diff options
author | kamel5 <vdr.kamel5 (at) gmx (dot) net> | 2021-06-11 16:42:05 +0200 |
---|---|---|
committer | kamel5 <vdr.kamel5 (at) gmx (dot) net> | 2021-07-12 13:41:18 +0200 |
commit | cdf36c1c87d4f953b275164fb91ba77f539c0cfc (patch) | |
tree | 300e21a88a98b23d21ce9644c572f88aa04529af | |
parent | 26f0adefa8c6eee4a5088ef899183f8499153879 (diff) | |
download | skin-nopacity-cdf36c1c87d4f953b275164fb91ba77f539c0cfc.tar.gz skin-nopacity-cdf36c1c87d4f953b275164fb91ba77f539c0cfc.tar.bz2 |
Add fade-out to display volume
-rw-r--r-- | config.c | 1 | ||||
-rw-r--r-- | displayvolume.c | 43 | ||||
-rw-r--r-- | displayvolume.h | 4 | ||||
-rw-r--r-- | setup.c | 1 |
4 files changed, 30 insertions, 19 deletions
@@ -205,6 +205,7 @@ void cNopacityConfig::LoadDefaults(void) { conf.insert(std::pair<std::string, int>("fontTracks", 0)); //DisplayVolume conf.insert(std::pair<std::string, int>("volumeFadeTime", 300)); + conf.insert(std::pair<std::string, int>("volumeFadeOutTime", 300)); conf.insert(std::pair<std::string, int>("volumeWidth", 40)); conf.insert(std::pair<std::string, int>("volumeHeight", 10)); conf.insert(std::pair<std::string, int>("volumeBorderBottom", 10)); diff --git a/displayvolume.c b/displayvolume.c index 78c6e83..9d90607 100644 --- a/displayvolume.c +++ b/displayvolume.c @@ -6,9 +6,8 @@ cNopacityDisplayVolume::cNopacityDisplayVolume(void) : cThread("DisplayVolume") { initial = true; + fadeout = false; muted = false; - FadeTime = config.GetValue("volumeFadeTime"); - FrameTime = FadeTime / 10; int top = geoManager->osdTop + geoManager->osdHeight - geoManager->volumeHeight - config.GetValue("volumeBorderBottom"); int left = geoManager->osdLeft + (geoManager->osdWidth - geoManager->volumeWidth) / 2; @@ -49,18 +48,20 @@ cNopacityDisplayVolume::cNopacityDisplayVolume(void) : cThread("DisplayVolume") } pixmapLabel = osd->CreatePixmap(2, cRect(0, 5, geoManager->volumeWidth, geoManager->volumeLabelHeight)); pixmapProgressBar = osd->CreatePixmap(2, cRect((geoManager->volumeWidth - geoManager->volumeProgressBarWidth) / 2, (geoManager->volumeHeight - geoManager->volumeProgressBarHeight)*2/3, geoManager->volumeProgressBarWidth, geoManager->volumeProgressBarHeight)); - - if (FadeTime) { - pixmapBackground->SetAlpha(0); - pixmapProgressBar->SetAlpha(0); - pixmapLabel->SetAlpha(0); - } } cNopacityDisplayVolume::~cNopacityDisplayVolume() { - Cancel(-1); - while (Active()) + if (config.GetValue("volumeFadeOutTime")) { + fadeout = true; + Start(); + } + int count = 0; + while (Active()) { cCondWait::SleepMs(10); + count++; + if (count > 150) + Cancel(1); + } osd->DestroyPixmap(pixmapBackground); osd->DestroyPixmap(pixmapLabel); osd->DestroyPixmap(pixmapProgressBar); @@ -128,17 +129,27 @@ tColor cNopacityDisplayVolume::DrawProgressbarBackground(int left, int top, int return clr; } +void cNopacityDisplayVolume::SetAlpha(int Alpha) { + pixmapBackground->SetAlpha(Alpha); + pixmapProgressBar->SetAlpha(Alpha); + pixmapLabel->SetAlpha(Alpha); +} + void cNopacityDisplayVolume::Flush(void) { if (Running()) return; - if (initial) - if (FadeTime) - Start(); + if (initial && config.GetValue("volumeFadeTime")) { + SetAlpha(0); + Start(); + } initial = false; osd->Flush(); } void cNopacityDisplayVolume::Action(void) { + int x = (fadeout) ? 255 : 0; + int FadeTime = (fadeout) ? config.GetValue("replayFadeOutTime") : config.GetValue("replayFadeTime"); + int FrameTime = FadeTime / 10; uint64_t First = cTimeMs::Now(); cPixmap::Lock(); cPixmap::Unlock(); @@ -147,11 +158,9 @@ void cNopacityDisplayVolume::Action(void) { while (Running()) { uint64_t Now = cTimeMs::Now(); double t = std::min(double(Now - Start) / FadeTime, 1.0); - int Alpha = t * ALPHA_OPAQUE; + int Alpha = std::abs(x - (int(t * ALPHA_OPAQUE))); cPixmap::Lock(); - pixmapBackground->SetAlpha(Alpha); - pixmapProgressBar->SetAlpha(Alpha); - pixmapLabel->SetAlpha(Alpha); + SetAlpha(Alpha); if (Running()) osd->Flush(); cPixmap::Unlock(); diff --git a/displayvolume.h b/displayvolume.h index bc4335b..6c184b2 100644 --- a/displayvolume.h +++ b/displayvolume.h @@ -7,9 +7,8 @@ class cNopacityDisplayVolume : public cSkinDisplayVolume, cThread { private: - int FrameTime; - int FadeTime; bool initial; + bool fadeout; bool muted; cOsd *osd; cPixmap *pixmapBackground; @@ -18,6 +17,7 @@ private: virtual void Action(void); void DrawProgressBar(int Current, int Total); tColor DrawProgressbarBackground(int left, int top, int width, int height); + void SetAlpha(int Alpha = 0); public: cNopacityDisplayVolume(void); virtual ~cNopacityDisplayVolume(void); @@ -504,6 +504,7 @@ void cNopacitySetupVolumeDisplay::Set(void) { int currentItem = Current(); Clear(); Add(new cMenuEditIntItem(tr("Fade-In Time in ms (Zero for switching off fading)"), tmpConf->GetValueRef("volumeFadeTime"), 0, 1000)); + Add(new cMenuEditIntItem(tr("Fade-Out Time in ms (Zero for switching off fading)"), tmpConf->GetValueRef("volumeFadeOutTime"), 0, 1000)); Add(new cMenuEditIntItem(tr("Width of Volume Display (Percent of OSD Height)"), tmpConf->GetValueRef("volumeWidth"), 10, 100)); Add(new cMenuEditIntItem(tr("Height of Volume Display (Percent of OSD Height)"), tmpConf->GetValueRef("volumeHeight"), 5, 100)); Add(new cMenuEditIntItem(tr("Bottom Border Height"), tmpConf->GetValueRef("volumeBorderBottom"), 0, 1000)); |