add support for show small icons behind each channel in servicelist (used for type...
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>
Fri, 26 May 2006 22:50:00 +0000 (22:50 +0000)
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>
Fri, 26 May 2006 22:50:00 +0000 (22:50 +0000)
show folder icon in channellist

data/folder.png [new file with mode: 0644]
lib/python/Components/ServiceList.py
lib/service/listboxservice.cpp
lib/service/listboxservice.h

diff --git a/data/folder.png b/data/folder.png
new file mode 100644 (file)
index 0000000..7342726
Binary files /dev/null and b/data/folder.png differ
index 85f004c..8525ade 100644 (file)
@@ -5,6 +5,8 @@ from enigma import *
 
 from string import upper
 
 
 from string import upper
 
+from Tools.Directories import resolveFilename, SCOPE_SKIN, SCOPE_SKIN_IMAGE, SCOPE_FONTS
+
 class ServiceList(HTMLComponent, GUIComponent):
        MODE_NORMAL = 0
        MODE_FAVOURITES = 1
 class ServiceList(HTMLComponent, GUIComponent):
        MODE_NORMAL = 0
        MODE_FAVOURITES = 1
@@ -12,6 +14,23 @@ class ServiceList(HTMLComponent, GUIComponent):
        def __init__(self):
                GUIComponent.__init__(self)
                self.l = eListboxServiceContent()
        def __init__(self):
                GUIComponent.__init__(self)
                self.l = eListboxServiceContent()
+
+               pic = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "folder.png"))
+               if pic:
+                       self.l.setPixmap(self.l.picFolder, pic)
+
+               pic = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "ico_dvb_s-fs8.png"))
+               if pic:
+                       self.l.setPixmap(self.l.picDVB_S, pic)
+
+               pic = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "ico_dvb_c-fs8.png"))
+               if pic:
+                       self.l.setPixmap(self.l.picDVB_C, pic)
+
+               pic = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "ico_dvb_t-fs8.png"))
+               if pic:
+                       self.l.setPixmap(self.l.picDVB_T, pic)
+
                self.root = None
                self.mode = self.MODE_NORMAL
 
                self.root = None
                self.mode = self.MODE_NORMAL
 
index 89ef72e..0b7b730 100644 (file)
@@ -147,7 +147,6 @@ void eListboxServiceContent::setVisualMode(int mode)
                m_element_font[celServiceName] = new gFont("Regular", 23);
                m_element_position[celServiceNumber] = eRect();
                m_element_font[celServiceNumber] = 0;
                m_element_font[celServiceName] = new gFont("Regular", 23);
                m_element_position[celServiceNumber] = eRect();
                m_element_font[celServiceNumber] = 0;
-               m_element_position[celIcon] = eRect();
                m_element_position[celServiceInfo] = eRect();
                m_element_font[celServiceInfo] = 0;
        }
                m_element_position[celServiceInfo] = eRect();
                m_element_font[celServiceInfo] = 0;
        }
@@ -165,6 +164,12 @@ void eListboxServiceContent::setElementFont(int element, gFont *font)
                m_element_font[element] = font;
 }
 
                m_element_font[element] = font;
 }
 
