From e399e4115e767698a95c0dee7afaa96af10d1eb4 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Sat, 3 Dec 2005 00:31:46 +0000 Subject: [PATCH] Moving clock --- timers.cc | 1 - viewman.cc | 33 ++++++++++++++++++++++++++++----- viewman.h | 1 + vwelcome.cc | 40 +++++++++++++++++++++++++++++++++++++--- vwelcome.h | 6 +++++- 5 files changed, 71 insertions(+), 10 deletions(-) diff --git a/timers.cc b/timers.cc index e734f5b..d1ac5e8 100755 --- a/timers.cc +++ b/timers.cc @@ -247,7 +247,6 @@ void Timers::threadMethod() logger->log("Timers", Log::DEBUG, "about to un-LOCK -TIMERS- MUTEX (1)"); threadWaitForSignalTimed(&nextTime); // FIXME does this work if the time is in the past? logger->log("Timers", Log::DEBUG, "LOCKED -TIMERS- MUTEX 5"); - logger->log("Timers", Log::DEBUG, "FIXME CHECK does waitforsignaltimed work for time < now?"); // unlocks in the wait } diff --git a/viewman.cc b/viewman.cc index 633a574..5c106ef 100644 --- a/viewman.cc +++ b/viewman.cc @@ -130,16 +130,40 @@ void ViewMan::deleteView(int z) } } -/* For later... -void ViewMan::update(int z) +// FIXME - make this take a optional region for smaller updates (not whole views) +void ViewMan::updateView(View* toUpdate, Region* regionToUpdate) { + // Get the z index of the view + + int z; + for (z = 0; z < numViews; z++) + { + if (views[z] == toUpdate) break; + } + + if (z == numViews) + { + // not a View we have! + return; + } + // get the region for the whole view, could be less than that // for smaller updates Region r = views[z]->area; - RegionList rl; - r.y += 10; + if (regionToUpdate) + { + // Can be null if the whole view should be updated + // If this is given the numbers are relative to the size of the view, not the screen + + r.x += regionToUpdate->x; + r.y += regionToUpdate->y; + r.w = regionToUpdate->w; + r.h = regionToUpdate->h; + } + + RegionList rl; Region r2; boxSplit(r, z+1, numViews, 1, rl); @@ -151,7 +175,6 @@ void ViewMan::update(int z) rl.pop_front(); } } -*/ void ViewMan::repaintRevealed(int x, Region r) { diff --git a/viewman.h b/viewman.h index fcef281..6fc3d2b 100644 --- a/viewman.h +++ b/viewman.h @@ -55,6 +55,7 @@ class ViewMan : public MessageQueue int add(View* v); int removeView(View* toRemove); void removeAll(); + void updateView(View* toUpdate, Region* regionToUpdate = NULL); int handleCommand(UCHAR command); diff --git a/vwelcome.cc b/vwelcome.cc index 0dd9827..7ee0c6f 100644 --- a/vwelcome.cc +++ b/vwelcome.cc @@ -26,6 +26,11 @@ VWelcome::VWelcome() { instance = this; + clockRegion.x = 400; + clockRegion.y = 0; + clockRegion.w = 60; + clockRegion.h = 30; + create(460, 200); if (Video::getInstance()->getFormat() == Video::PAL) { @@ -52,6 +57,7 @@ VWelcome::VWelcome() VWelcome::~VWelcome() { + Timers::getInstance()->cancelTimer(this, 1); instance = NULL; } @@ -76,23 +82,51 @@ void VWelcome::draw() { View::draw(); sl.draw(); + jpeg.init("/vdr.jpg"); + jpeg.draw(); + drawClock(); +} + +void VWelcome::drawClock() +{ + // Blank the area first + rectangle(area.w - 60, 0, 60, 30, titleBarColour); char timeString[20]; time_t t; time(&t); struct tm* tms = localtime(&t); strftime(timeString, 19, "%H:%M", tms); - drawTextRJ(timeString, 450, 5, Colour::LIGHTTEXT); + time_t dt = 60 - (t % 60); + if (dt == 0) dt = 60; + Timers::getInstance()->setTimer(this, 1, (struct timespec){dt, 0}); +} - jpeg.init("/vdr.jpg"); - jpeg.draw(); +void VWelcome::timercall(int clientReference) +{ + drawClock(); + ViewMan::getInstance()->updateView(this, &clockRegion); } int VWelcome::handleCommand(int command) { switch(command) { + case Remote::NINE: + { + VInfo* viewWait = new VInfo(); + viewWait->create(100, 100); + viewWait->setScreenPos(485, 185); + viewWait->setTitleBarOn(0); + viewWait->setBackgroundColour(Colour::DANGER); + viewWait->draw(); + viewWait->show(); + ViewMan::getInstance()->add(viewWait); + + return 2; + } + case Remote::DF_UP: case Remote::UP: { diff --git a/vwelcome.h b/vwelcome.h index e90242f..fb788a8 100644 --- a/vwelcome.h +++ b/vwelcome.h @@ -40,7 +40,7 @@ #include "voptions.h" #include "i18n.h" -class VWelcome : public View +class VWelcome : public View, public TimerReceiver { public: VWelcome(); @@ -51,6 +51,7 @@ class VWelcome : public View int handleCommand(int command); void processMessage(Message* m); void draw(); + void timercall(int clientReference); private: static VWelcome* instance; @@ -61,6 +62,9 @@ class VWelcome : public View void doRadioList(); void doRecordingsList(); void doOptions(); + void drawClock(); + + Region clockRegion; }; #endif -- 2.39.5