summaryrefslogtreecommitdiff
path: root/textscroller.c
diff options
context:
space:
mode:
authorMartin Schirrmacher <vdr.skinflatplus@schirrmacher.eu>2014-06-30 17:26:17 +0200
committerMartin Schirrmacher <vdr.skinflatplus@schirrmacher.eu>2014-06-30 17:26:17 +0200
commitdf1bbb5136b0d5a5aa49917e77073e7c4818428b (patch)
treefef17aff0d0ff9f99abe738abbf09e3c1d44f77f /textscroller.c
parentc47fb40c9e8b8dbbe5125119feb4db324edb6778 (diff)
downloadskin-flatplus-df1bbb5136b0d5a5aa49917e77073e7c4818428b.tar.gz
skin-flatplus-df1bbb5136b0d5a5aa49917e77073e7c4818428b.tar.bz2
fix flicker with textscroller
Diffstat (limited to 'textscroller.c')
-rw-r--r--textscroller.c37
1 files changed, 24 insertions, 13 deletions
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);
}
}