summaryrefslogtreecommitdiff
path: root/displaymessage.c
diff options
context:
space:
mode:
authorSoeren Moch <smoch@web.de>2021-02-13 14:03:29 +0100
committerkamel5 <vdr.kamel5 (at) gmx (dot) net>2021-02-16 11:56:10 +0100
commitf0da5c8eacd54de7346bc000e86ad90ca0d18003 (patch)
tree3843abca573aad8fe4af607b28f5574029f29e63 /displaymessage.c
parent1e9345336c9e714c37495352ad37a67f72e6a7a2 (diff)
downloadskin-nopacity-f0da5c8eacd54de7346bc000e86ad90ca0d18003.tar.gz
skin-nopacity-f0da5c8eacd54de7346bc000e86ad90ca0d18003.tar.bz2
Split MessageBox class out of DisplayMessage
So we can reuse this MessageBox code later. Signed-off-by: Soeren Moch <smoch@web.de>
Diffstat (limited to 'displaymessage.c')
-rw-r--r--displaymessage.c69
1 files changed, 8 insertions, 61 deletions
diff --git a/displaymessage.c b/displaymessage.c
index e435dde..77a3bd0 100644
--- a/displaymessage.c
+++ b/displaymessage.c
@@ -10,76 +10,24 @@ cNopacityDisplayMessage::cNopacityDisplayMessage(cImageCache *imgCache) {
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);
- pixmap = osd->CreatePixmap(2, cRect(0, 0, geoManager->messageWidth, geoManager->messageHeight));
- pixmapBackground = osd->CreatePixmap(1, cRect(0, 0, geoManager->messageWidth, geoManager->messageHeight));
- if (FadeTime) {
- pixmap->SetAlpha(0);
- pixmapBackground->SetAlpha(0);
- }
+ messageBox = NULL;
}
cNopacityDisplayMessage::~cNopacityDisplayMessage() {
Cancel(-1);
while (Active())
cCondWait::SleepMs(10);
- osd->DestroyPixmap(pixmap);
- osd->DestroyPixmap(pixmapBackground);
+ delete messageBox;
delete osd;
}
void cNopacityDisplayMessage::SetMessage(eMessageType Type, const char *Text) {
- tColor col = Theme.Color(clrMessageStatus);
- tColor colFont = Theme.Color(clrMessageFontStatus);
- eSkinElementType seType = seMessageStatus;
- switch (Type) {
- case mtStatus:
- col = Theme.Color(clrMessageStatus);
- colFont = Theme.Color(clrMessageFontStatus);
- seType = seMessageStatus;
- break;
- case mtInfo:
- col = Theme.Color(clrMessageInfo);
- colFont = Theme.Color(clrMessageFontInfo);
- seType = seMessageInfo;
- break;
- case mtWarning:
- col = Theme.Color(clrMessageWarning);
- colFont = Theme.Color(clrMessageFontWarning);
- seType = seMessageWarning;
- break;
- case mtError:
- col = Theme.Color(clrMessageError);
- colFont = Theme.Color(clrMessageFontError);
- seType = seMessageError;
- break;
- }
-
- pixmap->Fill(clrTransparent);
- if (config.GetValue("displayType") == dtGraphical) {
- pixmapBackground->Fill(clrTransparent);
- cImage *imgBack = imgCache->GetSkinElement(seType);
- if (imgBack) {
- pixmapBackground->DrawImage(cPoint(0, 0), *imgBack);
- }
- } else {
- pixmapBackground->Fill(col);
- if (config.GetValue("displayType") == dtBlending) {
- cImage imgBack = imgCache->GetBackground(Theme.Color(clrMessageBlend), col, geoManager->messageWidth-2, geoManager->messageHeight-2, true);
- pixmapBackground->DrawImage(cPoint(1, 1), imgBack);
- }
- if (config.GetValue("roundedCorners")) {
- DrawRoundedCornersWithBorder(pixmapBackground, col, config.GetValue("cornerRadius"), geoManager->messageWidth, geoManager->messageHeight);
- }
- }
- int textWidth = fontManager->messageText->Width(Text);
- pixmap->DrawText(cPoint((geoManager->messageWidth - textWidth) / 2,
- (geoManager->messageHeight - fontManager->messageText->Height()) / 2),
- Text,
- colFont,
- clrTransparent,
- fontManager->messageText);
- if (FadeTime)
+ delete messageBox;
+ messageBox = new cNopacityMessageBox(osd, imgCache, cRect(0, 0, geoManager->messageWidth, geoManager->messageHeight), Type, Text);
+ if (FadeTime) {
+ messageBox->SetAlpha(0);
Start();
+ }
}
void cNopacityDisplayMessage::Flush(void) {
@@ -93,8 +41,7 @@ void cNopacityDisplayMessage::Action(void) {
cPixmap::Lock();
double t = std::min(double(Now - Start) / FadeTime, 1.0);
int Alpha = t * ALPHA_OPAQUE;
- pixmapBackground->SetAlpha(Alpha);
- pixmap->SetAlpha(Alpha);
+ messageBox->SetAlpha(Alpha);
cPixmap::Unlock();
if (Running())
osd->Flush();