]> git.vomp.tv Git - vompclient-marten.git/commitdiff
Fix overdrawing progress bar at startup
authorChris Tallon <chris@vomp.tv>
Thu, 15 Jun 2006 23:09:32 +0000 (23:09 +0000)
committerChris Tallon <chris@vomp.tv>
Thu, 15 Jun 2006 23:09:32 +0000 (23:09 +0000)
vvideorec.cc

index 73626742e3835adb60e673328e30fa5ee4ec8b32..4b7b27184fc4dbe82d6838b0ee0717f5fbb2f5c7 100644 (file)
@@ -377,6 +377,18 @@ void VVideoRec::drawBarClocks()
   Log* logger = Log::getInstance();
   logger->log("VVideoRec", Log::DEBUG, "Draw bar clocks");
 
+  // Draw RTC
+  // Blank the area first
+  rectangle(barRegion.x + 624, barRegion.y + 12, 60, 30, barBlue);
+  char timeString[20];
+  time_t t;
+  time(&t);
+  struct tm* tms = localtime(&t);
+  strftime(timeString, 19, "%H:%M", tms);
+  drawText(timeString, barRegion.x + 624, barRegion.y + 12, Colour::LIGHTTEXT);
+
+  // Draw clocks
+
   rectangle(clocksRegion, barBlue);
 
   ULONG currentFrameNum = player->getCurrentFrameNum();
@@ -386,26 +398,19 @@ void VVideoRec::drawBarClocks()
   hmsf lengthHMSF = video->framesToHMSF(lengthFrames);
 
   char buffer[100];
-//  strcpy(buffer, "-:--:-- / -:--:--");
-//  else
-//  {
+  if (currentFrameNum >= lengthFrames)
+  {
+    strcpy(buffer, "-:--:-- / -:--:--");
+  }
+  else
+  {
     SNPRINTF(buffer, 99, "%01i:%02i:%02i / %01i:%02i:%02i", currentFrameHMSF.hours, currentFrameHMSF.minutes, currentFrameHMSF.seconds, lengthHMSF.hours, lengthHMSF.minutes, lengthHMSF.seconds);
     logger->log("VVideoRec", Log::DEBUG, buffer);
-//  }
+  }
 
   drawText(buffer, clocksRegion.x, clocksRegion.y, Colour::LIGHTTEXT);
 
 
-  // Draw clock
-  // Blank the area first
-  rectangle(barRegion.x + 624, barRegion.y + 12, 60, 30, barBlue);
-  char timeString[20];
-  time_t t;
-  time(&t);
-  struct tm* tms = localtime(&t);
-  strftime(timeString, 19, "%H:%M", tms);
-  drawText(timeString, barRegion.x + 624, barRegion.y + 12, Colour::LIGHTTEXT);
-
 
 
 
@@ -417,22 +422,26 @@ void VVideoRec::drawBarClocks()
   rectangle(barRegion.x + progBarXbase, barRegion.y + 12, 310, 24, Colour::LIGHTTEXT);
   rectangle(barRegion.x + progBarXbase + 2, barRegion.y + 14, 306, 20, barBlue);
 
-  int progressWidth = 302 * currentFrameNum / lengthFrames;
+  if (currentFrameNum < lengthFrames)
+  {
+
+    int progressWidth = 302 * currentFrameNum / lengthFrames;
 
-  rectangle(barRegion.x + progBarXbase + 4, barRegion.y + 16, progressWidth, 16, Colour::SELECTHIGHLIGHT);
+    rectangle(barRegion.x + progBarXbase + 4, barRegion.y + 16, progressWidth, 16, Colour::SELECTHIGHLIGHT);
 
-  // Now calc position for start margin blips
-  int posPix;
+    // Now calc position for start margin blips
+    int posPix;
 
-  posPix = 302 * startMargin * video->getFPS() / lengthFrames;
+    posPix = 302 * startMargin * video->getFPS() / lengthFrames;
 
-  rectangle(barRegion.x + progBarXbase + 2 + posPix, barRegion.y + 12 - 2, 2, 2, Colour::LIGHTTEXT);
-  rectangle(barRegion.x + progBarXbase + 2 + posPix, barRegion.y + 12 + 24, 2, 2, Colour::LIGHTTEXT);
+    rectangle(barRegion.x + progBarXbase + 2 + posPix, barRegion.y + 12 - 2, 2, 2, Colour::LIGHTTEXT);
+    rectangle(barRegion.x + progBarXbase + 2 + posPix, barRegion.y + 12 + 24, 2, 2, Colour::LIGHTTEXT);
 
-  posPix = 302 * (lengthFrames - endMargin * video->getFPS()) / lengthFrames;
+    posPix = 302 * (lengthFrames - endMargin * video->getFPS()) / lengthFrames;
 
-  rectangle(barRegion.x + progBarXbase + 2 + posPix, barRegion.y + 12 - 2, 2, 2, Colour::LIGHTTEXT);
-  rectangle(barRegion.x + progBarXbase + 2 + posPix, barRegion.y + 12 + 24, 2, 2, Colour::LIGHTTEXT);
+    rectangle(barRegion.x + progBarXbase + 2 + posPix, barRegion.y + 12 - 2, 2, 2, Colour::LIGHTTEXT);
+    rectangle(barRegion.x + progBarXbase + 2 + posPix, barRegion.y + 12 + 24, 2, 2, Colour::LIGHTTEXT);
+  }
 }
 
 void VVideoRec::removeBar()