diff options
author | kamel5 <vdr.kamel5 (at) gmx (dot) net> | 2021-06-11 12:53:34 +0200 |
---|---|---|
committer | kamel5 <vdr.kamel5 (at) gmx (dot) net> | 2021-07-12 13:27:48 +0200 |
commit | 97fa0bc7ff041c102975fcf19b82c1e4eb623efa (patch) | |
tree | f1cb928de77ef6933645f30575f5cc1bcf6a0c67 | |
parent | 32affb0a183db7fad828b2f262896a8b15d24cd0 (diff) | |
download | skin-nopacity-97fa0bc7ff041c102975fcf19b82c1e4eb623efa.tar.gz skin-nopacity-97fa0bc7ff041c102975fcf19b82c1e4eb623efa.tar.bz2 |
Add fade-out to display replay
-rw-r--r-- | config.c | 1 | ||||
-rw-r--r-- | displayreplay.c | 30 | ||||
-rw-r--r-- | displayreplay.h | 3 | ||||
-rw-r--r-- | setup.c | 1 |
4 files changed, 22 insertions, 13 deletions
@@ -184,6 +184,7 @@ void cNopacityConfig::LoadDefaults(void) { conf.insert(std::pair<std::string, int>("replayBorderVertical", 15)); conf.insert(std::pair<std::string, int>("replayBorderBottom", 15)); conf.insert(std::pair<std::string, int>("replayFadeTime", 300)); + conf.insert(std::pair<std::string, int>("replayFadeOutTime", 300)); conf.insert(std::pair<std::string, int>("fontReplayHeader", 0)); conf.insert(std::pair<std::string, int>("fontReplay", 0)); //DisplayMessage diff --git a/displayreplay.c b/displayreplay.c index 5810ffa..7072fd3 100644 --- a/displayreplay.c +++ b/displayreplay.c @@ -5,10 +5,9 @@ cNopacityDisplayReplay::cNopacityDisplayReplay(bool ModeOnly) : cThread("DisplayReplay") { initial = true; + fadeout = false; modeOnly = ModeOnly; lastDate = ""; - FadeTime = config.GetValue("replayFadeTime"); - FrameTime = FadeTime / 10; createOSD(); CreatePixmaps(); DrawBackground(); @@ -17,9 +16,17 @@ cNopacityDisplayReplay::cNopacityDisplayReplay(bool ModeOnly) : cThread("Display } cNopacityDisplayReplay::~cNopacityDisplayReplay() { - Cancel(-1); - while (Active()) + if (config.GetValue("replayFadeOutTime")) { + fadeout = true; + Start(); + } + int count = 0; + while (Active()) { cCondWait::SleepMs(10); + count++; + if (count > 150) + Cancel(1); + } if (!modeOnly) { osd->DestroyPixmap(pixmapBackground); osd->DestroyPixmap(pixmapTop); @@ -143,9 +150,7 @@ void cNopacityDisplayReplay::CreatePixmaps(void) { iconSize, iconSize)); - if (FadeTime) { - SetAlpha(0); - } else if (!modeOnly) { + if (!modeOnly) { int alphaBack = (100 - config.GetValue("channelBackgroundTransparency"))*255/100; pixmapBackground->SetAlpha(alphaBack); } @@ -488,15 +493,18 @@ void cNopacityDisplayReplay::Flush(void) { if (!modeOnly) { DrawDate(); } - if (initial) { - if (FadeTime) - Start(); + if (initial && config.GetValue("replayFadeTime")) { + SetAlpha(0); + Start(); } initial = false; osd->Flush(); } void cNopacityDisplayReplay::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(); @@ -505,7 +513,7 @@ void cNopacityDisplayReplay::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(); SetAlpha(Alpha); if (Running()) diff --git a/displayreplay.h b/displayreplay.h index 12e2a4d..58be8cc 100644 --- a/displayreplay.h +++ b/displayreplay.h @@ -12,8 +12,7 @@ private: bool initial; bool modeOnly; cString lastDate; - int FrameTime; - int FadeTime; + bool fadeout; cPixmap *pixmapBackground; cPixmap *pixmapTop; cPixmap *pixmapInfo; @@ -440,6 +440,7 @@ void cNopacitySetupReplayDisplay::Set(void) { Clear(); Add(new cMenuEditIntItem(tr("Fade-In Time in ms (Zero for switching off fading)"), tmpConf->GetValueRef("replayFadeTime"), 0, 1000)); + Add(new cMenuEditIntItem(tr("Fade-Out Time in ms (Zero for switching off fading)"), tmpConf->GetValueRef("replayFadeOutTime"), 0, 1000)); Add(new cMenuEditIntItem(tr("Height of Replay Display (Percent of OSD Height)"), tmpConf->GetValueRef("replayHeight"), 15, 80)); Add(new cMenuEditIntItem(tr("Left & Right Border Width"), tmpConf->GetValueRef("replayBorderVertical"), 0, 300)); Add(new cMenuEditIntItem(tr("Bottom Border Height"), tmpConf->GetValueRef("replayBorderBottom"), 0, 300)); |