diff options
author | kamel5 <vdr.kamel5 (at) gmx (dot) net> | 2021-06-11 15:56:45 +0200 |
---|---|---|
committer | kamel5 <vdr.kamel5 (at) gmx (dot) net> | 2021-07-12 13:41:16 +0200 |
commit | 4b1edb5a90c742aa7f34bf5910f9d75774011054 (patch) | |
tree | e4163bd3bd8b602b32896ded43e33792c139bb1e | |
parent | 4358bf876579464772f98cc3aa43af345d127880 (diff) | |
download | skin-nopacity-4b1edb5a90c742aa7f34bf5910f9d75774011054.tar.gz skin-nopacity-4b1edb5a90c742aa7f34bf5910f9d75774011054.tar.bz2 |
Add fade-out to display tracks
-rw-r--r-- | config.c | 1 | ||||
-rw-r--r-- | displaytracks.c | 28 | ||||
-rw-r--r-- | displaytracks.h | 5 | ||||
-rw-r--r-- | setup.c | 1 |
4 files changed, 22 insertions, 13 deletions
@@ -195,6 +195,7 @@ void cNopacityConfig::LoadDefaults(void) { conf.insert(std::pair<std::string, int>("fontMessage", 0)); //DisplayTracks conf.insert(std::pair<std::string, int>("tracksFadeTime", 300)); + conf.insert(std::pair<std::string, int>("tracksFadeOutTime", 300)); conf.insert(std::pair<std::string, int>("tracksWidth", 25)); conf.insert(std::pair<std::string, int>("tracksItemHeight", 80)); conf.insert(std::pair<std::string, int>("tracksPosition", 0)); diff --git a/displaytracks.c b/displaytracks.c index c53ecc7..586e083 100644 --- a/displaytracks.c +++ b/displaytracks.c @@ -6,11 +6,10 @@ cNopacityDisplayTracks::cNopacityDisplayTracks(const char *Title, int NumTracks, const char * const *Tracks) : cThread("DisplayTracks") { initial = true; + fadeout = false; currentIndex = -1; numTracks = NumTracks; audioChannelLast = -5; - FadeTime = config.GetValue("tracksFadeTime"); - FrameTime = FadeTime / 10; SetGeometry(); CreatePixmaps(); DrawHeader(Title); @@ -19,9 +18,17 @@ cNopacityDisplayTracks::cNopacityDisplayTracks(const char *Title, int NumTracks, } cNopacityDisplayTracks::~cNopacityDisplayTracks() { - Cancel(-1); - while (Active()) + if (config.GetValue("tracksFadeOutTime")) { + fadeout = true; + Start(); + } + int count = 0; + while (Active()) { cCondWait::SleepMs(10); + count++; + if (count > 150) + Cancel(1); + } osd->DestroyPixmap(pixmapContainer); osd->DestroyPixmap(pixmapHeader); osd->DestroyPixmap(pixmapHeaderAudio); @@ -112,14 +119,14 @@ void cNopacityDisplayTracks::DrawHeader(const char *Title) { pixmapHeader->DrawText(cPoint((width - fontManager->trackHeader->Width(Title)) / 2, (menuItemHeight - fontManager->trackHeader->Height()) / 2), Title, Theme.Color(clrTracksFontHead), clrTransparent, fontManager->trackHeader); } -void cNopacityDisplayTracks::SetAlpha(int Alpha) { +void cNopacityDisplayTracks::SetAlpha(int Alpha, bool Force) { if (config.GetValue("tracksFadeTime")) { pixmapContainer->SetAlpha(Alpha); pixmapHeader->SetAlpha(Alpha); pixmapHeaderAudio->SetAlpha(Alpha); pixmapIcon->SetAlpha(Alpha); for (auto i = menuItems.begin(); i != menuItems.end(); ++i) { - if (*i && Running()) { + if (*i && (Force || Running())) { cNopacityMenuItem *item = i->get(); item->SetAlpha(Alpha); } @@ -140,8 +147,6 @@ void cNopacityDisplayTracks::SetItem(const char *Text, int Index, bool Current) if (config.GetValue("displayType") == dtGraphical) item->CreatePixmapForeground(); item->Render(); - if (initial && config.GetValue("tracksFadeTime")) - item->SetAlpha(0); } void cNopacityDisplayTracks::SetTrack(int Index, const char * const *Tracks) { @@ -184,7 +189,7 @@ void cNopacityDisplayTracks::Flush(void) { if (Running()) return; if (initial && config.GetValue("tracksFadeTime")) { - SetAlpha(0); + SetAlpha(0, true); Start(); } initial = false; @@ -192,6 +197,9 @@ void cNopacityDisplayTracks::Flush(void) { } void cNopacityDisplayTracks::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(); @@ -200,7 +208,7 @@ void cNopacityDisplayTracks::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/displaytracks.h b/displaytracks.h index 79183b7..7d041fd 100644 --- a/displaytracks.h +++ b/displaytracks.h @@ -10,8 +10,7 @@ class cNopacityDisplayTracks : public cSkinDisplayTracks, cThread { private: cOsd *osd; - int FrameTime; - int FadeTime; + bool fadeout; int width, height; int menuItemWidth; int menuItemHeight; @@ -29,7 +28,7 @@ private: void SetGeometry(void); void CreatePixmaps(void); void DrawHeader(const char *Title); - void SetAlpha(int Alpha = 0); + void SetAlpha(int Alpha = 0, bool force = false); public: cNopacityDisplayTracks(const char *Title, int NumTracks, const char * const *Tracks); virtual ~cNopacityDisplayTracks(); @@ -461,6 +461,7 @@ void cNopacitySetupTrackDisplay::Set(void) { int currentItem = Current(); Clear(); Add(new cMenuEditIntItem(tr("Fade-In Time in ms (Zero for switching off fading)"), tmpConf->GetValueRef("tracksFadeTime"), 0, 1000)); + Add(new cMenuEditIntItem(tr("Fade-Out Time in ms (Zero for switching off fading)"), tmpConf->GetValueRef("tracksFadeOutTime"), 0, 1000)); Add(new cMenuEditIntItem(tr("Width of Tracks Display (Percent of OSD Width)"), tmpConf->GetValueRef("tracksWidth"), 10, 100)); Add(new cMenuEditIntItem(tr("Height of Track Items (in pixels)"), tmpConf->GetValueRef("tracksItemHeight"), 30, 200)); Add(new cMenuEditIntItem(tr("Position (0: bot. center, 1: bot. left, ... , 7: bot. right)"), tmpConf->GetValueRef("tracksPosition"), 0, 7)); |