Skip to content

Commit

Permalink
Implements button text resizing on all skin screens
Browse files Browse the repository at this point in the history
  • Loading branch information
Taapat committed Mar 23, 2023
1 parent e918a91 commit 6959820
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 31 deletions.
15 changes: 9 additions & 6 deletions usr/share/enigma2/SimpleGray-HD/skin_screens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,7 @@ self.instance.move(ePoint(int((1280 * f - wsizex) / 2), int((740 * f - wsizey) /
<widget source="key_green" render="Label" position="221*f,532*f" size="196*f,36*f" font="Regular;22*f" halign="center" valign="center"/>
<widget source="key_yellow" render="Label" position="425*f,532*f" size="196*f,36*f" font="Regular;22*f" halign="center" valign="center"/>
<widget source="key_blue" render="Label" position="629*f,532*f" size="196*f,36*f" font="Regular;22*f" halign="center" valign="center"/>
<panel name="ResizeButtonStaticTextTemplate"/>
</screen>

<!--Screens.EventView-->
Expand Down Expand Up @@ -603,10 +604,11 @@ self.instance.move(ePoint(int((1280 * f - wsizex) / 2), int((740 * f - wsizey) /
<eLabel position="219*f,530*f" size="200*f,40*f" zPosition="-5" backgroundColor="green"/>
<eLabel position="423*f,530*f" size="200*f,40*f" zPosition="-5" backgroundColor="yellow"/>
<eLabel position="627*f,530*f" size="200*f,40*f" zPosition="-5" backgroundColor="blue"/>
<widget name="key_red" render="Label" position="17*f,532*f" size="196*f,36*f" font="Regular;22*f" halign="center" valign="center"/>
<widget name="key_green" render="Label" position="221*f,532*f" size="196*f,36*f" font="Regular;22*f" halign="center" valign="center"/>
<widget name="key_yellow" render="Label" position="425*f,532*f" size="196*f,36*f" font="Regular;22*f" halign="center" valign="center"/>
<widget name="key_blue" render="Label" position="629*f,532*f" size="196*f,36*f" font="Regular;22*f" halign="center" valign="center"/>
<widget name="key_red" position="17*f,532*f" size="196*f,36*f" font="Regular;22*f" halign="center" valign="center"/>
<widget name="key_green" position="221*f,532*f" size="196*f,36*f" font="Regular;22*f" halign="center" valign="center"/>
<widget name="key_yellow" position="425*f,532*f" size="196*f,36*f" font="Regular;22*f" halign="center" valign="center"/>
<widget name="key_blue" position="629*f,532*f" size="196*f,36*f" font="Regular;22*f" halign="center" valign="center"/>
<panel name="ResizeButtonTextTemplate"/>
</screen>

<!--Plugins.Extensions.GraphMultiEPG.GraphMultiEpg-->
Expand Down Expand Up @@ -1116,8 +1118,9 @@ self.instance.move(ePoint(int((1280 * f - wsizex) / 2), int((740 * f - wsizey) /
<widget name="list" position="5*f,10*f" size="625*f,453*f" scrollbarMode="showOnDemand" itemHeight="50*f"/>
<eLabel position="15*f,500*f" size="247*f,40*f" zPosition="-5" backgroundColor="red"/>
<eLabel position="266*f,500*f" size="247*f,40*f" zPosition="-5" backgroundColor="green"/>
<widget name="key_red" render="Label" position="17*f,502*f" size="243*f,36*f" font="Regular;22*f" halign="center" valign="center"/>
<widget name="key_green" render="Label" position="268*f,502*f" size="243*f,36*f" font="Regular;22*f" halign="center" valign="center"/>
<widget name="key_red" position="17*f,502*f" size="243*f,36*f" font="Regular;22*f" halign="center" valign="center"/>
<widget name="key_green" position="268*f,502*f" size="243*f,36*f" font="Regular;22*f" halign="center" valign="center"/>
<panel name="ResizeButtonTextTemplate"/>
</screen>

<!--from Screens.PluginBrowser-->
Expand Down
58 changes: 33 additions & 25 deletions usr/share/enigma2/SimpleGray-HD/skin_templates.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,20 @@
<widget objectTypes="key_blue,Label,Button" name="key_blue" position="(e-36*f)*0.75+23*f,2*f" size="(e-36*f)/4-4*f,36*f" font="Regular;22*f" halign="center" valign="center"/>
</panel>
<applet type="onLayoutFinish">
def calculate_text_size(self):
def resize_button_text(self):
b_height = 0
for x in ("key_red", "key_green", "key_yellow", "key_blue"):
if x in self:
button = self[x]
if hasattr(button, "downstream_elements"):
button = button.downstream_elements[1]
button = button.downstream_elements[-1]
if not b_height:
b_height = button.instance.size().height()
if button.instance.calculateSize().height() > b_height:
from skin import parseFont
button.instance.setFont(parseFont("Regular;16*f"))
from Tools.BoundFunction import boundFunction
self.onShown.append(boundFunction(calculate_text_size, self))
self.onShown.append(boundFunction(resize_button_text, self))
</applet>
</screen>

Expand Down Expand Up @@ -202,17 +202,7 @@ self.onShown.append(boundFunction(calculate_text_size, self))
<widget name="key_yellow" position="365*f,2*f" size="166*f,36*f" font="Regular;22*f" halign="center" valign="center"/>
<widget name="key_blue" position="539*f,2*f" size="166*f,36*f" font="Regular;22*f" halign="center" valign="center"/>
</panel>
<applet type="onLayoutFinish">
b_height = 0
for x in ("key_red", "key_green", "key_yellow", "key_blue"):
if x in self:
button = self[x]
if not b_height:
b_height = button.instance.size().height()
if button.instance.calculateSize().height() > b_height:
from skin import parseFont
button.instance.setFont(parseFont("Regular;16*f"))
</applet>
<panel name="ResizeButtonTextTemplate"/>
</screen>

<screen name="LeftTextButtonsTemplate">
Expand All @@ -235,17 +225,7 @@ for x in ("key_red", "key_green", "key_yellow", "key_blue"):
<widget objectTypes="key_yellow,StaticText" source="key_yellow" render="Label" position="365*f,2*f" size="166*f,36*f" font="Regular;22*f" halign="center" valign="center"/>
<widget objectTypes="key_blue,StaticText" source="key_blue" render="Label" position="539*f,2*f" size="166*f,36*f" font="Regular;22*f" halign="center" valign="center"/>
</panel>
<applet type="onLayoutFinish">
b_height = 0
for x in ("key_red", "key_green", "key_yellow", "key_blue"):
if x in self:
button = self[x].downstream_elements[1]
if not b_height:
b_height = button.instance.size().height()
if button.instance.calculateSize().height() > b_height:
from skin import parseFont
button.instance.setFont(parseFont("Regular;16*f"))
</applet>
<panel name="ResizeButtonStaticTextTemplate"/>
</screen>

<screen name="IpkDownloadTemplate">
Expand Down Expand Up @@ -376,6 +356,34 @@ self.instance.resize(eSize(*(int(wsizex), int(wsizey))))
<widget name="arrowup2" pixmap="skin_default/arrowup.svg" position="0,0" zPosition="1" size="37,70" transparent="1" alphatest="on"/>
</screen>

<screen name="ResizeButtonStaticTextTemplate">
<applet type="onLayoutFinish">
b_height = 0
for x in ("key_red", "key_green", "key_yellow", "key_blue"):
if x in self:
button = self[x].downstream_elements[-1].instance
if not b_height:
b_height = button.size().height()
if button.calculateSize().height() > b_height:
from skin import parseFont
button.setFont(parseFont("Regular;16*f"))
</applet>
</screen>

<screen name="ResizeButtonTextTemplate">
<applet type="onLayoutFinish">
b_height = 0
for x in ("key_red", "key_green", "key_yellow", "key_blue"):
if x in self:
button = self[x].instance
if not b_height:
b_height = button.size().height()
if button.calculateSize().height() > b_height:
from skin import parseFont
button.setFont(parseFont("Regular;16*f"))
</applet>
</screen>

<screen name="ScanStatusTemplate">
<widget name="frontend" pixmap="icons/scan-s.svg" position="15*f,15*f" size="64*f,64*f" transparent="1" alphatest="on"/>
<widget name="scan_state" position="15*f,100*f" size="420*f,30*f" font="Regular;20*f"/>
Expand Down

0 comments on commit 6959820

Please sign in to comment.