blob: 92753f0d619c6c5cb91066360eac77adc13038dc (
plain)
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
|
#include "displaymessage.h"
#include "config.h"
#include "imageloader.h"
#include "helpers.h"
cNopacityDisplayMessage::cNopacityDisplayMessage(void) {
FadeTime = config.GetValue("messageFadeTime");
FrameTime = FadeTime / 10;
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() {
Cancel(-1);
while (Active())
cCondWait::SleepMs(10);
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 (FadeTime) {
messageBox->SetAlpha(0);
Start();
}
}
void cNopacityDisplayMessage::Flush(void) {
osd->Flush();
}
void cNopacityDisplayMessage::Action(void) {
uint64_t Start = cTimeMs::Now();
while (Running()) {
uint64_t Now = cTimeMs::Now();
cPixmap::Lock();
double t = std::min(double(Now - Start) / FadeTime, 1.0);
int Alpha = t * ALPHA_OPAQUE;
messageBox->SetAlpha(Alpha);
cPixmap::Unlock();
if (Running())
osd->Flush();
int Delta = cTimeMs::Now() - Now;
if (Running() && (Delta < FrameTime))
cCondWait::SleepMs(FrameTime - Delta);
if ((int)(Now - Start) > FadeTime)
break;
}
}
|