From: Felix Domke Date: Sun, 28 Aug 2005 22:46:00 +0000 (+0000) Subject: - start on 'favourites' visual design. service listbox now configurable (in complex... X-Git-Tag: 2.6.0~5720 X-Git-Url: https://git.cweiske.de/enigma2.git/commitdiff_plain/1f5b1a20e4de369c197de1dae8fcb368e3e10b26 - start on 'favourites' visual design. service listbox now configurable (in complex mode) --- diff --git a/keymap.xml b/keymap.xml index 225cee86..ec26ccaf 100644 --- a/keymap.xml +++ b/keymap.xml @@ -10,6 +10,8 @@ + + @@ -66,9 +68,10 @@ - + + diff --git a/lib/python/Components/ServiceList.py b/lib/python/Components/ServiceList.py index 5725871d..4c553d9d 100644 --- a/lib/python/Components/ServiceList.py +++ b/lib/python/Components/ServiceList.py @@ -4,6 +4,10 @@ from GUIComponent import * from enigma import * class ServiceList(HTMLComponent, GUIComponent): + + MODE_NORMAL = 0 + MODE_FAVOURITES = 1 + def __init__(self): GUIComponent.__init__(self) self.l = eListboxServiceContent() @@ -55,3 +59,17 @@ class ServiceList(HTMLComponent, GUIComponent): ref = eServiceReference() return marked + + def setMode(self, mode): + if mode == self.MODE_NORMAL: + self.instance.setItemHeight(20) + self.l.setVisualMode(eListboxServiceContent.visModeSimple) + else: + self.instance.setItemHeight(40) + + self.l.setElementFont(self.l.celServiceName, gFont("Arial", 30)) + self.l.setElementPosition(self.l.celServiceName, eRect(40, 0, self.instance.size().width(), 40)) + self.l.setElementFont(self.l.celServiceNumber, gFont("Arial", 20)) + self.l.setElementPosition(self.l.celServiceNumber, eRect(0, 10, 40, 30)) + + self.l.setVisualMode(eListboxServiceContent.visModeComplex) diff --git a/lib/python/Screens/ChannelSelection.py b/lib/python/Screens/ChannelSelection.py index 465d3de3..3155c44d 100644 --- a/lib/python/Screens/ChannelSelection.py +++ b/lib/python/Screens/ChannelSelection.py @@ -69,7 +69,9 @@ class ChannelSelection(Screen): def action(self, contexts, action): if action[:7] == "bouquet": print "setting root to " + action[8:] - self.csel["list"].setRoot(eServiceReference("1:0:1:0:0:0:0:0:0:0:" + action[8:])) + l = self.csel["list"] + l.setMode(l.MODE_NORMAL) + l.setRoot(eServiceReference("1:0:1:0:0:0:0:0:0:0:" + action[8:])) else: ActionMap.action(self, contexts, action) @@ -78,7 +80,8 @@ class ChannelSelection(Screen): "cancel": self.close, "ok": self.channelSelected, "mark": self.doMark, - "contextMenu": self.doContext + "contextMenu": self.doContext, + "showFavourites": self.showFavourites }) self["actions"].csel = self @@ -119,6 +122,7 @@ class ChannelSelection(Screen): # ... def channelSelected(self): self.session.nav.playService(self["list"].getCurrent()) + print "current: " + self["list"].getCurrent().toString() self.close() #called from infoBar @@ -137,3 +141,7 @@ class ChannelSelection(Screen): def setMoveMode(self, mode): self.movemode = mode + def showFavourites(self): + l = self["list" ] + l.setRoot(eServiceReference('1:0:1:0:0:0:0:0:0:0:(provider == "fav")')) + l.setMode(l.MODE_FAVOURITES) diff --git a/lib/python/Screens/InfoBar.py b/lib/python/Screens/InfoBar.py index 6f8dde1b..0ead7221 100644 --- a/lib/python/Screens/InfoBar.py +++ b/lib/python/Screens/InfoBar.py @@ -6,6 +6,7 @@ from Components.ActionMap import ActionMap from Components.Button import Button from Components.ServiceName import ServiceName from Components.EventInfo import EventInfo +from Components.ServicePosition import ServicePosition from Screens.MessageBox import MessageBox from Screens.MovieSelection import MovieSelection @@ -43,7 +44,8 @@ class InfoBar(Screen): }) # self["okbutton"] = Button("mainMenu", [self.mainMenu]) - self["CurrentTime"] = Clock() + self["CurrentTime"] = ServicePosition(self.session.nav, ServicePosition.TYPE_REMAINING) + # Clock() self["Volume"] = self.volumeBar diff --git a/lib/service/listboxservice.cpp b/lib/service/listboxservice.cpp index 24090f73..07838722 100644 --- a/lib/service/listboxservice.cpp +++ b/lib/service/listboxservice.cpp @@ -80,10 +80,39 @@ int eListboxServiceContent::lookupService(const eServiceReference &ref) return index; } +void eListboxServiceContent::setVisualMode(int mode) +{ + m_visual_mode = mode; + + if (m_visual_mode == visModeSimple) + { + m_element_position[celServiceName] = eRect(ePoint(0, 0), m_itemsize); + m_element_font[celServiceName] = new gFont("Arial", 14); + 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; + } +} + +void eListboxServiceContent::setElementPosition(int element, eRect where) +{ + if ((element >= 0) && (element < celElements)) + m_element_position[element] = where; +} + +void eListboxServiceContent::setElementFont(int element, gFont *font) +{ + if ((element >= 0) && (element < celElements)) + m_element_font[element] = font; +} + DEFINE_REF(eListboxServiceContent); eListboxServiceContent::eListboxServiceContent() { + m_visual_mode = visModeSimple; m_size = 0; cursorHome(); eServiceCenter::getInstance(m_service_center); @@ -162,11 +191,11 @@ int eListboxServiceContent::size() void eListboxServiceContent::setSize(const eSize &size) { m_itemsize = size; + setVisualMode(m_visual_mode); } void eListboxServiceContent::paint(gPainter &painter, eWindowStyle &style, const ePoint &offset, int selected) { - ePtr fnt = new gFont("Arial", 14); painter.clip(eRect(offset, m_itemsize)); if (cursorValid() && isMarked(*m_cursor)) style.setStyle(painter, eWindowStyle::styleListboxMarked); @@ -176,19 +205,47 @@ void eListboxServiceContent::paint(gPainter &painter, eWindowStyle &style, const if (cursorValid()) { - painter.setFont(fnt); - - ePoint text_offset = offset + (selected ? ePoint(2, 2) : ePoint(1, 1)); - - /* get name of service */ + /* get service information */ ePtr service_info; m_service_center->info(*m_cursor, service_info); - std::string name = ""; - - if (service_info) - service_info->getName(*m_cursor, name); - painter.renderText(eRect(text_offset, m_itemsize), name); + for (int e = 0; e < celElements; ++e) + { + if (!m_element_font[e]) + continue; + painter.setFont(m_element_font[e]); + + std::string text = ""; + + switch (e) + { + case celServiceName: + { + if (service_info) + service_info->getName(*m_cursor, text); + break; + } + case celServiceNumber: + { + char bla[10]; + sprintf(bla, "%d", m_cursor_number + 1); + text = bla; + break; + } + case celServiceInfo: + { + text = "now&next"; + break; + } + case celIcon: + continue; + } + + eRect area = m_element_position[e]; + area.moveBy(offset.x(), offset.y()); + + painter.renderText(area, text); + } if (selected) style.drawFrame(painter, eRect(offset, m_itemsize), eWindowStyle::frameListboxEntry); diff --git a/lib/service/listboxservice.h b/lib/service/listboxservice.h index 36bb5bb4..f32e0865 100644 --- a/lib/service/listboxservice.h +++ b/lib/service/listboxservice.h @@ -27,6 +27,25 @@ public: int lookupService(const eServiceReference &ref); + enum { + visModeSimple, + visModeComplex + }; + + void setVisualMode(int mode); + + /* only in complex mode: */ + enum { + celServiceName, + celServiceNumber, + celIcon, + celServiceInfo, // "now" event + celElements + }; + + void setElementPosition(int element, eRect where); + void setElementFont(int element, gFont *font); + protected: void cursorHome(); void cursorEnd(); @@ -44,6 +63,11 @@ protected: /* the following functions always refer to the selected item */ void paint(gPainter &painter, eWindowStyle &style, const ePoint &offset, int selected); + + int m_visual_mode; + /* for complex mode */ + eRect m_element_position[celElements]; + ePtr m_element_font[celElements]; private: typedef std::list list; diff --git a/skin.py b/skin.py index 2c1778e4..7d24441d 100644 --- a/skin.py +++ b/skin.py @@ -97,7 +97,7 @@ dom = xml.dom.minidom.parseString( - +