diff options
-rw-r--r-- | baserender.c | 17 | ||||
-rw-r--r-- | baserender.h | 1 | ||||
-rw-r--r-- | displaychannel.c | 3 | ||||
-rw-r--r-- | displaymenu.c | 7 | ||||
-rw-r--r-- | displaymenu.h | 3 | ||||
-rw-r--r-- | textscroller.c | 37 | ||||
-rw-r--r-- | textscroller.h | 23 |
7 files changed, 60 insertions, 31 deletions
diff --git a/baserender.c b/baserender.c index 2afa89f2..233d397e 100644 --- a/baserender.c +++ b/baserender.c @@ -17,6 +17,7 @@ cFlatBaseRender::cFlatBaseRender(void) { tobBarTitleExtra2 = ""; topBarLastDate = ""; topBarUpdateTitle = false; + topBarUpdateScroller = false; topBarHeight = 0; topBarExtraIconSet = false; topBarMenuIconSet = false; @@ -131,6 +132,11 @@ void cFlatBaseRender::TopBarCreate(void) { } void cFlatBaseRender::TopBarSetTitle(cString title) { + if( strcmp(*topBarTitle, *title) != 0 ) + topBarUpdateScroller = true; + + dsyslog("topBarTitle: %s title: %s topBarUpdateScroller: %d", *topBarTitle, *title, topBarUpdateScroller); + topBarTitle = title; tobBarTitleExtra1 = ""; tobBarTitleExtra2 = ""; @@ -200,14 +206,13 @@ void cFlatBaseRender::TopBarEnableDiskUsage(void) { TopBarSetTitleExtra(extra1, extra2); TopBarSetExtraIcon(iconName); } -// sollte bei jedum "Flush" aufgerufen werden! +// sollte bei jedem "Flush" aufgerufen werden! void cFlatBaseRender::TopBarUpdate(void) { cString curDate = DayDateTime(); int TopBarWidth = osdWidth - Config.decorBorderTopBarSize*2; int MenuIconWidth = 0; if ( strcmp(curDate, topBarLastDate) || topBarUpdateTitle ) { - topBarScroller.Clear(); topBarUpdateTitle = false; topBarLastDate = curDate; @@ -365,7 +370,11 @@ void cFlatBaseRender::TopBarUpdate(void) { int maxWidth = extraLeft - (MenuIconWidth + marginItem*2) - marginItem; if( (TitleWidth > maxWidth) && Config.ScrollerEnable ) { - topBarScroller.AddScroller(*topBarTitle, cRect(MenuIconWidth + marginItem*2, fontTop, maxWidth, topBarFontHeight), Theme.Color(clrTopBarFont), clrTransparent, topBarFont); + if( topBarUpdateScroller ) { + topBarScroller.Clear(); + topBarScroller.AddScroller(*topBarTitle, cRect(MenuIconWidth + marginItem*2, fontTop, maxWidth, topBarFontHeight), Theme.Color(clrTopBarFont), clrTransparent, topBarFont); + topBarUpdateScroller = false; + } TitleWidth = TitleWidthLeft; } else { /* int dotsWidth = topBarFont->Width("... "); @@ -403,7 +412,6 @@ void cFlatBaseRender::TopBarUpdate(void) { else topBarPixmap->DrawText(cPoint(ConLeft + ConW + marginItem, fontSmlTop), ConNum, Theme.Color(clrTopBarConflictHighFg), Theme.Color(clrTopBarConflictHighBg), topBarFontSml); } - } } @@ -559,7 +567,6 @@ void cFlatBaseRender::MessageSet(eMessageType Type, const char *Text) { messagePixmap->DrawText(cPoint((osdWidth - textWidth) / 2, marginItem), Text, Theme.Color(clrMessageFont), Theme.Color(clrMessageBg), font); } - int top = osdHeight - Config.MessageOffset - messageHeight - Config.decorBorderMessageSize; DecorBorderDraw(Config.decorBorderMessageSize, top, osdWidth - Config.decorBorderMessageSize*2, messageHeight, Config.decorBorderMessageSize, Config.decorBorderMessageType, Config.decorBorderMessageFg, Config.decorBorderMessageBg, BorderMessage); } diff --git a/baserender.h b/baserender.h index f092023a..cfe19392 100644 --- a/baserender.h +++ b/baserender.h @@ -45,6 +45,7 @@ class cFlatBaseRender cFont *topBarFont, *topBarFontSml; int topBarFontHeight, topBarFontSmlHeight; cTextScrollers topBarScroller; + bool topBarUpdateScroller; cString topBarTitle; cString tobBarTitleExtra1, tobBarTitleExtra2; diff --git a/displaychannel.c b/displaychannel.c index 3060b9f8..51df6014 100644 --- a/displaychannel.c +++ b/displaychannel.c @@ -315,9 +315,6 @@ void cFlatDisplayChannel::SetEvents(const cEvent *Present, const cEvent *Followi cString epg(""); scrollers.Clear(); - //scrollers.AddScroller("very long, stupid Text to scroll and other", cRect(20, 500, 300, fontHeight), Theme.Color(clrChannelFontEpg), Theme.Color(clrChannelBg), font); - //scrollers.AddScroller("second very long", cRect(20, 600, 400, fontHeight), Theme.Color(clrChannelFontEpg), Theme.Color(clrChannelBg), font); - //scrollers.AddScroller("third very long, stupid Text to scroll and other", cRect(20, 700, 500, fontHeight), Theme.Color(clrChannelFontEpg), Theme.Color(clrChannelBg), font); chanInfoBottomPixmap->Fill(Theme.Color(clrChannelBg)); chanIconsPixmap->Fill( clrTransparent ); diff --git a/displaymenu.c b/displaymenu.c index c1b0783c..f9307f4a 100644 --- a/displaymenu.c +++ b/displaymenu.c @@ -66,9 +66,16 @@ cFlatDisplayMenu::cFlatDisplayMenu(void) { menuCategory = mcUndefined; + scrollers.SetOsd(osd); + scrollers.SetScrollStep( Config.ScrollerStep ); + scrollers.SetScrollDelay( Config.ScrollerDelay ); + scrollers.SetScrollType( Config.ScrollerType ); + } cFlatDisplayMenu::~cFlatDisplayMenu() { + scrollers.Clear(); + osd->DestroyPixmap(menuPixmap); osd->DestroyPixmap(menuIconsPixmap); osd->DestroyPixmap(menuIconsBGPixmap); diff --git a/displaymenu.h b/displaymenu.h index 26919c9c..1ad36333 100644 --- a/displaymenu.h +++ b/displaymenu.h @@ -39,6 +39,9 @@ class cFlatDisplayMenu : public cFlatBaseRender, public cSkinDisplayMenu { cComplexContent ComplexContent; + // TextScroller + cTextScrollers scrollers; + cString ItemEventLastChannelName; // Icons diff --git a/textscroller.c b/textscroller.c index 487f1663..ee88338b 100644 --- a/textscroller.c +++ b/textscroller.c @@ -34,7 +34,7 @@ void cTextScroll::Draw(void) { Pixmap->DrawText(cPoint(0, 0), Text.c_str(), ColorFg, ColorBg, Font); } -void cTextScroll::DoStep(int Step) { +void cTextScroll::DoStep(void) { if( !Pixmap ) return; @@ -54,16 +54,16 @@ void cTextScroll::DoStep(int Step) { int drawPortX = Pixmap->DrawPort().X(); if( isReserveStep ) - drawPortX += Step; + drawPortX += PixelsPerStep; else - drawPortX -= Step; + drawPortX -= PixelsPerStep; int maxX = Pixmap->DrawPort().Width() - Pixmap->ViewPort().Width(); maxX *= -1; if( ScrollType == 0 ) { if( drawPortX <= maxX ) { - drawPortX += Step; + drawPortX += PixelsPerStep; ResetX = true; waitSteps = WAITSTEPS; } @@ -75,7 +75,6 @@ void cTextScroll::DoStep(int Step) { isReserveStep = false; waitSteps = WAITSTEPS; } - } Pixmap->SetDrawPortPoint(cPoint(drawPortX, 0)); @@ -103,18 +102,30 @@ void cTextScrollers::Clear(void) { void cTextScrollers::AddScroller(const char *text, cRect position, tColor colorFg, tColor colorBg, cFont *font) { Cancel(-1); - while (Active()) + while( Active() ) cCondWait::SleepMs(10); - Scrollers.push_back( new cTextScroll(Osd, scrollType, Layer) ); + Scrollers.push_back( new cTextScroll(Osd, scrollType, scrollStep, (int)((double)WAITDELAY / (double)scrollDelay), Layer) ); Scrollers.back()->SetText(text, position, colorFg, colorBg, font); - if( !Running() ) { + StartScrolling(); +} + +void cTextScrollers::StartScrolling(void) { + if( !Running() && Scrollers.size() > 0 ) { Start(); } } void cTextScrollers::Action(void) { + // wait 1 second so the osd is finished + for(int i = 0; i < 100 && Running(); i++ ) { + cCondWait::SleepMs(10); + } + + if( !Running() ) + return; + std::vector<cTextScroll *>::iterator it; for( it = Scrollers.begin(); it != Scrollers.end(); it++) { if( !Running() ) @@ -125,20 +136,20 @@ void cTextScrollers::Action(void) { } while( Running() ) { + if (Running()) + cCondWait::SleepMs(scrollDelay); + std::vector<cTextScroll *>::iterator it; for( it = Scrollers.begin(); it != Scrollers.end(); it++) { if( !Running() ) return; cPixmap::Lock(); - (*it)->DoStep(scrollStep); + (*it)->DoStep(); cPixmap::Unlock(); } - if (Running()) + if( Running() ) Osd->Flush(); - - if (Running()) - cCondWait::SleepMs(scrollDelay); } } diff --git a/textscroller.h b/textscroller.h index 624a557c..4e428987 100644 --- a/textscroller.h +++ b/textscroller.h @@ -5,7 +5,7 @@ #include <string.h> #include <vdr/thread.h> -#define WAITSTEPS 50 +#define WAITDELAY 1000 // in ms class cTextScroll { @@ -18,32 +18,33 @@ private: cPixmap *Pixmap; cOsd *Osd; int Layer; - - int waitSteps; + int PixelsPerStep; + int WAITSTEPS, waitSteps; bool isReserveStep; bool ResetX; int ScrollType; public: - cTextScroll(cOsd *osd, int type, int layer) { + cTextScroll(cOsd *osd, int type, int pixels, int waitsteps, int layer) { Font = NULL; Pixmap = NULL; Osd = osd; Layer = layer; - + PixelsPerStep = pixels; ScrollType = type; isReserveStep = false; - waitSteps = WAITSTEPS; + WAITSTEPS = waitsteps; ResetX = false; + dsyslog("waitSteps: %d", waitSteps); } - cTextScroll(cOsd *osd, int type) { + cTextScroll(cOsd *osd, int type, int pixels, int waitsteps) { Font = NULL; Pixmap = NULL; Osd = osd; Layer = 2; - + PixelsPerStep = pixels; ScrollType = type; isReserveStep = false; - waitSteps = WAITSTEPS; + WAITSTEPS = waitsteps; ResetX = false; } @@ -56,7 +57,7 @@ public: void Reset(void); void SetText(const char *text, cRect position, tColor colorFg, tColor colorBg, cFont *font); - void DoStep(int Step); + void DoStep(void); void Draw(void); }; @@ -71,6 +72,7 @@ private: int scrollType; int Layer; virtual void Action(void); + void StartScrolling(void); public: cTextScrollers(); ~cTextScrollers(); @@ -82,4 +84,5 @@ public: void SetScrollDelay(int delay) { scrollDelay = delay; } void SetScrollType(int type) { scrollType = type; } void AddScroller(const char *text, cRect position, tColor colorFg, tColor colorBg, cFont *font); + bool isActive(void) { return Active(); } }; |