Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vdr] Vdr Patch to display progress bars



Hi
I programmed  a little patch for vdr to show progress bars next to the 
epg infos in the "whats on" menu.

Our former decoder had such a feature, I always thought it was very 
practical...

If enough people like it, klaus will hopefully integrate it into vdr.

Matthias

--------------------------------------- begin patch 
---------------------------------------------------
diff -u vdr-1.0.0pre4/dvbosd.h myvdr41/dvbosd.h
--- vdr-1.0.0pre4/dvbosd.h    Sun Feb  3 17:43:50 2002
+++ myvdr41/dvbosd.h    Sat Mar 23 11:32:14 2002
@@ -82,6 +82,7 @@
   void SetPixel(int x, int y, eDvbColor Color);
   void SetBitmap(int x, int y, const cBitmap &Bitmap);
   int Width(void) { return width; }
+  int Height(void) { return height; }
   int Width(unsigned char c);
   int Width(const char *s);
   void Text(int x, int y, const char *s, eDvbColor ColorFg = clrWhite, 
eDvbColor ColorBg = clrBackground);
Common subdirectories: vdr-1.0.0pre4/libdtv and myvdr41/libdtv
diff -u vdr-1.0.0pre4/menu.c myvdr41/menu.c
--- vdr-1.0.0pre4/menu.c    Sun Mar 17 15:23:44 2002
+++ myvdr41/menu.c    Sat Mar 23 16:58:17 2002
@@ -1375,18 +1375,80 @@
 class cMenuWhatsOnItem : public cOsdItem {
 public:
   const cEventInfo *eventInfo;
-  cMenuWhatsOnItem(const cEventInfo *EventInfo);
+  cMenuWhatsOnItem(const cEventInfo *EventInfo, bool ShowProgressBar);
+  ~cMenuWhatsOnItem();
+  virtual void Display(int Offset = -1, eDvbColor FgColor = clrWhite, 
eDvbColor BgColor = clrBackground);
+ protected:
+  cBitmap *progressBar;
+  bool showProgressBar;
+  float percent;
+ private:
+  void DrawProgressBar(eDvbColor FgColor, eDvbColor BgColor);
 };
 
-cMenuWhatsOnItem::cMenuWhatsOnItem(const cEventInfo *EventInfo)
+cMenuWhatsOnItem::~cMenuWhatsOnItem() {
+  if (showProgressBar)
+    delete progressBar;
+}
+
+void cMenuWhatsOnItem::DrawProgressBar(eDvbColor FgColor,eDvbColor 
BgColor)
+{
+  int width = progressBar->Width();
+  int height = progressBar->Height();
+
+  progressBar->Fill(0,0,width,height,BgColor);
+  for (int i = 0; i < width; i++) {
+    progressBar->SetPixel(i,4,FgColor);
+    progressBar->SetPixel(i,5,FgColor);
+    progressBar->SetPixel(i,6,FgColor);
+
+    progressBar->SetPixel(i,height - 7,FgColor);
+    progressBar->SetPixel(i,height - 6,FgColor);
+    progressBar->SetPixel(i,height - 5,FgColor);
+  }
+  for (int i = 7; i < height-8; i++) {
+    progressBar->SetPixel(0,i,FgColor);
+    progressBar->SetPixel(1,i,FgColor);
+    progressBar->SetPixel(2,i,FgColor);
+
+    progressBar->SetPixel(width - 3,i,FgColor);
+    progressBar->SetPixel(width - 2,i,FgColor);
+    progressBar->SetPixel(width - 1,i,FgColor);
+  }
+
+  progressBar->Fill(3,7,(int)(percent*(width-4)), height - 8,FgColor);
+}
+
+cMenuWhatsOnItem::cMenuWhatsOnItem(const cEventInfo *EventInfo, bool 
ShowProgressBar)
 {
   eventInfo = EventInfo;
   char *buffer = NULL;
   cChannel *channel = Channels.GetByNumber(eventInfo->GetChannelNumber());
-  asprintf(&buffer, "%d\t%.*s\t%.*s\t%s", 
eventInfo->GetChannelNumber(), 6, channel ? channel->name : "???", 5, 
eventInfo->GetTimeString(), eventInfo->GetTitle());
+  if (ShowProgressBar) {
+    asprintf(&buffer, "%d\t%.*s\t%.*s\t", 
eventInfo->GetChannelNumber(), 6, channel ? channel->name : "???", 5, 
eventInfo->GetTimeString());
+    progressBar = new cBitmap(60,27,2);
+    //percent = eventInfo->GetChannelNumber()/100.0; //to test all 
percentages...
+    percent = (float)(time(NULL) - eventInfo->GetTime()) / 
(float)(eventInfo->GetDuration());
+    if (percent < 0) percent = 0;
+    if (percent > 1.0) percent = 1.0;
+  } else {
+    asprintf(&buffer, "%d\t%.*s\t%.*s\t%s", 
eventInfo->GetChannelNumber(), 6, channel ? channel->name : "???", 5, 
eventInfo->GetTimeString(), eventInfo->GetTitle());
+  }
   SetText(buffer, false);
+  this->showProgressBar = ShowProgressBar;
+}
+
+void cMenuWhatsOnItem::Display(int Offset, eDvbColor FgColor, eDvbColor 
BgColor)
+{
+  cOsdItem::Display(Offset,FgColor,BgColor);
+  if (showProgressBar) {
+    DrawProgressBar(userColor ? fgColor : FgColor, userColor ? bgColor: 
BgColor);
+    Interface->SetBitmap(198,(offset+2)*27,*progressBar);
+    Interface->WriteText(22, offset+2, eventInfo->GetTitle(),userColor 
? fgColor : FgColor, userColor ? bgColor : BgColor);
+  }
 }
 
+
 // --- cMenuWhatsOn 
----------------------------------------------------------
 
 class cMenuWhatsOn : public cOsdMenu {
@@ -1435,7 +1497,7 @@
   qsort(pArray, num, sizeof(cEventInfo *), CompareEventChannel);
 
   for (int a = 0; a < num; a++)
-      Add(new cMenuWhatsOnItem(pArray[a]), 
pArray[a]->GetChannelNumber() == CurrentChannelNr);
+      Add(new cMenuWhatsOnItem(pArray[a],Now), 
pArray[a]->GetChannelNumber() == CurrentChannelNr);
 
   currentChannel = CurrentChannelNr;
   delete pArray;
diff -u vdr-1.0.0pre4/osd.h myvdr41/osd.h
--- vdr-1.0.0pre4/osd.h    Sun Mar 10 17:18:11 2002
+++ myvdr41/osd.h    Sat Mar 23 17:01:31 2002
@@ -48,9 +48,9 @@
 class cOsdItem : public cListObject {
 private:
   const char *text;
-  int offset;
   eOSState state;
 protected:
+  int offset;
   bool fresh;
   bool userColor;
   eDvbColor fgColor, bgColor;
----------------------------------- end patch 
--------------------------------------




Home | Main Index | Thread Index