+void eListboxServiceContent::setPixmap(int type, ePtr<gPixmap> &pic)
+{
+       if ((type >=0) && (type < picElements))
+               m_pixmaps[type] = pic;
+}
+
 void eListboxServiceContent::sort()
 {
        ePtr<iListableService> lst;
 void eListboxServiceContent::sort()
 {
        ePtr<iListableService> lst;
@@ -372,79 +377,118 @@ void eListboxServiceContent::paint(gPainter &painter, eWindowStyle &style, const
                if (m_is_playable_ignore.valid() && service_info && !service_info->isPlayable(*m_cursor, m_is_playable_ignore))
                        painter.setForegroundColor(gRGB(0xbbbbbb));
 
                if (m_is_playable_ignore.valid() && service_info && !service_info->isPlayable(*m_cursor, m_is_playable_ignore))
                        painter.setForegroundColor(gRGB(0xbbbbbb));
 
+               int xoffset=0;  // used as offset when painting the folder symbol
+
                for (int e = 0; e < celElements; ++e)
                {
                for (int e = 0; e < celElements; ++e)
                {
-                       if (!m_element_font[e])
-                               continue;
-                       int flags=gPainter::RT_VALIGN_CENTER;
+                       if (m_element_font[e])
+                       {
+                               int flags=gPainter::RT_VALIGN_CENTER,
+                                       yoffs = 0,
+                                       xoffs = xoffset;
+                               eRect &area = m_element_position[e];
+                               std::string text = "<n/a>";
+                               xoffset=0;
+
+                               switch (e)
+                               {
+                               case celServiceNumber:
+                               {
+                                       char bla[10];
+                                       sprintf(bla, "%d", m_numberoffset + m_cursor_number + 1);
+                                       text = bla;
+                                       flags|=gPainter::RT_HALIGN_RIGHT;
+                                       break;
+                               }
+                               case celServiceName:
+                               {
+                                       if (service_info)
+                                               service_info->getName(*m_cursor, text);
+                                       break;
+                               }
+                               case celServiceInfo:
+                               {
+                                       ePtr<eServiceEvent> evt;
+                                       if ( !service_info->getEvent(*m_cursor, evt) )
+                                       {
+                                               std::string name = evt->getEventName();
+                                               if (!name.length())
+                                                       continue;
+                                               text = '(' + evt->getEventName() + ')';
+                                       }
+                                       else
+                                               continue;
+                                       break;
+                               }
+                               }
 
 
-                       eRect area = m_element_position[e];
+                               eRect tmp = area;
+                               tmp.setWidth(tmp.width()-xoffs);
 
 
-                       std::string text = "<n/a>";
+                               eTextPara *para = new eTextPara(tmp);
+                               para->setFont(m_element_font[e]);
+                               para->renderString(text);
 
 
-                       switch (e)
-                       {
-                       case celIcon:
-                               // render icon here...
-                               continue;
-                       case celServiceNumber:
-                       {
-                               char bla[10];
-                               sprintf(bla, "%d", m_numberoffset + m_cursor_number + 1);
-                               text = bla;
-                               flags|=gPainter::RT_HALIGN_RIGHT;
-                               break;
-                       }
-                       case celServiceName:
-                       {
-                               if (service_info)
-                                       service_info->getName(*m_cursor, text);
-                               break;
-                       }
-                       case celServiceInfo:
-                       {
-                               ePtr<eServiceEvent> evt;
-                               if ( !service_info->getEvent(*m_cursor, evt) )
-                                       text = '(' + evt->getEventName() + ')';
-                               else
-                                       continue;
-                               break;
-                       }
-                       }
+                               if (e == celServiceName)
+                               {
+                                       eRect bbox = para->getBoundBox();
+                                       int name_width = bbox.width()+8;
+                                       m_element_position[celServiceInfo].setLeft(area.left()+name_width);
+                                       m_element_position[celServiceInfo].setTop(area.top());
+                                       m_element_position[celServiceInfo].setWidth(area.width()-name_width);
+                                       m_element_position[celServiceInfo].setHeight(area.height());
+                               }
 
 
-                       eTextPara *para = new eTextPara(area);
+                               if (flags & gPainter::RT_HALIGN_RIGHT)
+                                       para->realign(eTextPara::dirRight);
+                               else if (flags & gPainter::RT_HALIGN_CENTER)
+                                       para->realign(eTextPara::dirCenter);
+                               else if (flags & gPainter::RT_HALIGN_BLOCK)
+                                       para->realign(eTextPara::dirBlock);
 
 
-                       para->setFont(m_element_font[e]);
-                       para->renderString(text);
+                               if (flags & gPainter::RT_VALIGN_CENTER)
+                               {
+                                       eRect bbox = para->getBoundBox();
+                                       int vcentered_top = (area.height() - bbox.height()) / 2;
+                                       yoffs = vcentered_top - bbox.top();
+                               }
 
 
-                       if (e == celServiceName)
-                       {
-                               eRect bbox = para->getBoundBox();
-                               int name_width = bbox.width()+10;
-                               m_element_position[celServiceInfo].setLeft(area.left()+name_width);
-                               m_element_position[celServiceInfo].setTop(area.top());
-                               m_element_position[celServiceInfo].setWidth(area.width()-name_width);
-                               m_element_position[celServiceInfo].setHeight(area.height());
+                               painter.renderPara(para, offset+ePoint(xoffs, yoffs));
                        }
                        }
+                       else if (e == celServiceTypePixmap || e == celFolderPixmap)
+                       {
+                               int orbpos = m_cursor->getUnsignedData(4) >> 16;
+                               ePtr<gPixmap> &pixmap =
+                                       (e == celFolderPixmap) ? m_pixmaps[picFolder] :
+                                       (orbpos == 0xFFFF) ? m_pixmaps[picDVB_C] :
+                                       (orbpos == 0xEEEE) ? m_pixmaps[picDVB_T] : m_pixmaps[picDVB_S];
+                               if (pixmap)
+                               {
+                                       eSize pixmap_size = pixmap->size();
+                                       eRect area = m_element_position[e == celFolderPixmap ? celServiceName : celServiceInfo];
+                                       int correction = (area.height() - pixmap_size.height()) / 2;
 
 
-                       if (flags & gPainter::RT_HALIGN_RIGHT)
-                               para->realign(eTextPara::dirRight);
-                       else if (flags & gPainter::RT_HALIGN_CENTER)
-                               para->realign(eTextPara::dirCenter);
-                       else if (flags & gPainter::RT_HALIGN_BLOCK)
-                               para->realign(eTextPara::dirBlock);
-
-                       ePoint offs = offset;
+                                       if (m_cursor->flags & eServiceReference::flagDirectory)
+                                       {
+                                               if (e != celFolderPixmap)
+                                                       continue;
+                                               xoffset = pixmap_size.width() + 8;
+                                       }
+                                       else
+                                       {
+                                               if (e != celServiceTypePixmap)
+                                                       continue;
+                                               m_element_position[celServiceInfo] = area;
+                                               m_element_position[celServiceInfo].setLeft(area.left() + pixmap_size.width() + 8);
+                                               m_element_position[celServiceInfo].setWidth(area.width() - pixmap_size.width() - 8);
+                                       }
 
 
-                       if (flags & gPainter::RT_VALIGN_CENTER)
-                       {
-                               eRect bbox = para->getBoundBox();
-                               int vcentered_top = (area.height() - bbox.height()) / 2;
-                               int correction = vcentered_top - bbox.top();
-                               offs += ePoint(0, correction);
+                                       area.moveBy(offset);
+                                       painter.clip(area);
+                                       painter.blit(pixmap, offset+ePoint(area.left(), correction), area, gPainter::BT_ALPHATEST);
+                                       painter.clippop();
+                               }
                        }
                        }
-
-                       painter.renderPara(para, offs);
                }
                
                if (selected)
                }
                
                if (selected)
index 234cd39..d26ee54 100644 (file)
@@ -42,15 +42,25 @@ public:
        
                /* only in complex mode: */
        enum {
        
                /* only in complex mode: */
        enum {
-               celIcon,
                celServiceNumber,
                celServiceNumber,
+               celFolderPixmap,
                celServiceName,
                celServiceName,
+               celServiceTypePixmap,
                celServiceInfo, // "now" event
                celElements
        };
                celServiceInfo, // "now" event
                celElements
        };
-       
+
+       enum {
+               picDVB_S,
+               picDVB_T,
+               picDVB_C,
+               picFolder,
+               picElements
+       };
+
        void setElementPosition(int element, eRect where);
        void setElementFont(int element, gFont *font);
        void setElementPosition(int element, eRect where);
        void setElementFont(int element, gFont *font);
+       void setPixmap(int type, ePtr<gPixmap> &pic);
        
        void sort();
 
        
        void sort();
 
@@ -79,6 +89,7 @@ protected:
                /* for complex mode */
        eRect m_element_position[celElements];
        ePtr<gFont> m_element_font[celElements];
                /* for complex mode */
        eRect m_element_position[celElements];
        ePtr<gFont> m_element_font[celElements];
+       ePtr<gPixmap> m_pixmaps[picElements];
 private:
        typedef std::list<eServiceReference> list;
        
 private:
        typedef std::list<eServiceReference> list;