-
Notifications
You must be signed in to change notification settings - Fork 0
/
displaymessage.c
69 lines (64 loc) · 2.27 KB
/
displaymessage.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include "displaymessage.h"
#include "config.h"
#include "imageloader.h"
#include "helpers.h"
cNopacityDisplayMessage::cNopacityDisplayMessage(void) : cThread("DisplayMessage") {
fadeout = false;
int top = geoManager->osdTop + geoManager->osdHeight - geoManager->messageHeight - config.GetValue("messageBorderBottom");
int left = geoManager->osdLeft + (geoManager->osdWidth - geoManager->messageWidth) / 2;
osd = CreateOsd(left, top, geoManager->messageWidth, geoManager->messageHeight);
messageBox = NULL;
}
cNopacityDisplayMessage::~cNopacityDisplayMessage() {
if (config.GetValue("animation") && config.GetValue("messageFadeOutTime")) {
fadeout = true;
Start();
}
int count = 0;
while (Active()) {
cCondWait::SleepMs(10);
count++;
if (count > 150)
Cancel(1);
}
delete messageBox;
delete osd;
}
void cNopacityDisplayMessage::SetMessage(eMessageType Type, const char *Text) {
delete messageBox;
messageBox = new cNopacityMessageBox(osd, cRect(0, 0, geoManager->messageWidth, geoManager->messageHeight), Type, Text);
if (config.GetValue("animation") && config.GetValue("messageFadeTime")) {
messageBox->SetAlpha(0);
Start();
}
}
void cNopacityDisplayMessage::Flush(void) {
if (Running())
return;
osd->Flush();
}
void cNopacityDisplayMessage::Action(void) {
int x = (fadeout) ? 255 : 0;
int FadeTime = (fadeout) ? config.GetValue("messageFadeOutTime") : config.GetValue("messageFadeTime");
int FrameTime = FadeTime / 10;
uint64_t First = cTimeMs::Now();
cPixmap::Lock();
cPixmap::Unlock();
uint64_t Start = cTimeMs::Now();
dsyslog ("skinnopacity: First Lock(): %llums \n", (long long)(Start - First));
while (Running()) {
uint64_t Now = cTimeMs::Now();
double t = std::min(double(Now - Start) / FadeTime, 1.0);
int Alpha = std::abs(x - (int(t * ALPHA_OPAQUE)));
cPixmap::Lock();
messageBox->SetAlpha(Alpha);
if (Running())
osd->Flush();
cPixmap::Unlock();
int Delta = cTimeMs::Now() - Now;
if (Running() && (Delta < FrameTime))
cCondWait::SleepMs(FrameTime - Delta);
if ((int)(Now - Start) > FadeTime)
break;
}
}