]> git.vomp.tv Git - vompclient-marten.git/commitdiff
Moving clock
authorChris Tallon <chris@vomp.tv>
Sat, 3 Dec 2005 00:31:46 +0000 (00:31 +0000)
committerChris Tallon <chris@vomp.tv>
Sat, 3 Dec 2005 00:31:46 +0000 (00:31 +0000)
timers.cc
viewman.cc
viewman.h
vwelcome.cc
vwelcome.h

index e734f5bce50abae24173fef0f1786e4f3e8e3285..d1ac5e85b6a1216c4b6c9ef6a3151b5e1b23ce78 100755 (executable)
--- 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)");\r
       threadWaitForSignalTimed(&nextTime); // FIXME does this work if the time is in the past?\r
 logger->log("Timers", Log::DEBUG, "LOCKED -TIMERS- MUTEX 5");\r
-      logger->log("Timers", Log::DEBUG, "FIXME CHECK does waitforsignaltimed work for time < now?");\r
 \r
       // unlocks in the wait\r
     }\r
index 633a574739f006f343f2893ea96ce4e3e95e7d7e..5c106efba8641a6c30966fef833847854c8ec617 100644 (file)
@@ -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)
 {
index fcef28131233cc3064b05e611391633c07769be9..6fc3d2b42d896915f2c1ab51da4e2dfbc00469c9 100644 (file)
--- 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);
 
index 0dd982744bd03dca3815f6229ed7d814c21cfe69..7ee0c6f5d36b9743cc032f4d18e95bcbc0f0cbeb 100644 (file)
@@ -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:
     {
index e90242f9e7da3ee04644e0b8925c9173d0c30855..fb788a8efef561742c091960ea84f58be948c6e9 100644 (file)
@@ -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