import skin
-from enigma import ePoint
+from enigma import ePoint, eSize
class GUIComponent(object):
""" GUI component """
self.__dict__.clear()
# this works only with normal widgets - if you don't have self.instance, override this.
- def applySkin(self, desktop):
+ def applySkin(self, desktop, parent):
if not self.visible:
self.instance.hide()
if self.skinAttributes is None:
return False
- skin.applyAllAttributes(self.instance, desktop, self.skinAttributes)
+ skin.applyAllAttributes(self.instance, desktop, self.skinAttributes, parent.scale)
return True
def move(self, x, y = None):
self.instance.move(x)
else:
self.instance.move(ePoint(int(x), int(y)))
-
- def resize(self, size):
- self.instance.resize(size)
-
+
+ def resize(self, x, y = None):
+ if y is None:
+ self.instance.resize(x)
+ else:
+ self.instance.resize(eSize(int(x), int(y)))
+
def setZPosition(self, z):
self.instance.setZPosition(z)
def __init__(self):
self.onLayoutFinish = [ ]
self.summaries = CList()
+ self.instance = None
+ self.desktop = None
- def createGUIScreen(self, parent, desktop):
+ def createGUIScreen(self, parent, desktop, updateonly = False):
for val in self.renderer:
if isinstance(val, GUIComponent):
- val.GUIcreate(parent)
- if not val.applySkin(desktop):
+ if not updateonly:
+ val.GUIcreate(parent)
+ if not val.applySkin(desktop, self):
print "warning, skin is missing renderer", val, "in", self
for key in self:
val = self[key]
if isinstance(val, GUIComponent):
- val.GUIcreate(parent)
+ if not updateonly:
+ val.GUIcreate(parent)
depr = val.deprecationInfo
- if val.applySkin(desktop):
+ if val.applySkin(desktop, self):
if depr:
print "WARNING: OBSOLETE COMPONENT '%s' USED IN SKIN. USE '%s' INSTEAD!" % (key, depr[0])
print "OBSOLETE COMPONENT WILL BE REMOVED %s, PLEASE UPDATE!" % (depr[1])
print "warning, skin is missing element", key, "in", self
for w in self.additionalWidgets:
- w.instance = w.widget(parent)
- # w.instance.thisown = 0
- applyAllAttributes(w.instance, desktop, w.skinAttributes)
+ if not updateonly:
+ w.instance = w.widget(parent)
+ # w.instance.thisown = 0
+ applyAllAttributes(w.instance, desktop, w.skinAttributes, self.scale)
for f in self.onLayoutFinish:
if type(f) is not type(self.close): # is this the best way to do this?
self.instance.setTitle(title)
self.title = title
self.summaries.setTitle(title)
+
+ def setDesktop(self, desktop):
+ self.desktop = desktop
+
+ def applySkin(self):
+ z = 0
+ title = ""
+ baseres = (720, 576) # FIXME: a skin might have set another resolution, which should be the base res
+ for (key, value) in self.skinAttributes:
+ if key == "zPosition":
+ z = int(value)
+ elif key == "title":
+ title = value
+ elif key == "baseResolution":
+ baseres = tuple([int(x) for x in value.split(',')])
+ self.scale = ((baseres[0], baseres[0]), (baseres[1], baseres[1]))
+
+ if not self.instance:
+ from enigma import eWindow
+ self.instance = eWindow(self.desktop, z)
+ self.title = title
+ applyAllAttributes(self.instance, self.desktop, self.skinAttributes, self.scale)
+ self.createGUIScreen(self.instance, self.desktop)
self.nameCache = { }
self.pngname = ""
- def applySkin(self, desktop):
+ def applySkin(self, desktop, parent):
attribs = [ ]
for (attrib, value) in self.skinAttributes:
if attrib == "path":
else:
attribs.append((attrib,value))
self.skinAttributes = attribs
- return Renderer.applySkin(self, desktop)
+ return Renderer.applySkin(self, desktop, parent)
GUI_WIDGET = ePixmap
def postWidgetCreate(self, instance):
instance.setDecoder(0)
- def applySkin(self, desktop):
- ret = Renderer.applySkin(self, desktop)
+ def applySkin(self, desktop, parent):
+ ret = Renderer.applySkin(self, desktop, parent)
if ret:
- self.Position = self.instance.position()
+ self.Position = self.instance.position() # fixme, scaling!
self.Size = self.instance.size()
return ret
self.pages = None
self.total = None
- def applySkin(self, desktop):
+ def applySkin(self, desktop, parent):
ret = False
if self.skinAttributes is not None:
- skin.applyAllAttributes(self.long_text, desktop, self.skinAttributes)
+ skin.applyAllAttributes(self.long_text, desktop, self.skinAttributes, parent.scale)
widget_attribs = [ ]
scrollbar_attribs = [ ]
for (attrib, value) in self.skinAttributes:
scrollbar_attribs.append((attrib,value))
if attrib.find("transparent") != -1 or attrib.find("backgroundColor") != -1:
widget_attribs.append((attrib,value))
- skin.applyAllAttributes(self.instance, desktop, widget_attribs)
- skin.applyAllAttributes(self.scrollbar, desktop, scrollbar_attribs+widget_attribs)
+ skin.applyAllAttributes(self.instance, desktop, widget_attribs, parent.scale)
+ skin.applyAllAttributes(self.scrollbar, desktop, scrollbar_attribs+widget_attribs, parent.scale)
ret = True
s = self.long_text.size()
self.instance.move(self.long_text.position())
self.mode = self.MODE_NORMAL
self.onSelectionChanged = [ ]
- def applySkin(self, desktop):
+ def applySkin(self, desktop, parent):
attribs = [ ]
if self.skinAttributes is not None:
attribs = [ ]
else:
attribs.append((attrib, value))
self.skinAttributes = attribs
- return GUIComponent.applySkin(self, desktop)
+ return GUIComponent.applySkin(self, desktop, parent)
def connectSelChanged(self, fnc):
if not fnc in self.onSelectionChanged:
profile("PYTHON_START")
from enigma import runMainloop, eDVBDB, eTimer, quitMainloop, eDVBVolumecontrol, \
- getDesktop, ePythonConfigQuery, eAVSwitch, eWindow, eServiceEvent
+ getDesktop, ePythonConfigQuery, eAVSwitch, eServiceEvent
from tools import *
profile("LANGUAGE")
# display
-class OutputDevice:
- def create(self, screen): pass
-
-class GUIOutputDevice(OutputDevice):
- parent = None
- def create(self, comp, desktop):
- comp.createGUIScreen(self.parent, desktop)
-
profile("LOAD:ScreenGlobals")
from Screens.Globals import Globals
from Screens.SessionGlobals import SessionGlobals
# create GUI view of this dialog
assert desktop is not None
- z = 0
- title = ""
- for (key, value) in dlg.skinAttributes:
- if key == "zPosition":
- z = int(value)
- elif key == "title":
- title = value
-
- dlg.instance = eWindow(desktop, z)
- dlg.title = title
- applyAllAttributes(dlg.instance, desktop, dlg.skinAttributes)
- gui = GUIOutputDevice()
- gui.parent = dlg.instance
- gui.create(dlg, desktop)
+ dlg.setDesktop(desktop)
+ dlg.applySkin()
return dlg
loadSkin('skin_default.xml')
profile("LoadSkinDefaultDone")
-def parsePosition(str):
+def parsePosition(str, scale):
x, y = str.split(',')
- return ePoint(int(x), int(y))
+ return ePoint(int(x) * scale[0][0] / scale[0][1], int(y) * scale[1][0] / scale[1][1])
-def parseSize(str):
+def parseSize(str, scale):
x, y = str.split(',')
- return eSize(int(x), int(y))
+ return eSize(int(x) * scale[0][0] / scale[0][1], int(y) * scale[1][0] / scale[1][1])
-def parseFont(str):
+def parseFont(str, scale):
name, size = str.split(';')
- return gFont(name, int(size))
+ return gFont(name, int(size) * scale[0][0] / scale[0][1])
def parseColor(str):
if str[0] != '#':
raise SkinError("pixmap file %s not found!" % (path))
return ptr
-def applySingleAttribute(guiObject, desktop, attrib, value):
+def applySingleAttribute(guiObject, desktop, attrib, value, scale = ((1,1),(1,1))):
# and set attributes
try:
if attrib == 'position':
- guiObject.move(parsePosition(value))
+ guiObject.move(parsePosition(value, scale))
elif attrib == 'size':
- guiObject.resize(parseSize(value))
+ guiObject.resize(parseSize(value, scale))
elif attrib == 'title':
guiObject.setTitle(_(value))
elif attrib == 'text':
guiObject.setText(_(value))
elif attrib == 'font':
- guiObject.setFont(parseFont(value))
+ guiObject.setFont(parseFont(value, scale))
elif attrib == 'zPosition':
guiObject.setZPosition(int(value))
elif attrib in ["pixmap", "backgroundPixmap", "selectionPixmap"]:
guiObject.setWrapAround(True)
elif attrib == "pointer" or attrib == "seek_pointer":
(name, pos) = value.split(':')
- pos = parsePosition(pos)
+ pos = parsePosition(pos, scale)
ptr = loadPixmap(name, desktop)
guiObject.setPointer({"pointer": 0, "seek_pointer": 1}[attrib], ptr, pos)
elif attrib == 'shadowOffset':
- guiObject.setShadowOffset(parsePosition(value))
+ guiObject.setShadowOffset(parsePosition(value, scale))
elif attrib == 'noWrap':
guiObject.setNoWrap(1)
else:
# AttributeError:
print "widget %s (%s) doesn't support attribute %s!" % ("", guiObject.__class__.__name__, attrib)
-def applyAllAttributes(guiObject, desktop, attributes):
+def applyAllAttributes(guiObject, desktop, attributes, scale):
for (attrib, value) in attributes:
- applySingleAttribute(guiObject, desktop, attrib, value)
+ applySingleAttribute(guiObject, desktop, attrib, value, scale)
def loadSingleSkinData(desktop, skin, path_prefix):
"""loads skin data like colors, windowstyle etc."""
for title in windowstyle.findall("title"):
get_attr = title.attrib.get
- offset = parseSize(get_attr("offset"))
- font = parseFont(get_attr("font"))
+ offset = parseSize(get_attr("offset"), ((1,1),(1,1)))
+ font = parseFont(get_attr("font"), ((1,1),(1,1)))
style.setTitleFont(font);
style.setTitleOffset(offset)