Skip to content

Commit 04c5cf0

Browse files
[MessageBox] Fix Title, List width
1 parent 89ecb5e commit 04c5cf0

1 file changed

Lines changed: 61 additions & 29 deletions

File tree

usr/share/enigma2/MetrixHD/skinfiles/skin_openatv.xml

Lines changed: 61 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,7 +1283,8 @@ self['config'].l.setSeperation(int(300*f))
12831283
<applet type="onLayoutFinish">
12841284
# this should be factored out into some helper code,but currently demonstrates applets.
12851285
from __future__ import division
1286-
from enigma import eSize, ePoint, getDesktop, eRectangle
1286+
from enigma import eSize, ePoint, getDesktop, eRectangle, gFont
1287+
from Tools.TextBoundary import getTextBoundarySize
12871288
#orgwidth = self.instance.size().width()
12881289
#orgheight = self.instance.size().height()
12891290
#---
@@ -1293,54 +1294,79 @@ offset_listwidth = 10
12931294
offset_listheight = 30
12941295
offset_textwidth = 170
12951296
offset_textheight = 20
1296-
min_width = 400
1297-
min_height = 50
1297+
offset_titlewidth = 62
12981298
#----
12991299
deskwidth = getDesktop(0).size().width()
13001300
deskheight = getDesktop(0).size().height()
1301+
maxheight = int(deskheight * 0.75)
1302+
min_width = 400
1303+
min_height = 50
1304+
#----
1305+
titlewidth = 0
1306+
titleheight = 50
13011307
textsize = self["text"].getSize()
13021308
textwidth = textsize[0] + offset_textwidth
13031309
textheight = textsize[1] + offset_textheight
1304-
13051310
listwidth = 0
13061311
listheight = 0
13071312

13081313
if self.list:
1309-
try:
1310-
for i in self.list:
1311-
if len(i[0]) > listwidth:
1312-
listwidth = len(i[0])
1313-
listwidth = listwidth * offset_listwidth
1314-
listheight = len(self.list) * offset_listheight
1315-
except:
1316-
pass
1317-
1318-
maxheight = int(deskheight * 0.75)
1319-
1320-
if listheight &gt;maxheight:
1314+
listheight = len(self.list) * offset_listheight
1315+
if listheight &gt; maxheight:
13211316
listheight = maxheight
1322-
1323-
if (min_height &gt;textheight):
1317+
if (min_height &gt; textheight):
13241318
textheight = min_height
1325-
if (min_width &gt;textwidth):
1326-
textwidth = min_width
1327-
if (listheight &gt;0):
1319+
if (listheight &gt; 0):
13281320
offset = 21
13291321
else:
13301322
offset = 13
1331-
if (textwidth &gt;listwidth):
1332-
wsizex = textwidth + offset_listposx * 2
1333-
else:
1334-
textwidth = listwidth - offset_listposx
1335-
wsizex = listwidth + offset_listposx
1323+
1324+
try:
1325+
for (key, value) in self["Title"].master.skinAttributes:
1326+
if key == "font":
1327+
font = value.split(";")
1328+
title = self.windowTitle
1329+
if self.timeout > 0:
1330+
title = f"{title} ({str(self.timeout)})"
1331+
titlewidth = getTextBoundarySize(None, gFont(font[0], float(font[1])), self["Title"].master.instance.size(), title, True).width()
1332+
1333+
"""
1334+
for (key, value) in self["text"].skinAttributes:
1335+
if key == "font":
1336+
font = value.split(";")
1337+
textwidth = getTextBoundarySize(None, gFont(font[0], float(font[1])), self["text"].instance.size(), self["text"].text, False).width()
1338+
textwidth += offset_textwidth
1339+
"""
1340+
1341+
if self.list:
1342+
for (key, value) in self["list"].skinAttributes:
1343+
if key == "font":
1344+
font = value.split(";")
1345+
o = ""
1346+
for i in self.list:
1347+
l = getTextBoundarySize(None, gFont(font[0], float(font[1])), self["list"].instance.size(), i[0], True).width()
1348+
if l > listwidth:
1349+
listwidth = l
1350+
o = i[0]
1351+
listwidth += offset_listwidth * 2
1352+
except Exception as e:
1353+
pass
1354+
1355+
if (min_width &gt; textwidth):
1356+
textwidth = min_width
1357+
if (titlewidth + offset_titlewidth &gt; textwidth):
1358+
textwidth = titlewidth + offset_titlewidth
1359+
if (listwidth + offset_listposx &gt; textwidth):
1360+
textwidth = listwidth + offset_listposx
1361+
wsizex = textwidth + offset_listposx * 2
13361362

13371363
wsizey = textheight + listheight + offset
13381364

1339-
if ((wsizey + offset_listposy - offset_listposx) &gt;deskheight):
1365+
if ((wsizey + offset_listposy - offset_listposx) &gt; deskheight):
13401366
textheight = deskheight - listheight - offset - offset_listposy + offset_listposx
13411367
wsizey = textheight + listheight + offset
13421368

1343-
if (wsizex &gt;deskwidth):
1369+
if (wsizex &gt; deskwidth):
13441370
textwidth = deskwidth - offset_listposx * 2
13451371
listwidth = wsizex = deskwidth
13461372

@@ -1349,10 +1375,16 @@ wsize = (wsizex,wsizey + offset_listposy - offset_listposx)
13491375
# resize
13501376
self.instance.resize(eSize(*wsize))
13511377

1352-
# resize label
1378+
# resize text
13531379
textsize = (textwidth,textheight)
13541380
self["text"].instance.resize(eSize(*textsize))
13551381

1382+
# resize title
1383+
#if titlewidth == 0: # this should never happen
1384+
# titlewidth = wsizex - offset_listposx * 2 - offset_titlewidth
1385+
titlesize = (titlewidth,titleheight)
1386+
self["Title"].master.instance.resize(eSize(*titlesize))
1387+
13561388
# move list
13571389
if self.list:
13581390
listsize = (wsizex - offset_listposx * 2,listheight)

0 commit comments

Comments
 (0)