From e918a9144b76447fa2d9c43acfedc1df6228654d Mon Sep 17 00:00:00 2001 From: Taapat Date: Thu, 23 Mar 2023 00:23:57 +0200 Subject: [PATCH] Implement buttons text size reduction If it doesn't fit in the button. --- .../enigma2/SimpleGray-HD/skin_templates.xml | 40 ++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/usr/share/enigma2/SimpleGray-HD/skin_templates.xml b/usr/share/enigma2/SimpleGray-HD/skin_templates.xml index c62e0db..0a97822 100644 --- a/usr/share/enigma2/SimpleGray-HD/skin_templates.xml +++ b/usr/share/enigma2/SimpleGray-HD/skin_templates.xml @@ -64,6 +64,22 @@ + +def calculate_text_size(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] + 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)) + @@ -186,6 +202,17 @@ + +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")) + @@ -208,6 +235,17 @@ + +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")) + @@ -260,7 +298,7 @@ self["text"].instance.resize(eSize(*textsize)) if self.type == self.TYPE_YESNO: self["list"].instance.move(ePoint(int(15 * f), int(wsizey - listlen - 10 * f))) self["list"].instance.resize(eSize(*(int(wsizex - 30 * f), int(listlen)))) -self.instance.move(ePoint(int((1280 * f - wsizex) / 2), int((690 * f - wsizey) / 2))) +self.instance.move(ePoint(int((1280 * f - wsizex) // 2), int((690 * f - wsizey) // 2))) self.instance.resize(eSize(*(int(wsizex), int(wsizey))))