From d824878602251674a0557490a33444ed0f678357 Mon Sep 17 00:00:00 2001 From: Dimitar Tsenev Date: Wed, 15 Nov 2023 16:22:15 +0200 Subject: [PATCH 1/2] [Updated] several UI elements to handle properly ofsets and events --- lib/gui/elistboxcontent.cpp | 7 +- lib/python/Components/Addons/Pager.py | 51 +++++++++++---- lib/python/Components/Converter/EventName.py | 16 ++++- lib/python/Components/EpgList.py | 18 ++++-- lib/python/Components/MovieList.py | 68 +++++++++++--------- lib/python/Components/TimerList.py | 39 ++++++++--- lib/python/Screens/TimerEdit.py | 2 +- 7 files changed, 140 insertions(+), 61 deletions(-) diff --git a/lib/gui/elistboxcontent.cpp b/lib/gui/elistboxcontent.cpp index 3911734d33e..4e96e7c04ce 100644 --- a/lib/gui/elistboxcontent.cpp +++ b/lib/gui/elistboxcontent.cpp @@ -287,13 +287,15 @@ void eListboxPythonStringContent::paint(gPainter &painter, eWindowStyle &style, { const char *string = PyUnicode_Check(item) ? PyUnicode_AsUTF8(item) : ""; ePoint text_offset = offset; + ePoint style_text_offset = ePoint(0, 0); if (gray) painter.setForegroundColor(gRGB(0x808080)); int flags = 0; if (local_style) { - text_offset += local_style->m_text_offset; + style_text_offset = local_style->m_text_offset; + text_offset += style_text_offset; if (local_style->m_valign == eListboxStyle::alignTop) flags |= gPainter::RT_VALIGN_TOP; @@ -312,7 +314,8 @@ void eListboxPythonStringContent::paint(gPainter &painter, eWindowStyle &style, flags |= gPainter::RT_HALIGN_BLOCK; } - painter.renderText(eRect(text_offset, m_itemsize), string, flags, border_color, border_size); + // Here we have to compensate the local style text offset from both sides + painter.renderText(eRect(text_offset.x(), text_offset.y(), m_itemsize.width() - style_text_offset.x()*2, m_itemsize.height() - style_text_offset.y()*2), string, flags, border_color, border_size); } } diff --git a/lib/python/Components/Addons/Pager.py b/lib/python/Components/Addons/Pager.py index cbdcb1269ed..e30c22cc4cc 100644 --- a/lib/python/Components/Addons/Pager.py +++ b/lib/python/Components/Addons/Pager.py @@ -1,10 +1,11 @@ from Components.Addons.GUIAddon import GUIAddon -from enigma import eListbox, eListboxPythonMultiContent, BT_ALIGN_CENTER, eSize +from enigma import eListbox, eListboxPythonMultiContent, BT_ALIGN_CENTER, BT_VALIGN_CENTER -from skin import parseScale +from skin import parseScale, applySkinFactor from Components.MultiContent import MultiContentEntryPixmapAlphaBlend +from Components.Sources.List import List from Tools.Directories import resolveFilename, SCOPE_GUISKIN from Tools.LoadPixmap import LoadPixmap @@ -13,13 +14,16 @@ class Pager(GUIAddon): def __init__(self): GUIAddon.__init__(self) - self.l = eListboxPythonMultiContent() + self.l = eListboxPythonMultiContent() # noqa: E741 self.l.setBuildFunc(self.buildEntry) - self.l.setItemHeight(25) - self.spacing = 5 + self.l.setItemHeight(25) # 25 is the height of the default images. For other images set the height in the skin. + self.l.setItemWidth(25) # 25 is the width of the default images. For other images set the width in the skin. + self.spacing = applySkinFactor(5) self.picDotPage = LoadPixmap(resolveFilename(SCOPE_GUISKIN, "icons/dot.png")) self.picDotCurPage = LoadPixmap(resolveFilename(SCOPE_GUISKIN, "icons/dotfull.png")) - self.showIcons = "showAll" # can be "showAll", "onlyFirst", "onlyLast" + self.showIcons = "showAll" # can be "showAll", "onlyFirst", "onlyLast" + self.orientations = {"orHorizontal": eListbox.orHorizontal, "orVertical": eListbox.orVertical} + self.orientation = eListbox.orHorizontal def onContainerShown(self): # disable listboxes default scrollbars @@ -34,14 +38,18 @@ def onContainerShown(self): def buildEntry(self, currentPage, pageCount): width = self.l.getItemSize().width() + height = self.l.getItemSize().height() xPos = width + yPos = height if self.picDotPage: pixd_size = self.picDotPage.size() pixd_width = pixd_size.width() pixd_height = pixd_size.height() width_dots = pixd_width + (pixd_width + self.spacing) * pageCount + height_dots = pixd_height + (pixd_height + self.spacing) * pageCount xPos = (width - width_dots) / 2 - pixd_width / 2 if self.showIcons == "showAll" else 0 + yPos = (height - height_dots) / 2 - pixd_height / 2 if self.showIcons == "showAll" else 0 res = [None] if pageCount > (0 if self.showIcons == "showAll" else -1): pages = list(range(pageCount + 1)) @@ -52,12 +60,23 @@ def buildEntry(self, currentPage, pageCount): pages = [pages[-1]] for x in pages: if self.picDotPage and self.picDotCurPage: - res.append(MultiContentEntryPixmapAlphaBlend( + if self.orientation == eListbox.orHorizontal: + res.append( + MultiContentEntryPixmapAlphaBlend( pos=(xPos, 0), size=(pixd_width, pixd_height), png=self.picDotCurPage if x == currentPage else self.picDotPage, backcolor=None, backcolor_sel=None, flags=BT_ALIGN_CENTER)) - xPos += pixd_width + self.spacing + xPos += pixd_width + self.spacing + else: + res.append( + MultiContentEntryPixmapAlphaBlend( + pos=(0, yPos), + size=(pixd_width, pixd_height), + png=self.picDotCurPage if x == currentPage else self.picDotPage, + backcolor=None, backcolor_sel=None, flags=BT_ALIGN_CENTER | BT_VALIGN_CENTER)) + yPos += pixd_height + self.spacing + return res def selChange(self, currentPage, pagesCount): @@ -71,7 +90,7 @@ def postWidgetCreate(self, instance): instance.allowNativeKeys(False) def getSourceOrientation(self): - if self.source.__class__.__name__ == "List": # Components.Sources.List, used by MainMenu + if isinstance(self.source, List): # Components.Sources.List orig_source = self.source.master.master else: orig_source = self.source @@ -85,7 +104,7 @@ def getCurrentIndex(self): return self.source.l.getCurrentSelectionIndex() def getSourceSize(self): - if self.source.__class__.__name__ == "List": # Components.Sources.List, used by MainMenu + if isinstance(self.source, List): # Components.Sources.List return self.source.master.master.instance.size() return self.source.instance.size() @@ -97,7 +116,7 @@ def getListCount(self): return 0 def getListItemSize(self): - if self.source.__class__.__name__ == "List": # Components.Sources.List, used by MainMenu + if isinstance(self.source, List): # Components.Sources.List orig_source = self.source.master.master else: orig_source = self.source @@ -146,10 +165,20 @@ def applySkin(self, desktop, parent): self.picDotCurPage = pic elif attrib == "itemHeight": self.l.setItemHeight(parseScale(value)) + elif attrib == "itemWidth": + self.l.setItemWidth(parseScale(value)) elif attrib == "spacing": self.spacing = parseScale(value) elif attrib == "showIcons": self.showIcons = value + elif attrib == "orientation": + self.orientation = self.orientations.get(value, self.orientations["orHorizontal"]) + if self.orientation == eListbox.orHorizontal: + self.instance.setOrientation(eListbox.orVertical) + self.l.setOrientation(eListbox.orVertical) + else: + self.instance.setOrientation(eListbox.orHorizontal) + self.l.setOrientation(eListbox.orHorizontal) else: attribs.append((attrib, value)) self.skinAttributes = attribs diff --git a/lib/python/Components/Converter/EventName.py b/lib/python/Components/Converter/EventName.py index acc0dc7f385..4d808ac38e8 100644 --- a/lib/python/Components/Converter/EventName.py +++ b/lib/python/Components/Converter/EventName.py @@ -64,6 +64,8 @@ def getBoolean(self): event = self.source.event if event is None: return False + if self.type == self.NAME: + return bool(self.getText()) if self.type == self.PDC: if event.getPdcPil(): return True @@ -173,7 +175,19 @@ def getText(self): duration_str = "%d min" % (duration / 60) start_time_str = "%2d:%02d" % (t_start.tm_hour, t_start.tm_min) end_time_str = "%2d:%02d" % (t_end.tm_hour, t_end.tm_min) - res_str = "%s - %s %s %s" % (start_time_str, end_time_str, self.separator, duration_str) + name = event.getEventName() + res_str = "" + for x in self.parts[1:]: + if x == "NAME" and name: + res_str = self.appendToStringWithSeparator(res_str, name) + if x == "STARTTIME" and start_time_str: + res_str = self.appendToStringWithSeparator(res_str, start_time_str) + if x == "ENDTIME" and end_time_str: + res_str = self.appendToStringWithSeparator(res_str, end_time_str) + if x == "TIMERANGE" and start_time_str and end_time_str: + res_str = self.appendToStringWithSeparator(res_str, "%s - %s" % (start_time_str, end_time_str)) + if x == "DURATION" and duration_str: + res_str = self.appendToStringWithSeparator(res_str, duration_str) return res_str text = property(getText) diff --git a/lib/python/Components/EpgList.py b/lib/python/Components/EpgList.py index 22103cba806..06e4788c570 100644 --- a/lib/python/Components/EpgList.py +++ b/lib/python/Components/EpgList.py @@ -57,6 +57,7 @@ def __init__(self, type=EPG_TYPE_SINGLE, selChangedCB=None, timer=None): self.skinColumns = False self.tw = applySkinFactor(90) self.dy = 0 + self.sidesMargin = 0 if type == EPG_TYPE_SINGLE: self.l.setBuildFunc(self.buildSingleEntry) @@ -218,15 +219,19 @@ def buildSingleEntry(self, service, eventId, beginTime, duration, EventName): t = localtime(beginTime) res = [ None, # no private data needed - (eListboxPythonMultiContent.TYPE_TEXT, r1.x, r1.y, r1.w, r1.h, 0, RT_HALIGN_RIGHT | RT_VALIGN_CENTER, self.days[t[6]]), - (eListboxPythonMultiContent.TYPE_TEXT, r2.x, r2.y, r2.w, r1.h, 0, RT_HALIGN_RIGHT | RT_VALIGN_CENTER, "%02d.%02d, %02d:%02d" % (t[2], t[1], t[3], t[4])) + (eListboxPythonMultiContent.TYPE_TEXT, r1.x + self.sidesMargin, r1.y, r1.w, r1.h, 0, RT_HALIGN_RIGHT | RT_VALIGN_CENTER, self.days[t[6]]), + (eListboxPythonMultiContent.TYPE_TEXT, r2.x + self.sidesMargin, r2.y, r2.w, r1.h, 0, RT_HALIGN_RIGHT | RT_VALIGN_CENTER, "%02d.%02d, %02d:%02d" % (t[2], t[1], t[3], t[4])) ] if clock_types: for i in range(len(clock_types)): - res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHABLEND, r3.x + i * self.space, r3.y + self.dy, self.iconSize, self.iconSize, self.clocks[clock_types[i]])) - res.append((eListboxPythonMultiContent.TYPE_TEXT, r3.x + (i + 1) * self.space, r3.y, r3.w, r3.h, 0, RT_HALIGN_LEFT | RT_VALIGN_CENTER, EventName)) + clockIcon = self.clocks[clock_types[i]] + pix_size = clockIcon.size() + pix_width = pix_size.width() + pix_height = pix_size.height() + res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHABLEND, r3.x + self.sidesMargin + i * self.space, r3.y + self.dy, pix_width, pix_height, clockIcon)) + res.append((eListboxPythonMultiContent.TYPE_TEXT, r3.x + self.sidesMargin + (i + 1) * self.space, r3.y, r3.w, r3.h, 0, RT_HALIGN_LEFT | RT_VALIGN_CENTER, EventName)) else: - res.append((eListboxPythonMultiContent.TYPE_TEXT, r3.x, r3.y, r3.w, r3.h, 0, RT_HALIGN_LEFT | RT_VALIGN_CENTER, EventName)) + res.append((eListboxPythonMultiContent.TYPE_TEXT, r3.x + self.sidesMargin, r3.y, r3.w, r3.h, 0, RT_HALIGN_LEFT | RT_VALIGN_CENTER, EventName)) return res def buildSimilarEntry(self, service, eventId, beginTime, service_name, duration): @@ -412,6 +417,9 @@ def setColWidths(value): else: warningWrongSkinParameter(attrib) + def sidesMargin(value): + self.sidesMargin = parseScale(value) + def setColGap(value): self.colGap = parseScale(value) diff --git a/lib/python/Components/MovieList.py b/lib/python/Components/MovieList.py index 1dbc0a3e4a6..7e83df7d565 100644 --- a/lib/python/Components/MovieList.py +++ b/lib/python/Components/MovieList.py @@ -175,6 +175,7 @@ def __init__(self, root, list_type=None, sort_type=None, descr_state=None): self.partIconeShiftCompact = 4 self.partIconeShiftOriginal = 5 self.spaceRight = 2 + self.spaceLeft= 2 self.spaceIconeText = 2 self.iconsWidth = 22 self.trashShift = 1 @@ -338,6 +339,9 @@ def columnsCompactDescription(value): def compactColumn(value): self.compactColumn = parseScale(value) + def spaceLeft(value): + self.spaceLeft = parseScale(value) + def treeDescription(value): self.treeDescription = parseScale(value) for (attrib, value) in self.skinAttributes[:]: @@ -397,15 +401,15 @@ def buildMovieListEntry(self, serviceref, info, begin, data): p = os.path.split(p[0]) txt = p[1] if txt == ".Trash": - res.append(MultiContentEntryPixmapAlphaBlend(pos=(0, self.trashShift), size=(iconSize, self.iconTrash.size().height()), png=self.iconTrash)) - res.append(MultiContentEntryText(pos=(x, 0), size=(width - x - tn - r, self.itemHeight), font=0, flags=RT_HALIGN_LEFT | valign_center, text=_("Deleted items"))) - res.append(MultiContentEntryText(pos=(width - tn - r, 0), size=(tn, self.itemHeight), font=1, flags=RT_HALIGN_RIGHT | valign_center, text=_("Trash can"))) + res.append(MultiContentEntryPixmapAlphaBlend(pos=(self.spaceLeft, self.trashShift), size=(iconSize, self.iconTrash.size().height()), png=self.iconTrash)) + res.append(MultiContentEntryText(pos=(x + self.spaceLeft, 0), size=(width - x - tn - r - self.spaceLeft, self.itemHeight), font=0, flags=RT_HALIGN_LEFT | valign_center, text=_("Deleted items"))) + res.append(MultiContentEntryText(pos=(width - tn - r, 0), size=(tn - self.spaceLeft, self.itemHeight), font=1, flags=RT_HALIGN_RIGHT | valign_center, text=_("Trash can"))) return res if not config.movielist.show_underlines.value: txt = txt.replace('_', ' ').strip() - res.append(MultiContentEntryPixmapAlphaBlend(pos=(0, self.dirShift), size=(iconSize, iconSize), png=self.iconFolder)) - res.append(MultiContentEntryText(pos=(x, 0), size=(width - x - tn - r, self.itemHeight), font=0, flags=RT_HALIGN_LEFT | valign_center, text=txt)) - res.append(MultiContentEntryText(pos=(width - tn - r, 0), size=(tn, self.itemHeight), font=1, flags=RT_HALIGN_RIGHT | valign_center, text=_("Directory"))) + res.append(MultiContentEntryPixmapAlphaBlend(pos=(self.spaceLeft, self.dirShift), size=(iconSize, iconSize), png=self.iconFolder)) + res.append(MultiContentEntryText(pos=(x + self.spaceLeft, 0), size=(width - x - tn - r - self.spaceLeft, self.itemHeight), font=0, flags=RT_HALIGN_LEFT | valign_center, text=txt)) + res.append(MultiContentEntryText(pos=(width - tn - r, 0), size=(tn - self.spaceLeft, self.itemHeight), font=1, flags=RT_HALIGN_RIGHT | valign_center, text=_("Directory"))) return res if (data == -1) or (data is None): data = MovieListData() @@ -466,18 +470,18 @@ def buildMovieListEntry(self, serviceref, info, begin, data): if data.icon is not None: if self.list_type in (MovieList.LISTTYPE_COMPACT_DESCRIPTION, MovieList.LISTTYPE_COMPACT): - pos = (0, self.partIconeShiftCompact) + pos = (self.spaceLeft, self.partIconeShiftCompact) elif self.list_type == MovieList.LISTTYPE_ORIGINAL: - pos = (0, self.partIconeShiftOriginal) + pos = (self.spaceLeft, self.partIconeShiftOriginal) else: - pos = (0, self.partIconeShiftMinimal) + pos = (self.spaceLeft, self.partIconeShiftMinimal) res.append(MultiContentEntryPixmapAlphaBlend(pos=pos, size=(iconSize, data.icon.size().height()), png=data.icon)) switch = config.usage.show_icons_in_movielist.value if switch in ('p', 's'): if switch == 'p': iconSize = self.pbarLargeWidth if data.part is not None: - res.append(MultiContentEntryProgress(pos=(0, self.pbarShift), size=(iconSize, self.pbarHeight), percent=data.part, borderWidth=2, foreColor=data.partcol, foreColorSelected=None, backColor=None, backColorSelected=None)) + res.append(MultiContentEntryProgress(pos=(self.spaceLeft, self.pbarShift), size=(iconSize, self.pbarHeight), percent=data.part, borderWidth=2, foreColor=data.partcol, foreColorSelected=None, backColor=None, backColorSelected=None)) elif switch == 'i': pass else: @@ -492,18 +496,18 @@ def buildMovieListEntry(self, serviceref, info, begin, data): fc, sc = self.columnsOriginal[0], self.columnsOriginal[1] ih1 = (ih * 2) // 5 # 75 -> 30 ih2 = (ih * 2) // 3 # 75 -> 50 - res.append(MultiContentEntryText(pos=(iconSize + space, 0), size=(width - fc - r, ih1), font=0, flags=RT_HALIGN_LEFT, text=data.txt)) + res.append(MultiContentEntryText(pos=(iconSize + space + self.spaceLeft, 0), size=(width - fc - r - self.spaceLeft, ih1), font=0, flags=RT_HALIGN_LEFT, text=data.txt)) if self.tags: - res.append(MultiContentEntryText(pos=(width - fc - r, 0), size=(fc, ih1), font=2, flags=RT_HALIGN_RIGHT, text=info.getInfoString(serviceref, iServiceInformation.sTags))) + res.append(MultiContentEntryText(pos=(width - fc - r - self.spaceLeft, 0), size=(fc - self.spaceLeft, ih1), font=2, flags=RT_HALIGN_RIGHT, text=info.getInfoString(serviceref, iServiceInformation.sTags))) if data.serviceName: - res.append(MultiContentEntryText(pos=(sc - r, ih2), size=(sc, ih2 - ih1), font=1, flags=RT_HALIGN_LEFT, text=data.serviceName)) + res.append(MultiContentEntryText(pos=(sc - r - self.spaceLeft, ih2), size=(sc - self.spaceLeft, ih2 - ih1), font=1, flags=RT_HALIGN_LEFT, text=data.serviceName)) else: if data.serviceName: - res.append(MultiContentEntryText(pos=(width - fc - r, 0), size=(fc, ih1), font=2, flags=RT_HALIGN_RIGHT, text=data.serviceName)) - res.append(MultiContentEntryText(pos=(0, ih1), size=(width - r, ih2 - ih1), font=1, flags=RT_HALIGN_LEFT, text=data.description)) - res.append(MultiContentEntryText(pos=(0, ih2), size=(sc - r, ih - ih2), font=1, flags=RT_HALIGN_LEFT, text=begin_string)) + res.append(MultiContentEntryText(pos=(width - fc - r - self.spaceLeft, 0), size=(fc - self.spaceLeft, ih1), font=2, flags=RT_HALIGN_RIGHT, text=data.serviceName)) + res.append(MultiContentEntryText(pos=(self.spaceLeft, ih1), size=(width - r - self.spaceLeft, ih2 - ih1), font=1, flags=RT_HALIGN_LEFT, text=data.description)) + res.append(MultiContentEntryText(pos=(self.spaceLeft, ih2), size=(sc - r - self.spaceLeft, ih - ih2), font=1, flags=RT_HALIGN_LEFT, text=begin_string)) if len: - res.append(MultiContentEntryText(pos=(width - sc - r, ih2), size=(sc, ih - ih2), font=1, flags=RT_HALIGN_RIGHT, text=len)) + res.append(MultiContentEntryText(pos=(width - sc - r - self.spaceLeft, ih2), size=(sc - self.spaceLeft, ih - ih2), font=1, flags=RT_HALIGN_RIGHT, text=len)) elif self.list_type == MovieList.LISTTYPE_COMPACT_DESCRIPTION: ih1 = ((ih * 8) + 14) // 15 # 37 -> 20, round up if len: @@ -511,13 +515,13 @@ def buildMovieListEntry(self, serviceref, info, begin, data): else: lenSize = 0 fc, sc, tc = self.columnsCompactDescription[0], self.columnsCompactDescription[1], self.columnsCompactDescription[2] - res.append(MultiContentEntryText(pos=(iconSize + space, 0), size=(width - sc - r, ih1), font=0, flags=RT_HALIGN_LEFT, text=data.txt)) - res.append(MultiContentEntryText(pos=(0, ih1), size=(width - tc - lenSize - r, ih - ih1), font=1, flags=RT_HALIGN_LEFT, text=data.description)) - res.append(MultiContentEntryText(pos=(width - fc - r, 6), size=(fc, ih1), font=1, flags=RT_HALIGN_RIGHT, text=begin_string)) + res.append(MultiContentEntryText(pos=(iconSize + space + self.spaceLeft, 0), size=(width - sc - r - self.spaceLeft, ih1), font=0, flags=RT_HALIGN_LEFT, text=data.txt)) + res.append(MultiContentEntryText(pos=(self.spaceLeft, ih1), size=(width - tc - lenSize - r - self.spaceLeft, ih - ih1), font=1, flags=RT_HALIGN_LEFT, text=data.description)) + res.append(MultiContentEntryText(pos=(width - fc - r - self.spaceLeft, 6), size=(fc, ih1), font=1, flags=RT_HALIGN_RIGHT, text=begin_string)) if data.serviceName: - res.append(MultiContentEntryText(pos=(width - tc - lenSize - r, ih1), size=(tc, ih - ih1), font=1, flags=RT_HALIGN_RIGHT, text=data.serviceName)) + res.append(MultiContentEntryText(pos=(width - tc - lenSize - r - self.spaceLeft, ih1), size=(tc - self.spaceLeft, ih - ih1), font=1, flags=RT_HALIGN_RIGHT, text=data.serviceName)) if lenSize: - res.append(MultiContentEntryText(pos=(width - lenSize - r, ih1), size=(lenSize, ih - ih1), font=1, flags=RT_HALIGN_RIGHT, text=len)) + res.append(MultiContentEntryText(pos=(width - lenSize - r - self.spaceLeft, ih1), size=(lenSize - self.spaceLeft, ih - ih1), font=1, flags=RT_HALIGN_RIGHT, text=len)) elif self.list_type == MovieList.LISTTYPE_COMPACT: col = self.compactColumn ih1 = ((ih * 8) + 14) // 15 # 37 -> 20, round up @@ -525,26 +529,26 @@ def buildMovieListEntry(self, serviceref, info, begin, data): lenSize = 2 * ih else: lenSize = 0 - res.append(MultiContentEntryText(pos=(iconSize + space, 0), size=(width - lenSize - iconSize - space - r, ih1), font=0, flags=RT_HALIGN_LEFT, text=data.txt)) + res.append(MultiContentEntryText(pos=(iconSize + space + self.spaceLeft, 0), size=(width - lenSize - iconSize - space - r - self.spaceLeft, ih1), font=0, flags=RT_HALIGN_LEFT, text=data.txt)) if self.tags: - res.append(MultiContentEntryText(pos=(width - col - r, ih1), size=(col, ih - ih1), font=1, flags=RT_HALIGN_RIGHT, text=info.getInfoString(serviceref, iServiceInformation.sTags))) + res.append(MultiContentEntryText(pos=(width - col - r - self.spaceLeft, ih1), size=(col - self.spaceLeft, ih - ih1), font=1, flags=RT_HALIGN_RIGHT, text=info.getInfoString(serviceref, iServiceInformation.sTags))) if data.serviceName: - res.append(MultiContentEntryText(pos=(col, ih1), size=(col, ih - ih1), font=1, flags=RT_HALIGN_LEFT, text=data.serviceName)) + res.append(MultiContentEntryText(pos=(col + self.spaceLeft, ih1), size=(col - self.spaceLeft, ih - ih1), font=1, flags=RT_HALIGN_LEFT, text=data.serviceName)) else: if data.serviceName: - res.append(MultiContentEntryText(pos=(width - col - r, ih1), size=(col, ih - ih1), font=1, flags=RT_HALIGN_RIGHT, text=data.serviceName)) - res.append(MultiContentEntryText(pos=(0, ih1), size=(col, ih - ih1), font=1, flags=RT_HALIGN_LEFT, text=begin_string)) + res.append(MultiContentEntryText(pos=(width - col - r - self.spaceLeft, ih1), size=(col - self.spaceLeft, ih - ih1), font=1, flags=RT_HALIGN_RIGHT, text=data.serviceName)) + res.append(MultiContentEntryText(pos=(self.spaceLeft, ih1), size=(col - self.spaceLeft, ih - ih1), font=1, flags=RT_HALIGN_LEFT, text=begin_string)) if lenSize: - res.append(MultiContentEntryText(pos=(width - lenSize - r, 0), size=(lenSize, ih1), font=0, flags=RT_HALIGN_RIGHT, text=len)) + res.append(MultiContentEntryText(pos=(width - lenSize - r - self.spaceLeft, 0), size=(lenSize - self.spaceLeft, ih1), font=0, flags=RT_HALIGN_RIGHT, text=len)) else: if (self.descr_state == MovieList.SHOW_DESCRIPTION) or not len: dateSize = ih * 145 // 25 # 25 -> 145 - res.append(MultiContentEntryText(pos=(iconSize + space, 0), size=(width - iconSize - space - dateSize - r, ih), font=0, flags=RT_HALIGN_LEFT | RT_VALIGN_CENTER, text=data.txt)) - res.append(MultiContentEntryText(pos=(width - dateSize - r, 2), size=(dateSize, ih), font=1, flags=RT_HALIGN_RIGHT | RT_VALIGN_CENTER, text=begin_string)) + res.append(MultiContentEntryText(pos=(iconSize + space + self.spaceLeft, 0), size=(width - iconSize - space - dateSize - r - self.spaceLeft, ih), font=0, flags=RT_HALIGN_LEFT | RT_VALIGN_CENTER, text=data.txt)) + res.append(MultiContentEntryText(pos=(width - dateSize - r - self.spaceLeft, 2), size=(dateSize - self.spaceLeft, ih), font=1, flags=RT_HALIGN_RIGHT | RT_VALIGN_CENTER, text=begin_string)) else: lenSize = ih * 3 # 25 -> 75 - res.append(MultiContentEntryText(pos=(iconSize + space, 0), size=(width - lenSize - iconSize - space - r, ih), font=0, flags=RT_HALIGN_LEFT, text=data.txt)) - res.append(MultiContentEntryText(pos=(width - lenSize - r, 0), size=(lenSize, ih), font=0, flags=RT_HALIGN_RIGHT, text=len)) + res.append(MultiContentEntryText(pos=(iconSize + space + self.spaceLeft, 0), size=(width - lenSize - iconSize - space - r - self.spaceLeft, ih), font=0, flags=RT_HALIGN_LEFT, text=data.txt)) + res.append(MultiContentEntryText(pos=(width - lenSize - r - self.spaceLeft, 0), size=(lenSize - self.spaceLeft, ih), font=0, flags=RT_HALIGN_RIGHT, text=len)) return res def moveToFirstMovie(self): diff --git a/lib/python/Components/TimerList.py b/lib/python/Components/TimerList.py index c5d839db7db..7fb3c1f4af4 100644 --- a/lib/python/Components/TimerList.py +++ b/lib/python/Components/TimerList.py @@ -26,10 +26,10 @@ def buildTimerEntry(self, timer, processed): serviceNameWidth = width - 200 - self.iconWidth - self.iconMargin if timer.external: - res.append((eListboxPythonMultiContent.TYPE_TEXT, width - serviceNameWidth - self.iconMargin, 0, serviceNameWidth, self.rowSplit, 0, RT_HALIGN_RIGHT | RT_VALIGN_BOTTOM, serviceName, self.backupColor, self.backupColorSel, None, None, None, None)) + res.append((eListboxPythonMultiContent.TYPE_TEXT, width - serviceNameWidth - self.iconMargin - self.sidesMargin, 0, serviceNameWidth, self.rowSplit, 0, RT_HALIGN_RIGHT | RT_VALIGN_BOTTOM, serviceName, self.backupColor, self.backupColorSel, None, None, None, None)) else: - res.append((eListboxPythonMultiContent.TYPE_TEXT, width - serviceNameWidth - self.iconMargin, 0, serviceNameWidth, self.rowSplit, 0, RT_HALIGN_RIGHT | RT_VALIGN_BOTTOM, serviceName)) - res.append((eListboxPythonMultiContent.TYPE_TEXT, self.iconWidth + self.iconMargin, 0, width - serviceNameWidth - self.iconWidth - self.iconMargin * 2, self.rowSplit, 2, RT_HALIGN_LEFT | RT_VALIGN_BOTTOM, timer.name)) + res.append((eListboxPythonMultiContent.TYPE_TEXT, width - serviceNameWidth - self.iconMargin - self.sidesMargin, 0, serviceNameWidth, self.rowSplit, 0, RT_HALIGN_RIGHT | RT_VALIGN_BOTTOM, serviceName)) + res.append((eListboxPythonMultiContent.TYPE_TEXT, self.iconWidth + self.iconMargin + self.sidesMargin, 0, width - serviceNameWidth - self.iconWidth - self.iconMargin * 2 - self.sidesMargin * 2, self.rowSplit, 2, RT_HALIGN_LEFT | RT_VALIGN_BOTTOM, timer.name)) begin = FuzzyTime(timer.begin) if timer.repeated: @@ -42,11 +42,11 @@ def buildTimerEntry(self, timer, processed): flags >>= 1 repeatedtext = ", ".join(repeatedtext) if self.iconRepeat: - res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHABLEND, self.iconMargin // 2, self.rowSplit + (self.itemHeight - self.rowSplit - self.iconHeight) // 2, self.iconWidth, self.iconHeight, self.iconRepeat)) + res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHABLEND, (self.iconMargin // 2) + self.sidesMargin, self.rowSplit + (self.itemHeight - self.rowSplit - self.iconHeight) // 2, self.iconWidth, self.iconHeight, self.iconRepeat)) else: repeatedtext = begin[0] # date if "autotimer" in timer.flags: - self.iconAutoTimer and res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHABLEND, self.iconMargin // 2, self.rowSplit + (self.itemHeight - self.rowSplit - self.iconHeight) // 2, self.iconWidth, self.iconHeight, self.iconAutoTimer)) + self.iconAutoTimer and res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHABLEND, (self.iconMargin // 2) + self.sidesMargin, self.rowSplit + (self.itemHeight - self.rowSplit - self.iconHeight) // 2, self.iconWidth, self.iconHeight, self.iconAutoTimer)) if timer.justplay: if timer.pipzap: extra_text = _("(ZAP as PiP)") @@ -83,26 +83,29 @@ def buildTimerEntry(self, timer, processed): state = _("done!") icon = self.iconDone - icon and res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHABLEND, self.iconMargin // 2, (self.rowSplit - self.iconHeight) // 2, self.iconWidth, self.iconHeight, icon)) + icon and res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHABLEND, (self.iconMargin // 2) + self.sidesMargin, (self.rowSplit - self.iconHeight) // 2, self.iconWidth, self.iconHeight, icon)) orbpos = self.getOrbitalPos(timer.service_ref, timer.state, hasattr(timer, "record_service") and timer.record_service or None) orbposWidth = getTextBoundarySize(self.instance, self.font, self.l.getItemSize(), orbpos).width() - res.append((eListboxPythonMultiContent.TYPE_TEXT, self.satPosLeft, self.rowSplit, orbposWidth, self.itemHeight - self.rowSplit, 1, RT_HALIGN_LEFT | RT_VALIGN_TOP, orbpos)) - res.append((eListboxPythonMultiContent.TYPE_TEXT, self.iconWidth + self.iconMargin, self.rowSplit, self.satPosLeft - self.iconWidth - self.iconMargin, self.itemHeight - self.rowSplit, 1, RT_HALIGN_LEFT | RT_VALIGN_TOP, state)) - res.append((eListboxPythonMultiContent.TYPE_TEXT, self.satPosLeft + orbposWidth, self.rowSplit, width - self.satPosLeft - orbposWidth - self.iconMargin, self.itemHeight - self.rowSplit, 1, RT_HALIGN_RIGHT | RT_VALIGN_TOP, text)) + res.append((eListboxPythonMultiContent.TYPE_TEXT, self.satPosLeft + self.sidesMargin, self.rowSplit, orbposWidth, self.itemHeight - self.rowSplit, 1, RT_HALIGN_LEFT | RT_VALIGN_TOP, orbpos)) + res.append((eListboxPythonMultiContent.TYPE_TEXT, self.iconWidth + self.iconMargin + self.sidesMargin, self.rowSplit, self.satPosLeft - self.iconWidth - self.iconMargin - self.sidesMargin * 2, self.itemHeight - self.rowSplit, 1, RT_HALIGN_LEFT | RT_VALIGN_TOP, state)) + res.append((eListboxPythonMultiContent.TYPE_TEXT, self.satPosLeft + orbposWidth + self.sidesMargin, self.rowSplit, width - self.satPosLeft - orbposWidth - self.iconMargin - self.sidesMargin * 2, self.itemHeight - self.rowSplit, 1, RT_HALIGN_RIGHT | RT_VALIGN_TOP, text)) return res def __init__(self, list): GUIComponent.__init__(self) + self.onSelectionChanged = [] self.l = eListboxPythonMultiContent() self.l.setBuildFunc(self.buildTimerEntry) self.serviceNameFont = gFont("Regular", 20) self.font = gFont("Regular", 18) self.eventNameFont = gFont("Regular", 18) self.l.setList(list) + self.listCount = len(list) # used by pager self.itemHeight = 50 self.rowSplit = 25 self.iconMargin = 4 self.satPosLeft = 160 + self.sidesMargin = 0 self.backupColor = self.backupColorSel = 0x00CCAC68 self.iconWait = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "icons/timer_wait.png")) #currently intended that all icons have the same size @@ -143,6 +146,10 @@ def backupColor(value): def backupColorSel(value): self.backupColorSel = int(value) + + def sidesMargin(value): + self.sidesMargin = parseScale(value) + for (attrib, value) in list(self.skinAttributes): try: locals().get(attrib)(value) @@ -161,11 +168,25 @@ def getCurrent(self): GUI_WIDGET = eListbox + def setList(self, list): + self.l.setList(list) + self.listCount = len(list) # used by pager + self.selectionChanged() + def postWidgetCreate(self, instance): + instance.selectionChanged.get().append(self.selectionChanged) instance.setContent(self.l) self.instance = instance instance.setWrapAround(True) + def preWidgetRemove(self, instance): + instance.selectionChanged.get().remove(self.selectionChanged) + instance.setContent(None) + + def selectionChanged(self): + for x in self.onSelectionChanged: + x() + def moveToIndex(self, index): self.instance.moveSelectionTo(index) diff --git a/lib/python/Screens/TimerEdit.py b/lib/python/Screens/TimerEdit.py index 13f0f4e9bd6..f927a178354 100644 --- a/lib/python/Screens/TimerEdit.py +++ b/lib/python/Screens/TimerEdit.py @@ -260,7 +260,7 @@ def eol_compare(x, y): self.list.sort(key=functools.cmp_to_key(eol_compare)) else: self.list.sort(key=lambda x: x[0].begin) - self["timerlist"].l.setList(self.list) + self["timerlist"].setList(self.list) self.updateState() def showLog(self): From 0cce136d6745a1556bb7ff177c2abbb2e04d80d5 Mon Sep 17 00:00:00 2001 From: Dimitar Tsenev Date: Thu, 16 Nov 2023 08:41:16 +0200 Subject: [PATCH 2/2] - changed pager to prevents too may pages display --- lib/python/Components/Addons/Pager.py | 69 ++++++++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-) diff --git a/lib/python/Components/Addons/Pager.py b/lib/python/Components/Addons/Pager.py index e30c22cc4cc..898625e45d8 100644 --- a/lib/python/Components/Addons/Pager.py +++ b/lib/python/Components/Addons/Pager.py @@ -21,9 +21,14 @@ def __init__(self): self.spacing = applySkinFactor(5) self.picDotPage = LoadPixmap(resolveFilename(SCOPE_GUISKIN, "icons/dot.png")) self.picDotCurPage = LoadPixmap(resolveFilename(SCOPE_GUISKIN, "icons/dotfull.png")) + self.picShevronLeft = LoadPixmap(resolveFilename(SCOPE_GUISKIN, "icons/shevronleft.png")) + self.picShevronRight = LoadPixmap(resolveFilename(SCOPE_GUISKIN, "icons/shevronright.png")) + self.picShevronUp = LoadPixmap(resolveFilename(SCOPE_GUISKIN, "icons/shevronup.png")) + self.picShevronDown = LoadPixmap(resolveFilename(SCOPE_GUISKIN, "icons/shevrondown.png")) self.showIcons = "showAll" # can be "showAll", "onlyFirst", "onlyLast" self.orientations = {"orHorizontal": eListbox.orHorizontal, "orVertical": eListbox.orVertical} self.orientation = eListbox.orHorizontal + self.max_pages = 10 def onContainerShown(self): # disable listboxes default scrollbars @@ -51,7 +56,51 @@ def buildEntry(self, currentPage, pageCount): xPos = (width - width_dots) / 2 - pixd_width / 2 if self.showIcons == "showAll" else 0 yPos = (height - height_dots) / 2 - pixd_height / 2 if self.showIcons == "showAll" else 0 res = [None] - if pageCount > (0 if self.showIcons == "showAll" else -1): + if self.max_pages > 0 and pageCount > self.max_pages and pageCount > 0: + width_dots = pixd_width + (pixd_width + self.spacing) * (2 if currentPage > 0 and currentPage < pageCount else 1) + xPos = (width - width_dots) / 2 - pixd_width / 2 + yPos = (height - height_dots) / 2 - pixd_height / 2 + if self.orientation == eListbox.orHorizontal: + if currentPage > 0: + res.append(MultiContentEntryPixmapAlphaBlend( + pos=(xPos, 0), + size=(pixd_width, pixd_height), + png=self.picShevronLeft, + backcolor=None, backcolor_sel=None, flags=BT_ALIGN_CENTER)) + xPos += pixd_width + self.spacing + res.append(MultiContentEntryPixmapAlphaBlend( + pos=(xPos, 0), + size=(pixd_width, pixd_height), + png=self.picDotCurPage, + backcolor=None, backcolor_sel=None, flags=BT_ALIGN_CENTER)) + xPos += pixd_width + self.spacing + if currentPage < pageCount: + res.append(MultiContentEntryPixmapAlphaBlend( + pos=(xPos, 0), + size=(pixd_width, pixd_height), + png=self.picShevronRight, + backcolor=None, backcolor_sel=None, flags=BT_ALIGN_CENTER)) + else: + if currentPage > 0: + res.append(MultiContentEntryPixmapAlphaBlend( + pos=(0, yPos), + size=(pixd_width, pixd_height), + png=self.picShevronLeft, + backcolor=None, backcolor_sel=None, flags=BT_ALIGN_CENTER)) + yPos += pixd_height + self.spacing + res.append(MultiContentEntryPixmapAlphaBlend( + pos=(0, yPos), + size=(pixd_width, pixd_height), + png=self.picDotCurPage, + backcolor=None, backcolor_sel=None, flags=BT_ALIGN_CENTER)) + yPos += pixd_height + self.spacing + if currentPage < pageCount: + res.append(MultiContentEntryPixmapAlphaBlend( + pos=(0, yPos), + size=(pixd_width, pixd_height), + png=self.picShevronRight, + backcolor=None, backcolor_sel=None, flags=BT_ALIGN_CENTER)) + elif pageCount > (0 if self.showIcons == "showAll" else -1): pages = list(range(pageCount + 1)) # add option to show just first or last icon if self.showIcons == "onlyFirst": @@ -163,6 +212,22 @@ def applySkin(self, desktop, parent): pic = LoadPixmap(resolveFilename(SCOPE_GUISKIN, value)) if pic: self.picDotCurPage = pic + elif attrib == "picL": + pic = LoadPixmap(resolveFilename(SCOPE_GUISKIN, value)) + if pic: + self.picShevronLeft = pic + elif attrib == "picR": + pic = LoadPixmap(resolveFilename(SCOPE_GUISKIN, value)) + if pic: + self.picShevronRight = pic + elif attrib == "picU": + pic = LoadPixmap(resolveFilename(SCOPE_GUISKIN, value)) + if pic: + self.picShevronUp = pic + elif attrib == "picD": + pic = LoadPixmap(resolveFilename(SCOPE_GUISKIN, value)) + if pic: + self.picShevronDown = pic elif attrib == "itemHeight": self.l.setItemHeight(parseScale(value)) elif attrib == "itemWidth": @@ -171,6 +236,8 @@ def applySkin(self, desktop, parent): self.spacing = parseScale(value) elif attrib == "showIcons": self.showIcons = value + elif attrib == "maxPages": + self.max_pages = value elif attrib == "orientation": self.orientation = self.orientations.get(value, self.orientations["orHorizontal"]) if self.orientation == eListbox.orHorizontal: