Skip to content

Commit 26fa9d9

Browse files
committed
[plugin] scale the selector screen to the desktop resolution
The screen geometry was fixed at 900x560 with a 30px item height, sized for a 720p desktop. On FHD/WQHD skins the list font comes from the active skin and is correspondingly larger, so slot names got clipped on the right and fewer entries fit without scrolling. Move all coordinates into a skinGeometry dict holding the 720p reference values, turn the skin into a %(name)d template, and multiply everything by getDesktop(0).size().height() / 720.0 in __init__ before Screen.__init__ parses self.skin. setItemHeight() uses the scaled value too. getDesktop() is core enigma2 API rather than a skin-engine feature, so this works the same on images whose skin parser does not implement the resolution= screen attribute.
1 parent 612ef46 commit 26fa9d9

3 files changed

Lines changed: 31 additions & 14 deletions

File tree

‎CONTROL/control‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Package: enigma2-plugin-extensions-multibootselector
2-
Version: 1.19
2+
Version: 1.20
33
Description: Basic python frontend for multiboot-selector.sh to simply select the slot to boot from.
44
Architecture: all
55
Section: extra

‎src/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# -*- coding: utf-8 -*-
2-
PV = "1.19"
2+
PV = "1.20"
33
PN = "MultiBoot Selector"
44
PD = "Select a slot to boot from"

‎src/plugin.py‎

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
PLUGIN_LOAD = True if "MBSP_FORCE_LOAD" in environ else not BoxInfo.getItem("canMultiBoot")
2626
except (ImportError, AttributeError):
2727
PLUGIN_LOAD = True
28+
from enigma import getDesktop
2829
from Components.ActionMap import ActionMap
2930
from Components.Button import Button
3031
from Components.Label import Label
@@ -66,26 +67,42 @@ def main(session, **kwargs):
6667

6768

