Skip to content

Commit

Permalink
[Addons] sync with latest (#4068)
Browse files Browse the repository at this point in the history
  • Loading branch information
Huevos committed Sep 20, 2024
1 parent 59da9fe commit e960a13
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 49 deletions.
45 changes: 41 additions & 4 deletions doc/AUTOMATICBUTTONS
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ in the screens correctly as if we had added them manually to every single screen
alignment="left"
zPosition="2"
spacing="10"
spacingPixmapText="10" />
spacingPixmapText="10"
buttonCornerRadius="6" />

Attributes:
connection: comma separated list of the buttons this widget will control.
pixmaps: comma separated list that contains "key_name" then a ":" then the path to the graphic to be used.
spacing: is the spacing between the text and the next button.
spacingPixmapText: is the spacing between the graphic and the text.
buttonCornerRadius (optional): add rounding to corners.

By default the foreground text color will be the same as the default listbox text color. But this can be altered for each
button with the "textColors" attribute.
Expand All @@ -52,7 +54,8 @@ Example widget with colored text:
alignment="left"
zPosition="2"
spacing="10"
spacingPixmapText="10" />
spacingPixmapText="10"
buttonCornerRadius="6" />

It is also possible to have colored text and no graphics:

Expand All @@ -67,7 +70,41 @@ It is also possible to have colored text and no graphics:
transparent="1"
alignment="left"
zPosition="2"
spacing="10" />
spacing="10"
buttonCornerRadius="6" />

Superimpose text over the graphic rather that have the graphic to the side of the text.

<widget
addon="ColorButtonsSequence"
connection="key_red,key_green,key_yellow,key_blue"
pixmaps="key_red:buttons/key_red.png,key_green:buttons/key_green.png,key_yellow:buttons/key_yellow.png,key_blue:buttons/key_blue.png"
position="0,0"
size="e,36"
font="Regular;26"
backgroundColor="background5"
alignment="left"
zPosition="10"
spacing="40"
spacingPixmapText="10"
buttonCornerRadius="6"
renderType="ImageTextOver" />

Superimpose texted over a coloured background (no graphic).

<widget addon="ColorButtonsSequence"
connection="key_red,key_green,key_yellow,key_blue"
textColors="key_red:red,key_green:green,key_yellow:yellow,key_blue:blue"
position="0,0"
size="e,36"
font="Regular;26"
backgroundColor="background5"
alignment="left"
zPosition="10"
spacing="40"
spacingPixmapText="10"
buttonCornerRadius="6"
renderType="ColorTextOver" />

=========================================================================================================================================================================

Expand All @@ -85,7 +122,7 @@ It is also possible to have colored text and no graphics:
Attributes:
connection: comma separated list of the buttons this widget will control.
pixmaps: comma separated list that contains "key_name" then a ":" then the path to the graphic to be used.
spacing: is the spacing between the text and the next button.
spacing: is the spacing between buttons.

In "connection" and "pixmap" add the buttons you want this widget to display.

Expand Down
53 changes: 44 additions & 9 deletions lib/python/Components/Addons/ColorButtonsSequence.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from Components.Addons.GUIAddon import GUIAddon

from enigma import eListbox, eListboxPythonMultiContent, BT_ALIGN_CENTER, RT_VALIGN_CENTER, RT_HALIGN_LEFT, eSize, getDesktop, gFont
from enigma import eListbox, eListboxPythonMultiContent, BT_ALIGN_CENTER, RT_VALIGN_CENTER, RT_HALIGN_LEFT, RT_HALIGN_CENTER, BT_SCALE, eSize, getDesktop, gFont

from skin import parseScale, parseColor, parseFont, applySkinFactor

from Components.MultiContent import MultiContentEntryPixmapAlphaBlend
from Components.MultiContent import MultiContentEntryPixmapAlphaBlend, MultiContentEntryText
from Components.Label import Label

from Tools.Directories import resolveFilename, SCOPE_GUISKIN
Expand All @@ -26,7 +26,9 @@ def __init__(self):
self.colorIndicatorStyle = "pixmap"
self.orientations = {"orHorizontal": eListbox.orHorizontal, "orVertical": eListbox.orVertical}
self.orientation = eListbox.orHorizontal
self.renderType = "ImageTextRight" # Currently supported are ImageTextRight, ImageTextOver and ColorTextOver
self.alignment = "left"
self.cornerRadius = 0
self.pixmaps = {}
self.colors = {}
self.textRenderer = Label("")
Expand Down Expand Up @@ -62,9 +64,15 @@ def buildEntry(self, sequence):

for x, val in sequence.items():
textColor = self.foreColor
buttonBgColor = self.foreColor

if x in self.colors:
textColor = parseColor(self.colors[x]).argb()
if x in self.pixmaps:
if self.renderType == "ImageTextRight":
textColor = parseColor(self.colors[x]).argb()
else:
buttonBgColor = parseColor(self.colors[x]).argb()

if self.renderType != "ImageTextOver" and x in self.pixmaps:
pic = LoadPixmap(resolveFilename(SCOPE_GUISKIN, self.pixmaps[x]))
if pic:
pixd_size = pic.size()
Expand Down Expand Up @@ -92,11 +100,34 @@ def buildEntry(self, sequence):
if textWidth < (minSectorWidth - self.spacingButtons - (self.spacingPixmapText if pic else 0) - pixd_width):
textWidth = minSectorWidth - self.spacingButtons - (self.spacingPixmapText if pic else 0) - pixd_width
if buttonText:
if textColor is not None:
res.append((eListboxPythonMultiContent.TYPE_TEXT, xPos, yPos, textWidth, height - 2, 0, RT_HALIGN_LEFT | RT_VALIGN_CENTER, buttonText, textColor))
textFlags = RT_HALIGN_LEFT | RT_VALIGN_CENTER
textPaddings = 0
backColor = None
if self.renderType in ["ColorTextOver", "ImageTextOver"]:
textFlags = RT_HALIGN_CENTER | RT_VALIGN_CENTER
textPaddings = self.spacingPixmapText
backColor = buttonBgColor

if self.renderType == "ImageTextOver":
if x in self.pixmaps:
pic = LoadPixmap(resolveFilename(SCOPE_GUISKIN, self.pixmaps[x]))
if pic:
res.append(MultiContentEntryPixmapAlphaBlend(
pos=(xPos, yPos),
size=(textWidth + textPaddings * 2, height),
png=pic,
backcolor=0x000000, backcolor_sel=None, flags=BT_SCALE, corner_radius=self.cornerRadius))
res.append(MultiContentEntryText(
pos=(xPos + textPaddings, yPos), size=(textWidth, height - 2),
font=0, flags=textFlags,
text=buttonText, color=textColor, color_sel=textColor))
else:
res.append((eListboxPythonMultiContent.TYPE_TEXT, xPos, yPos, textWidth, height - 2, 0, RT_HALIGN_LEFT | RT_VALIGN_CENTER, buttonText))
xPos += textWidth + self.spacingButtons
res.append(MultiContentEntryText(
pos=(xPos, yPos), size=(textWidth + textPaddings * 2, height - 2),
font=0, flags=textFlags,
text=buttonText, color=textColor, color_sel=textColor, backcolor=backColor, corner_radius=self.cornerRadius))

xPos += textWidth + textPaddings * 2 + self.spacingButtons
if xPos > width and self.layoutStyle != "fluid":
self.layoutStyle = "fluid"
return self.buildEntry(sequence)
Expand Down Expand Up @@ -138,11 +169,15 @@ def applySkin(self, desktop, parent):
self.instance.setOrientation(eListbox.orHorizontal)
self.l.setOrientation(eListbox.orHorizontal)
elif attrib == "font":
self.font = parseFont(value, ((1, 1), (1, 1)))
self.font = parseFont(value, parent.scale)
elif attrib == "foregroundColor":
self.foreColor = parseColor(value).argb()
elif attrib == "textColors":
self.colors = dict(item.split(':') for item in value.split(','))
elif attrib == "buttonCornerRadius":
self.cornerRadius = parseScale(value)
elif attrib == "renderType":
self.renderType = value
else:
attribs.append((attrib, value))
self.skinAttributes = attribs
Expand Down
20 changes: 7 additions & 13 deletions lib/python/Components/Addons/MainMenu.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,17 @@ def __init__(self):
self.longestMenuTextWidth = 0
self.minWidth = 100
self.maxWidth = 700


def onContainerShown(self):
self.textRenderer.GUIcreate(self.relatedScreen.instance)
self.source.onListUpdated.append(self.constructMenu)
self.constructMenu()

GUI_WIDGET = eListbox



def getDesktopWith(self):
return getDesktop(0).size().width()

def _calcTextWidth(self, text, font=None, size=None):
if size:
self.textRenderer.instance.resize(size)
Expand Down Expand Up @@ -80,20 +78,16 @@ def moveSelection(self, index):
def selectionChanged(self):
if self.instance and hasattr(self, "source"):
self.source.setConnectedGuiElement(self)

def setFont(self, value):
self.font = parseFont(value, ((1, 1), (1, 1)))
self.l.setFont(0, self.font)

def setMinWidth(self, value):
self.minWidth = parseScale(value)

def setMaxWidth(self, value):
self.maxWidth = parseScale(value)

def setIconSize(self, value):
self.iconSize = parseScale(value)

def setForegroundColor(self, value):
self.foregroundColor = parseColor(value).argb()

Expand Down Expand Up @@ -123,8 +117,8 @@ def constructMenu(self):
if textWidth > self.longestMenuTextWidth:
self.longestMenuTextWidth = textWidth
curSize = self.instance.size()
dest_width = self.iconSize + 20*2 + 10
dest_width += self.longestMenuTextWidth
dest_width = self.iconSize + 20 * 2 + 10
dest_width += self.longestMenuTextWidth
if dest_width > self.maxWidth:
dest_width = self.maxWidth
if dest_width > self.minWidth:
Expand All @@ -136,7 +130,7 @@ def applySkin(self, desktop, parent):
attribs = []
for (attrib, value) in self.skinAttributes[:]:
if attrib == "font":
self.font = parseFont(value, ((1, 1), (1, 1)))
self.font = parseFont(value, parent.scale)
elif attrib == "foregroundColor":
self.foregroundColor = parseColor(value).argb()
elif attrib == "foregroundColorSelected":
Expand Down
4 changes: 2 additions & 2 deletions lib/python/Components/Addons/Pager.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def onContainerShown(self):

if isinstance(onSelectionChanged, list) and self.initPager not in onSelectionChanged:
onSelectionChanged.append(self.initPager)

self.initPager()

GUI_WIDGET = eListbox
Expand Down Expand Up @@ -251,7 +251,7 @@ def applySkin(self, desktop, parent):
elif attrib == "showIcons":
self.showIcons = value
elif attrib == "maxPages":
self.max_pages = parseScale(value)
self.max_pages = int(value)
elif attrib == "orientation":
self.orientation = self.orientations.get(value, self.orientations["orHorizontal"])
if self.orientation == eListbox.orHorizontal:
Expand Down
19 changes: 9 additions & 10 deletions lib/python/Components/Addons/ScreenHeader.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from Components.Pixmap import Pixmap



class ScreenHeader(GUIAddon):
def __init__(self):
GUIAddon.__init__(self)
Expand Down Expand Up @@ -47,19 +46,19 @@ def buildEntry(self, sequence):
textItemsOffset = -1

res = [None]

for idx, x in enumerate(sequence):
if isinstance(x, StaticText):
textItemsCount += 1
if textItemsOffset == -1:
textItemsOffset = idx

isOneItem = textItemsCount == 1

itemHeight = self.instance.size().height()

for idx, x in enumerate(sequence):
if not isinstance(x, StaticText): # assume it is Pixmap
if not isinstance(x, StaticText): # assume it is Pixmap
if x.pixmap:
itemHeight = self.instance.size().height()
pix_size = x.pixmap.size()
Expand All @@ -81,7 +80,7 @@ def buildEntry(self, sequence):
elif idx == 1 + textItemsOffset:
yPos = self.instance.size().height() * 2 // 3 - 5
itemHeight = self.instance.size().height() // 3

fontIndex = 2 if isOneItem and idx == textItemsOffset else idx - textItemsOffset

res.append(MultiContentEntryText(
Expand Down Expand Up @@ -114,11 +113,11 @@ def applySkin(self, desktop, parent):
attribs = []
for (attrib, value) in self.skinAttributes[:]:
if attrib == "titleFont":
self.titleFont = parseFont(value, ((1, 1), (1, 1)))
self.titleFont = parseFont(value, parent.scale)
if attrib == "titleSingleFont":
self.titleSingleFont = parseFont(value, ((1, 1), (1, 1)))
self.titleSingleFont = parseFont(value, parent.scale)
elif attrib == "pathFont":
self.pathFont = parseFont(value, ((1, 1), (1, 1)))
self.pathFont = parseFont(value, parent.scale)
elif attrib == "titleForegroundColor":
self.titleForeground = parseColor(value).argb()
elif attrib == "pathForegroundColor":
Expand Down
21 changes: 10 additions & 11 deletions lib/python/Components/Addons/ServiceInfoBar.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
from Components.Addons.GUIAddon import GUIAddon

from enigma import eListbox, eListboxPythonMultiContent, BT_ALIGN_CENTER, iPlayableService, iRecordableService, eServiceReference, iServiceInformation, gFont, RT_HALIGN_LEFT, RT_VALIGN_CENTER, RT_VALIGN_TOP, RT_HALIGN_CENTER, eTimer, getDesktop, eSize, eStreamServer
from skin import parseScale, applySkinFactor, parseColor, parseFont, parameters

from Components.MultiContent import MultiContentEntryPixmapAlphaBlend, MultiContentEntryText
from Components.ServiceEventTracker import ServiceEventTracker
from Components.Addons.GUIAddon import GUIAddon
from Components.Converter.PliExtraInfo import createCurrentCaidLabel
from Components.Converter.ServiceInfo import getVideoHeight
from Components.Converter.VAudioInfo import StdAudioDesc
from Components.Converter.PliExtraInfo import createCurrentCaidLabel
from Components.Label import Label
from Components.MultiContent import MultiContentEntryPixmapAlphaBlend, MultiContentEntryText
from Components.ServiceEventTracker import ServiceEventTracker
from Components.Sources.StreamService import StreamServiceList
from Components.NimManager import nimmanager
from Components.config import config
from Screens.InfoBarGenerics import hasActiveSubservicesForCurrentChannel
from Tools.Directories import resolveFilename, SCOPE_GUISKIN
from Tools.LoadPixmap import LoadPixmap
Expand Down Expand Up @@ -106,8 +104,9 @@ def gotRecordEvent(self, service, event):
self.updateAddon()

def scheduleAddonUpdate(self):
self.refreshAddon.stop()
self.refreshAddon.start(350)
if hasattr(self, "refreshAddon"):
self.refreshAddon.stop()
self.refreshAddon.start(300)

def checkCrypto_update(self):
if NavigationInstance.instance is not None:
Expand Down Expand Up @@ -145,11 +144,11 @@ def detectVisible(self, key):
service = self.nav.getCurrentService()
info = service and service.info()
isRef = isinstance(service, eServiceReference)
#self.current_info = info
# self.current_info = info
if not info:
return None
video_height = None
video_aspect = None
# video_aspect = None
video_height = getVideoHeight(info)
if key == "videoRes":
if video_height >= 720 and video_height < 1500:
Expand Down Expand Up @@ -348,7 +347,7 @@ def applySkin(self, desktop, parent):
elif attrib == "autoresizeMode":
self.autoresizeMode = value
elif attrib == "font":
self.font = parseFont(value, ((1, 1), (1, 1)))
self.font = parseFont(value, parent.scale)
elif attrib == "foregroundColor":
self.foreColor = parseColor(value).argb()
elif attrib == "textBackColor":
Expand Down

0 comments on commit e960a13

Please sign in to comment.