@@ -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.
12851285from __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
12931294offset_listheight = 30
12941295offset_textwidth = 170
12951296offset_textheight = 20
1296- min_width = 400
1297- min_height = 50
1297+ offset_titlewidth = 62
12981298#----
12991299deskwidth = getDesktop(0).size().width()
13001300deskheight = 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
13011307textsize = self["text"].getSize()
13021308textwidth = textsize[0] + offset_textwidth
13031309textheight = textsize[1] + offset_textheight
1304-
13051310listwidth = 0
13061311listheight = 0
13071312
13081313if 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 > maxheight:
1314+ listheight = len(self.list) * offset_listheight
1315+ if listheight > maxheight:
13211316 listheight = maxheight
1322-
1323- if (min_height > textheight):
1317+ if (min_height > textheight):
13241318 textheight = min_height
1325- if (min_width > textwidth):
1326- textwidth = min_width
1327- if (listheight > 0):
1319+ if (listheight > 0):
13281320 offset = 21
13291321else:
13301322 offset = 13
1331- if (textwidth > 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 > textwidth):
1356+ textwidth = min_width
1357+ if (titlewidth + offset_titlewidth > textwidth):
1358+ textwidth = titlewidth + offset_titlewidth
1359+ if (listwidth + offset_listposx > textwidth):
1360+ textwidth = listwidth + offset_listposx
1361+ wsizex = textwidth + offset_listposx * 2
13361362
13371363wsizey = textheight + listheight + offset
13381364
1339- if ((wsizey + offset_listposy - offset_listposx) > deskheight):
1365+ if ((wsizey + offset_listposy - offset_listposx) > deskheight):
13401366 textheight = deskheight - listheight - offset - offset_listposy + offset_listposx
13411367 wsizey = textheight + listheight + offset
13421368
1343- if (wsizex > deskwidth):
1369+ if (wsizex > 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
13501376self.instance.resize(eSize(*wsize))
13511377
1352- # resize label
1378+ # resize text
13531379textsize = (textwidth,textheight)
13541380self["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
13571389if self.list:
13581390 listsize = (wsizex - offset_listposx * 2,listheight)
0 commit comments