Skip to content

Commit

Permalink
Merge pull request #3835 from DimitarCC/ui-patches-1
Browse files Browse the repository at this point in the history
  • Loading branch information
littlesat authored Nov 16, 2023
2 parents 95e8949 + 0cce136 commit 03e3e22
Show file tree
Hide file tree
Showing 7 changed files with 208 additions and 62 deletions.
7 changes: 5 additions & 2 deletions lib/gui/elistboxcontent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,13 +287,15 @@ void eListboxPythonStringContent::paint(gPainter &painter, eWindowStyle &style,
{
const char *string = PyUnicode_Check(item) ? PyUnicode_AsUTF8(item) : "<not-a-string>";
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;
Expand All @@ -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);
}
}

Expand Down
120 changes: 108 additions & 12 deletions lib/python/Components/Addons/Pager.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -13,13 +14,21 @@
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.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
Expand All @@ -34,16 +43,64 @@ 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):
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":
Expand All @@ -52,12 +109,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):
Expand All @@ -71,7 +139,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
Expand All @@ -85,7 +153,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()

Expand All @@ -97,7 +165,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
Expand Down Expand Up @@ -144,12 +212,40 @@ 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":
self.l.setItemWidth(parseScale(value))
elif attrib == "spacing":
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:
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
Expand Down
16 changes: 15 additions & 1 deletion lib/python/Components/Converter/EventName.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
18 changes: 13 additions & 5 deletions lib/python/Components/EpgList.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -412,6 +417,9 @@ def setColWidths(value):
else:
warningWrongSkinParameter(attrib)

def sidesMargin(value):
self.sidesMargin = parseScale(value)

def setColGap(value):
self.colGap = parseScale(value)

Expand Down
Loading

0 comments on commit 03e3e22

Please sign in to comment.