6869
class Scripts(Screen):
70+
# Geometry for a 720p desktop. Scaled at runtime in __init__ so the screen also fits FHD/WQHD skins,
71+
# where the skin's own list font is bigger and would otherwise clip the slot names.
72+
skinGeometry = {
73+
"w": 900, "h": 560,
74+
"pad": 10, "inner": 880,
75+
"hdrH": 40, "hdrFont": 22,
76+
"listY": 60, "listH": 415, "itemH": 30,
77+
"btnY": 510, "btnW": 210, "btnH": 40, "btnFont": 20,
78+
"btnX1": 10, "btnX2": 233, "btnX3": 456, "btnX4": 679,
79+
}
80+
6981
skin = """
70-
<screen position="center,center" size="900,560" title="MultiBoot Selector">
71-
<widget name="header" position="10,10" size="880,40" font="Regular;22" halign="center" valign="center" foregroundColor="#00e0ff" />
72-
<widget name="list" position="10,60" size="880,415" scrollbarMode="showOnDemand" />
82+
<screen position="center,center" size="%(w)d,%(h)d" title="MultiBoot Selector">
83+
<widget name="header" position="%(pad)d,%(pad)d" size="%(inner)d,%(hdrH)d" font="Regular;%(hdrFont)d" halign="center" valign="center" foregroundColor="#00e0ff" />
84+
<widget name="list" position="%(pad)d,%(listY)d" size="%(inner)d,%(listH)d" scrollbarMode="showOnDemand" />
7385
74-
<widget name="key_red_pixmap" pixmap="skin_default/buttons/red.png" position="10,510" size="210,40" scale="stretch" alphatest="on" />
75-
<widget name="key_red" position="10,510" size="210,40" font="Regular;20" zPosition="1" halign="center" valign="center" transparent="1" shadowColor="black" shadowOffset="-2,-2" />
86+
<widget name="key_red_pixmap" pixmap="skin_default/buttons/red.png" position="%(btnX1)d,%(btnY)d" size="%(btnW)d,%(btnH)d" scale="stretch" alphatest="on" />
87+
<widget name="key_red" position="%(btnX1)d,%(btnY)d" size="%(btnW)d,%(btnH)d" font="Regular;%(btnFont)d" zPosition="1" halign="center" valign="center" transparent="1" shadowColor="black" shadowOffset="-2,-2" />
7688
77-
<widget name="key_green_pixmap" pixmap="skin_default/buttons/green.png" position="233,510" size="210,40" scale="stretch" alphatest="on" />
78-
<widget name="key_green" position="233,510" size="210,40" font="Regular;20" zPosition="1" halign="center" valign="center" transparent="1" shadowColor="black" shadowOffset="-2,-2" />
89+
<widget name="key_green_pixmap" pixmap="skin_default/buttons/green.png" position="%(btnX2)d,%(btnY)d" size="%(btnW)d,%(btnH)d" scale="stretch" alphatest="on" />
90+
<widget name="key_green" position="%(btnX2)d,%(btnY)d" size="%(btnW)d,%(btnH)d" font="Regular;%(btnFont)d" zPosition="1" halign="center" valign="center" transparent="1" shadowColor="black" shadowOffset="-2,-2" />
7991
80-
<widget name="key_yellow_pixmap" pixmap="skin_default/buttons/yellow.png" position="456,510" size="210,40" scale="stretch" alphatest="on" />
81-
<widget name="key_yellow" position="456,510" size="210,40" font="Regular;20" zPosition="1" halign="center" valign="center" transparent="1" shadowColor="black" shadowOffset="-2,-2" />
92+
<widget name="key_yellow_pixmap" pixmap="skin_default/buttons/yellow.png" position="%(btnX3)d,%(btnY)d" size="%(btnW)d,%(btnH)d" scale="stretch" alphatest="on" />
93+
<widget name="key_yellow" position="%(btnX3)d,%(btnY)d" size="%(btnW)d,%(btnH)d" font="Regular;%(btnFont)d" zPosition="1" halign="center" valign="center" transparent="1" shadowColor="black" shadowOffset="-2,-2" />
8294
83-
<widget name="key_blue_pixmap" pixmap="skin_default/buttons/blue.png" position="679,510" size="210,40" scale="stretch" alphatest="on" />
84-
<widget name="key_blue" position="679,510" size="210,40" font="Regular;20" zPosition="1" halign="center" valign="center" transparent="1" shadowColor="black" shadowOffset="-2,-2" />
95+
<widget name="key_blue_pixmap" pixmap="skin_default/buttons/blue.png" position="%(btnX4)d,%(btnY)d" size="%(btnW)d,%(btnH)d" scale="stretch" alphatest="on" />
96+
<widget name="key_blue" position="%(btnX4)d,%(btnY)d" size="%(btnW)d,%(btnH)d" font="Regular;%(btnFont)d" zPosition="1" halign="center" valign="center" transparent="1" shadowColor="black" shadowOffset="-2,-2" />
8597
</screen>
8698
"""
8799

88100
def __init__(self, session, args=None):
101+
# getDesktop() is core enigma2 API, so this works on every image regardless of the skin engine's
102+
# own scaling features. Must be set before Screen.__init__, which parses self.skin.
103+
factor = getDesktop(0).size().height() / 720.0
104+
self.geometry = dict((key, int(value * factor)) for key, value in Scripts.skinGeometry.items())
105+
self.skin = Scripts.skin % self.geometry
89106
Screen.__init__(self, session)
90107
self.title = "Select Boot Slot - Version %s" % PV
91108
self["header"] = Label(_("Boot device not found!"))
@@ -97,7 +114,7 @@ def __init__(self, session, args=None):
97114
self.reload_list()
98115
self["list"] = MenuList([entry.label for entry in self.slist])
99116
if hasattr(self["list"].l, "setItemHeight"):
100-
self["list"].l.setItemHeight(30)
117+
self["list"].l.setItemHeight(self.geometry["itemH"])
101118

102119
self["key_red"] = Button(_("Cancel"))
103120
self["key_red_pixmap"] = Pixmap()

0 commit comments

Comments
 (0)