summaryrefslogtreecommitdiff
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
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>
-rw-r--r--Makefile2
-rw-r--r--displaymessage.c69
-rw-r--r--displaymessage.h6
-rw-r--r--messagebox.c71
-rw-r--r--messagebox.h18
5 files changed, 101 insertions, 65 deletions
diff --git a/Makefile b/Makefile
index 54cea3d..3575668 100644
--- a/Makefile
+++ b/Makefile
@@ -65,7 +65,7 @@ endif
### The object files (add further files here):
OBJS = $(PLUGIN).o config.o detailview.o displaychannel.o displaymenu.o displaymenuview.o displaymessage.o displayreplay.o displaytracks.o displayvolume.o displaychannelview.o fontmanager.o \
- geometrymanager.o imagecache.o imagemagickwrapper.o imagescaler.o helpers.o imageloader.o menudetailview.o menuitem.o nopacity.o setup.o textwindow.o timers.o
+ geometrymanager.o imagecache.o imagemagickwrapper.o imagescaler.o helpers.o imageloader.o menudetailview.o menuitem.o messagebox.o nopacity.o setup.o textwindow.o timers.o
### The main target:
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();
diff --git a/displaymessage.h b/displaymessage.h
index fc1d5b0..e89d4fb 100644
--- a/displaymessage.h
+++ b/displaymessage.h
@@ -4,13 +4,13 @@
#include <vdr/thread.h>
#include <vdr/skins.h>
#include "imagecache.h"
+#include "messagebox.h"
class cNopacityDisplayMessage : public cSkinDisplayMessage , cThread {
private:
cOsd *osd;
cImageCache *imgCache;
- cPixmap *pixmap;
- cPixmap *pixmapBackground;
+ cNopacityMessageBox *messageBox;
int FrameTime;
int FadeTime;
virtual void Action(void);
@@ -21,4 +21,4 @@ public:
virtual void Flush(void);
};
-#endif //__NOPACITY_DISPLAYMESSAGE_H \ No newline at end of file
+#endif //__NOPACITY_DISPLAYMESSAGE_H
diff --git a/messagebox.c b/messagebox.c
new file mode 100644
index 0000000..70398be
--- /dev/null
+++ b/messagebox.c
@@ -0,0 +1,71 @@
+#include "config.h"
+#include "helpers.h"
+#include "imageloader.h"
+#include "messagebox.h"
+
+cNopacityMessageBox::cNopacityMessageBox(cOsd *Osd, cImageCache *imgCache, const cRect &Rect, eMessageType Type, const char *Text) {
+ osd = Osd;
+ pixmap = osd->CreatePixmap(7, Rect);
+ pixmapBackground = osd->CreatePixmap(6, Rect);
+
+ tColor col;
+ tColor colFont;
+ eSkinElementType seType;
+ switch (Type) {
+ 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;
+ default: // case mtStatus:
+ col = Theme.Color(clrMessageStatus);
+ colFont = Theme.Color(clrMessageFontStatus);
+ seType = seMessageStatus;
+ 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, Rect.Width()-2, Rect.Height()-2, true);
+ pixmapBackground->DrawImage(cPoint(1, 1), imgBack);
+ }
+ if (config.GetValue("roundedCorners")) {
+ DrawRoundedCornersWithBorder(pixmapBackground, col, config.GetValue("cornerRadius"), Rect.Width(), Rect.Height());
+ }
+ }
+ int textWidth = fontManager->messageText->Width(Text);
+ pixmap->DrawText(cPoint((Rect.Width() - textWidth) / 2,
+ (Rect.Height() - fontManager->messageText->Height()) / 2),
+ Text,
+ colFont,
+ clrTransparent,
+ fontManager->messageText);
+}
+
+cNopacityMessageBox::~cNopacityMessageBox() {
+ osd->DestroyPixmap(pixmap);
+ osd->DestroyPixmap(pixmapBackground);
+}
+
+void cNopacityMessageBox::SetAlpha(int Alpha) {
+ pixmap->SetAlpha(Alpha);
+ pixmapBackground->SetAlpha(Alpha);
+}
diff --git a/messagebox.h b/messagebox.h
new file mode 100644
index 0000000..75c1df4
--- /dev/null
+++ b/messagebox.h
@@ -0,0 +1,18 @@
+#ifndef __NOPACITY_MESSAGEBOX_H
+#define __NOPACITY_MESSAGEBOX_H
+
+#include <vdr/skins.h>
+#include "imagecache.h"
+
+class cNopacityMessageBox {
+private:
+ cOsd *osd;
+ cPixmap *pixmap;
+ cPixmap *pixmapBackground;
+public:
+ cNopacityMessageBox(cOsd *Osd, cImageCache *imgCache, const cRect &Rect, eMessageType Type, const char *Text);
+ ~cNopacityMessageBox();
+ void SetAlpha(int Alpha);
+ };
+
+#endif //__NOPACITY_MESSAGEBOX_H