From 147ceb76b764f20ac530f7ee99206150d8c9e31b Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Thu, 15 Jun 2006 23:09:32 +0000 Subject: [PATCH] Fix overdrawing progress bar at startup --- vvideorec.cc | 57 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/vvideorec.cc b/vvideorec.cc index 7362674..4b7b271 100644 --- a/vvideorec.cc +++ b/vvideorec.cc @@ -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() -- 2.39.2