def autoResize(self): orgwidth = self.instance.size().width() orgpos = self.instance.position() # textsize = self["text"].getSize() textsize = (textsize[0] + 50, textsize[1]) # [iq] count = len(self.list) if count > 10: count = 10 offset = 25 * count wsizex = textsize[0] + 60 wsizey = textsize[1] + offset if (520 > wsizex): wsizex = 520 wsize = (wsizex, wsizey) # resize self.instance.resize(enigma.eSize(*wsize)) # resize label self["text"].instance.resize(enigma.eSize(*textsize)) # move list listsize = (wsizex, 25 * count) self["list"].instance.move(enigma.ePoint(0, textsize[1])) self["list"].instance.resize(enigma.eSize(*listsize)) # center window newwidth = wsize[0] self.instance.move(enigma.ePoint((720-wsizex)/2, (576-wsizey)/(count > 7 and 2 or 3)))
def setText(self, text, showBottom=False): self.message = text text = text.rstrip() if self.pageHeight: if self.split: left = [] right = [] for line in text.split("\n"): line = line.split(self.splitchar, 1) left.append(line[0]) right.append("" if len(line) < 2 else line[1].lstrip()) self.long_text.setText("\n".join(left)) self.right_text.setText("\n".join(right)) else: self.long_text.setText(text) self.TotalTextHeight = self.long_text.calculateSize().height() self.long_text.resize(eSize(self.pageWidth - 30, self.TotalTextHeight)) self.split and self.right_text.resize(eSize(self.pageWidth - self.column - 30, self.TotalTextHeight)) if showBottom: self.lastPage() else: self.setPos(0) if self.showscrollbar and self.TotalTextHeight > self.pageHeight: self.scrollbar.show() self.updateScrollbar() else: self.scrollbar.hide()
def updateSize(self): center = True if HD_Res: HDscale = 2 else: HDscale = 1; if splitToInt(self.position, 0) and splitToInt(self.position, 1): pos_x = splitToInt(self.position, 0) pos_y = splitToInt(self.position, 1) center = False # print "[OpenPanel] center = False" if splitToInt(self.size, 0) and splitToInt(self.size, 1): width = splitToInt(self.size, 0) height = splitToInt(self.size, 1) self.instance.resize(eSize(width, height)) self["text"].resize(eSize((width-(10*HDscale)), (height-20))) if center: pos_x = (self.Desktop_width - width) / 2 pos_y = (self.Desktop_height - height) / 2 # print "[OpenPanel] move center position" self.instance.move(ePoint(pos_x, pos_y)) else: # print "[OpenPanel] move to position: ",pos_x, pos_y self.instance.move(ePoint(pos_x, pos_y))
def changeScreensize(self, new_height, new_width = None): if new_width is None: new_width = sizeH self.instance.resize(eSize(new_width, new_height)) fb = getDesktop(0).size() new_posY = int(( fb.height() / 2 ) - ( new_height / 2 )) x = int( ( fb.width() - sizeH ) / 2 ) self.instance.move(ePoint(x, new_posY)) self["output"].resize(eSize(self.sizeLH, new_height - 20)) self["key_red"].setText(_("Close")) if self.what == "c": self["key_green"].setText("") self["key_yellow"].setText("Servers") self["key_blue"].setText("Log") self["output"].l.setItemHeight(20) elif self.what == "s": self["key_green"].setText("Clients") self["key_yellow"].setText("") self["key_blue"].setText("Log") self["output"].l.setItemHeight(20) elif self.what == "l": self["key_green"].setText("Clients") self["key_yellow"].setText("Servers") self["key_blue"].setText("") self["output"].l.setItemHeight(14) else: self["key_green"].setText("Clients") self["key_yellow"].setText("Servers") self["key_blue"].setText("Log")
def resize(self, w, h, doSave=True): if doSave: config.av.pip.value[2] = w config.av.pip.value[3] = h config.av.pip.save() if config.av.pip_mode.value == "standard": self.instance.resize(eSize(*(w, h))) self["video"].instance.resize(eSize(*(w, h))) self.setSizePosMainWindow() elif config.av.pip_mode.value == "cascade": self.instance.resize(eSize(*(w, h))) self["video"].instance.resize(eSize(*(w, h))) self.setSizePosMainWindow(0, h, MAX_X - w, MAX_Y - h) elif config.av.pip_mode.value == "split": self.instance.resize(eSize(*(MAX_X/2, MAX_Y ))) self["video"].instance.resize(eSize(*(MAX_X/2, MAX_Y))) self.setSizePosMainWindow(0, 0, MAX_X/2, MAX_Y) elif config.av.pip_mode.value == "byside": self.instance.resize(eSize(*(MAX_X/2, MAX_Y/2 ))) self["video"].instance.resize(eSize(*(MAX_X/2, MAX_Y/2))) self.setSizePosMainWindow(0, MAX_Y/4, MAX_X/2, MAX_Y/2) elif config.av.pip_mode.value in "bigpig external": self.instance.resize(eSize(*(MAX_X, MAX_Y))) self["video"].instance.resize(eSize(*(MAX_X, MAX_Y))) self.setSizePosMainWindow()
def movePosition(self): if self.instance: self.instance.move(ePoint(config.plugins.MovielistPreview.position_x.value, config.plugins.MovielistPreview.position_y.value)) size = config.plugins.MovielistPreview.size.value.split("x") self.instance.resize(eSize(int(size[0]), int(size[1]))) self["background"].instance.resize(eSize(int(size[0]), int(size[1]))) self["preview"].instance.resize(eSize(int(size[0]), int(size[1])))
def applySkin(self, desktop, parent): ret = False if self.skinAttributes is not None: skin.applyAllAttributes(self.long_text, desktop, self.skinAttributes, parent.scale) widget_attribs = [ ] scrollbar_attribs = [ ] for (attrib, value) in self.skinAttributes: if "borderColor" in attrib or "borderWidth" in attrib: scrollbar_attribs.append((attrib,value)) if "transparent" in attrib or "backgroundColor" in attrib: widget_attribs.append((attrib,value)) 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()) lineheight=fontRenderClass.getInstance().getLineHeight( self.long_text.getFont() ) if not lineheight: lineheight = 30 # assume a random lineheight if nothing is visible lines = (int)(s.height() / lineheight) self.pageHeight = (int)(lines * lineheight) self.instance.resize(eSize(s.width(), self.pageHeight+(int)(lineheight/6))) self.scrollbar.move(ePoint(s.width()-20,0)) self.scrollbar.resize(eSize(20,self.pageHeight+(int)(lineheight/6))) self.scrollbar.setOrientation(eSlider.orVertical); self.scrollbar.setRange(0,100) self.scrollbar.setBorderWidth(1) self.long_text.move(ePoint(0,0)) self.long_text.resize(eSize(s.width()-30, self.pageHeight*50)) self.setText(self.message) return ret
def applySkin(self, desktop, parent): scrollbarWidth = 20 scrollbarBorderWidth = 1 ret = False if self.skinAttributes: widget_attribs = [] scrollbar_attribs = [] for (attrib, value) in self.skinAttributes: if "borderColor" in attrib or "borderWidth" in attrib: scrollbar_attribs.append((attrib,value)) if "transparent" in attrib or "backgroundColor" in attrib: widget_attribs.append((attrib,value)) if "scrollbarSliderForegroundColor" in attrib: scrollbar_attribs.append((attrib,value)) self.skinAttributes.remove((attrib, value)) if "scrollbarSliderBorderColor" in attrib: scrollbar_attribs.append((attrib,value)) self.skinAttributes.remove((attrib, value)) if "scrollbarSliderPicture" in attrib: scrollbar_attribs.append((attrib,value)) self.skinAttributes.remove((attrib, value)) if "scrollbarBackgroundPicture" in attrib: scrollbar_attribs.append((attrib,value)) self.skinAttributes.remove((attrib, value)) if "scrollbarWidth" in attrib: scrollbarWidth = int(value) self.skinAttributes.remove((attrib, value)) if "scrollbarSliderBorderWidth" in attrib: scrollbarBorderWidth = int(value) self.skinAttributes.remove((attrib, value)) if "split" in attrib: self.split = int(value) if self.split: self.right_text = eLabel(self.instance) self.skinAttributes.remove((attrib, value)) if "colposition" in attrib: self.column = int(value) if "dividechar" in attrib: self.splitchar = value if self.split: skin.applyAllAttributes(self.long_text, desktop, self.skinAttributes + [("halign", "left")], parent.scale) skin.applyAllAttributes(self.right_text, desktop, self.skinAttributes + [("transparent", "1"), ("halign", "left" if self.column else "right")], parent.scale) else: skin.applyAllAttributes(self.long_text, desktop, self.skinAttributes, parent.scale) skin.applyAllAttributes(self.instance, desktop, widget_attribs, parent.scale) skin.applyAllAttributes(self.scrollbar, desktop, scrollbar_attribs + widget_attribs, parent.scale) ret = True self.pageWidth = self.long_text.size().width() lineheight = fontRenderClass.getInstance().getLineHeight(self.long_text.getFont()) or 30 # assume a random lineheight if nothing is visible lines = int(self.long_text.size().height() / lineheight) self.pageHeight = int(lines * lineheight) self.instance.move(self.long_text.position()) self.instance.resize(eSize(self.pageWidth, self.pageHeight + int(lineheight/6))) self.scrollbar.move(ePoint(self.pageWidth - scrollbarWidth, 0)) self.scrollbar.resize(eSize(scrollbarWidth, self.pageHeight + int(lineheight / 6))) self.scrollbar.setOrientation(eSlider.orVertical) self.scrollbar.setRange(0, 100) self.scrollbar.setBorderWidth(scrollbarBorderWidth) self.setText(self.message) return ret
def appendText(self, text): old_text = self.getText() if len(str(old_text)) >0: self.message += text else: self.message = text if self.long_text is not None: self.long_text.setText(self.message) text_height=self.long_text.calculateSize().height() total=self.pageHeight pages=1 while total < text_height: total += self.pageHeight pages += 1 s = self.long_text.size() self.long_text.resize(eSize(s.width(), total)) if self.split: self.right_text.resize(eSize(s.width()-self.column-30, total)) if (self. scrollbarmode == "showAlways") or ((self.scrollbarmode == "showOnDemand") and (pages > 1)): self.scrollbar.show() self.total = total self.pages = pages self.updateScrollbar() else: self.scrollbar.hide() self.total = None self.pages = None
def setItemsPerPage(self): global listscreen if self.listHeight > 0: if listscreen: itemHeight = self.listHeight / config.misc.graph_mepg.items_per_page_listscreen.getValue() else: itemHeight = self.listHeight / config.misc.graph_mepg.items_per_page.getValue() else: itemHeight = 54 # some default (270/5) if listscreen: self.instance.resize(eSize(self.listWidth, itemHeight * config.misc.graph_mepg.items_per_page_listscreen.getValue())) else: self.instance.resize(eSize(self.listWidth, itemHeight * config.misc.graph_mepg.items_per_page.getValue())) self.l.setItemHeight(itemHeight) self.picload.setPara((self.listWidth, itemHeight - 2 * self.eventBorderWidth, 0, 0, 1, 1, "#00000000")) self.picload.startDecode(resolveFilename(SCOPE_CURRENT_SKIN, 'epg/CurrentEvent.png'), 0, 0, False) self.nowEvPix = self.picload.getData() self.picload.startDecode(resolveFilename(SCOPE_CURRENT_SKIN, 'epg/OtherEvent.png'), 0, 0, False) self.othEvPix = self.picload.getData() self.picload.startDecode(resolveFilename(SCOPE_CURRENT_SKIN, 'epg/SelectedEvent.png'), 0, 0, False) self.selEvPix = self.picload.getData() self.picload.startDecode(resolveFilename(SCOPE_CURRENT_SKIN, 'epg/RecordingEvent.png'), 0, 0, False) self.recEvPix = self.picload.getData()
def autoResize(self): desktop_w = enigma.getDesktop(0).size().width() desktop_h = enigma.getDesktop(0).size().height() count = len(self.list) if count > 15: count = 15 if not self["text"].text: # move list textsize = (520, 0) listsize = (520, 25 * count) self["list"].instance.move(enigma.ePoint(0, 0)) self["list"].instance.resize(enigma.eSize(*listsize)) else: textsize = self["text"].getSize() if textsize[0] < textsize[1]: textsize = (textsize[1], textsize[0] + 10) if textsize[0] > 520: textsize = (textsize[0], textsize[1] + 25) else: textsize = (520, textsize[1] + 25) listsize = (textsize[0], 25 * count) # resize label self["text"].instance.resize(enigma.eSize(*textsize)) self["text"].instance.move(enigma.ePoint(10, 10)) # move list self["list"].instance.move(enigma.ePoint(0, textsize[1])) self["list"].instance.resize(enigma.eSize(*listsize)) wsizex = textsize[0] wsizey = textsize[1] + listsize[1] wsize = (wsizex, wsizey) self.instance.resize(enigma.eSize(*wsize)) # center window self.instance.move(enigma.ePoint((desktop_w - wsizex) / 2, (desktop_h - wsizey) / 2))
def updateSize(self): node = self.currentNode size = self.getSettings(node)[0] position = self.getSettings(node)[1] center = True if HD_Res: HDscale = 2; else: HDscale = 1; if splitToInt(position, 0) and splitToInt(position, 1): pos_x = splitToInt(position, 0) pos_y = splitToInt(position, 1) center = False # print "[OpenPanel] center = False" if splitToInt(size, 0) and splitToInt(size, 1): width = splitToInt(size, 0) height = splitToInt(size, 1) self.instance.resize(eSize(width, height)) self["list"].resize(eSize((width-(10*HDscale)), (height-60))) self["help"].resize(eSize((width-(10*HDscale)), 38)) self["help"].move(ePoint((5*HDscale), (height-40))) if center: pos_x = (self.Desktop_width - width) / 2 pos_y = (self.Desktop_height - height) / 2 # print "[OpenPanel] move center position" self.instance.move(ePoint(pos_x, pos_y)) else: # print "[OpenPanel] move to position: ",pos_x, pos_y self.instance.move(ePoint(pos_x, pos_y))
def autoResize(self): desktop_w = enigma.getDesktop(0).size().width() desktop_h = enigma.getDesktop(0).size().height() count = len(self.list) itemheight = self['list'].getItemHeight() if count > 15: count = 15 if not self['text'].text: textsize = (520, 0) listsize = (520, itemheight * count) self['list'].instance.move(enigma.ePoint(0, 0)) self['list'].instance.resize(enigma.eSize(*listsize)) else: textsize = self['text'].getSize() if textsize[0] < textsize[1]: textsize = (textsize[1], textsize[0] + 10) if textsize[0] > 520: textsize = (textsize[0], textsize[1] + itemheight) else: textsize = (520, textsize[1] + itemheight) listsize = (textsize[0], itemheight * count) self['text'].instance.resize(enigma.eSize(*textsize)) self['text'].instance.move(enigma.ePoint(10, 10)) self['list'].instance.move(enigma.ePoint(0, textsize[1])) self['list'].instance.resize(enigma.eSize(*listsize)) wsizex = textsize[0] wsizey = textsize[1] + listsize[1] wsize = (wsizex, wsizey) self.instance.resize(enigma.eSize(*wsize)) self.instance.move(enigma.ePoint((desktop_w - wsizex) / 2, (desktop_h - wsizey) / 2))
def updateDescription(self): if self.settings["description"] == MovieList.SHOW_DESCRIPTION: self["DescriptionBorder"].show() self["list"].instance.resize(eSize(self.listWidth, self.listHeight-self["DescriptionBorder"].instance.size().height())) else: self["Service"].newService(None) self["DescriptionBorder"].hide() self["list"].instance.resize(eSize(self.listWidth, self.listHeight))
def hidePiP(self): # set pip size to 1 pixel print("[EPGRefresh.PipAdapter.hidePiP]") x = y = 0 w = h = 1 self.session.pip.instance.move(ePoint(x, y)) self.session.pip.instance.resize(eSize(w, y)) self.session.pip["video"].instance.resize(eSize(w, y))
def parseSize(s, scale, object = None, desktop = None): x, y = s.split(',') parentsize = eSize() if object and (x[0] in ('c', 'e') or y[0] in ('c', 'e')): parentsize = getParentSize(object, desktop) xval = parseCoordinate(x, parentsize.width()) yval = parseCoordinate(y, parentsize.height()) return eSize(xval * scale[0][0] / scale[0][1], yval * scale[1][0] / scale[1][1])
def postWidgetCreate(self, instance): for (attrib, value) in self.skinAttributes: if attrib == "size": x, y = value.split(',') self._scaleSize = eSize(int(x), int(y)) break sc = AVSwitch().getFramebufferScale() self._aspectRatio = eSize(sc[0], sc[1]) self.picload.setPara((self._scaleSize.width(), self._scaleSize.height(), sc[0], sc[1], True, 2, '#ff000000'))
def resize(self, s): lineheight = fontRenderClass.getInstance().getLineHeight(self.long_text.getFont()) if not lineheight: lineheight = 30 # assume a random lineheight if nothing is visible lines = (int)(s.height() / lineheight) self.pageHeight = (int)(lines * lineheight) self.instance.resize(eSize(s.width(), self.pageHeight + (int)(lineheight / 6))) self.scrollbar.move(ePoint(s.width() - 20, 0)) self.scrollbar.resize(eSize(20, self.pageHeight + (int)(lineheight / 6))) self.long_text.resize(eSize(s.width() - 30, self.pageHeight * 16)) self.setText(self.message)
def applySkin(self, desktop, parent): scrollbarWidth = 20 scrollbarBorderWidth = 1 ret = False if self.skinAttributes is not None: scrollbar_attribs = [ ] widget_attribs = [ ] remove_attribs = [ ] for (attrib, value) in self.skinAttributes: if attrib.find("borderColor") != -1 or attrib.find("borderWidth") != -1: scrollbar_attribs.append((attrib,value)) if attrib.find("transparent") != -1 or attrib.find("backgroundColor") != -1: widget_attribs.append((attrib,value)) if attrib.find("scrollbarSliderForegroundColor") != -1: scrollbar_attribs.append((attrib,value)) remove_attribs.append((attrib, value)) if attrib.find("scrollbarSliderBorderColor") != -1: scrollbar_attribs.append((attrib,value)) remove_attribs.append((attrib, value)) if attrib.find("scrollbarSliderPicture") != -1: scrollbar_attribs.append((attrib,value)) remove_attribs.append((attrib, value)) if attrib.find("scrollbarBackgroundPicture") != -1: scrollbar_attribs.append((attrib,value)) remove_attribs.append((attrib, value)) if attrib.find("scrollbarWidth") != -1: scrollbarWidth = int(value) remove_attribs.append((attrib, value)) if attrib.find("scrollbarSliderBorderWidth") != -1: scrollbarBorderWidth = int(value) remove_attribs.append((attrib, value)) for (attrib, value) in remove_attribs: self.skinAttributes.remove((attrib, value)) skin.applyAllAttributes(self.long_text, desktop, self.skinAttributes, parent.scale) 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()) lineheight=fontRenderClass.getInstance().getLineHeight( self.long_text.getFont() ) if not lineheight: lineheight = 30 # assume a random lineheight if nothing is visible lines = (int)(s.height() / lineheight) self.pageHeight = (int)(lines * lineheight) self.instance.resize(eSize(s.width(), self.pageHeight+(int)(lineheight/6))) self.scrollbar.move(ePoint(s.width() - scrollbarWidth,0)) self.scrollbar.resize(eSize(scrollbarWidth,self.pageHeight+(int)(lineheight/6))) self.scrollbar.setOrientation(eSlider.orVertical); self.scrollbar.setRange(0,100) self.scrollbar.setBorderWidth(scrollbarBorderWidth) self.long_text.move(ePoint(0,0)) self.long_text.resize(eSize(s.width()-30, self.pageHeight*16)) self.setText(self.message) return ret
def __layoutFinished(self): from enigma import eSize, ePoint if getDesktop(0).size().height() == 1080: lenlist = len(self.list)*40 self["config"].instance.move(ePoint(383, 863 - lenlist)) self["config"].instance.resize(eSize(1234, lenlist)) self["introduction"].instance.resize(eSize(1234, 623 - lenlist)) else: lenlist = len(self.list)*30 self["config"].instance.move(ePoint(228, 590 - lenlist)) self["config"].instance.resize(eSize(800, lenlist)) self["introduction"].instance.resize(eSize(800, 415 - lenlist))
def reSize(self): self.updateInfo() if len(self.reclist) == 0: self.instance.resize(eSize(self.def_size.width(), 0)) else: height = self["chName"].instance.calculateSize().height() + 9 for x in self.labels: self[x].instance.resize(eSize(self[x].instance.size().width(), height)) height += self.def_hreg self.instance.resize(eSize(self.def_size.width(), height)) if self.anchor == "bottom": y = self.def_pos.y() + self.def_size.height() - height self.instance.move(ePoint(self.def_pos.x(), y))
def _onLayoutFinish(self): orgwidth = self.instance.size().width() orgpos = self.instance.position() textsize = self["text"].getSize() # y size still must be fixed in font stuff... textsize = (textsize[0] + 20, textsize[1] + 15) self.instance.resize(eSize(*textsize)) self["text"].instance.resize(eSize(*textsize)) # center window newwidth = textsize[0] self.instance.move(ePoint(orgpos.x() + (orgwidth - newwidth) / 2, orgpos.y()))
def _buildSizeAnimation(self, item, duration, interpolator=0): attrs = item.attrib if "interpolate" in attrs: interpolator = self._buildInterpolator(attrs) isReverse = item.tag == "size_hide" animateW = "animateW" in attrs animateH = "animateH" in attrs centered = "centered" in attrs if not animateW and not animateH: animateW = animateH = True w, h = attrs["val"].split(",") w, h = int(w), int(h) fromSize = eSize(w,h) toSize = eSize() return eSizeAnimation.create(duration, fromSize, toSize, False, interpolator, isReverse, animateW, animateH, centered)
def setWigetPixMapPictureInScale(self, myIndex, myWidget = "WigetPixMapPictureInScale", myWidgetFile = 'widgetmarker.png' ): if not 'position' in self.root[self.currentScreenID][myIndex].attrib: self[myWidget].hide() return elif not 'size' in self.root[self.currentScreenID][myIndex].attrib: self[myWidget].hide() return elif not 'pixmap' in self.root[self.currentScreenID][myIndex].attrib: if path.exists("%sUserSkinpics/%s" % (SkinPath, myWidgetFile) ): pic = "%sUserSkinpics/%s" % (SkinPath, myWidgetFile) else: pic = "%spic/edit/%s" % (PluginPath, myWidgetFile) else: pic = resolveFilename(SCOPE_SKIN, self.root[self.currentScreenID][myIndex].attrib['pixmap'] ) #position="x,y" size="x,y" printDEBUG("setWigetPixMapPictureInScale, pic=%s" % pic) WidgetPosition=self.root[self.currentScreenID][myIndex].attrib['position'].split(',') WidgetSize=self.root[self.currentScreenID][myIndex].attrib['size'].split(',') if WidgetPosition[0] == 'center': WidgetPosition[0] = self.currentWidth/2 - int(WidgetSize[0])/2 if WidgetPosition[1] == 'center': WidgetPosition[1] = self.currentHeight/2 - int(WidgetSize[1])/2 if path.exists(pic): self[myWidget].instance.resize(eSize(int(int(WidgetSize[0])*self.WidgetPreviewScale) , int(int(WidgetSize[1])*self.WidgetPreviewScale) )) self[myWidget].instance.setScale(1) self[myWidget].instance.setPixmapFromFile(pic) self[myWidget].show() self[myWidget].instance.move(ePoint(int(int(WidgetPosition[0])*self.WidgetPreviewScale) + self.WidgetPreviewX , \ int(int(WidgetPosition[1])*self.WidgetPreviewScale + self.WidgetPreviewY))) else: self[myWidget].hide()
def size(self, value): if isinstance(value, tuple): self.guiObject.resize(eSize(*value)) else: self.guiObject.resize( parseSize(value, self.scaleTuple, self.guiObject, self.desktop))
def resize(self, x, y = None): self.width = x self.height = y if y is None: self.instance.resize(x) else: self.instance.resize(eSize(int(x), int(y)))
def applySkin(self, desktop): skin.applyAllAttributes(self.long_text, desktop, self.skinAttributes) s = self.long_text.size() self.instance.move(self.long_text.position()) lineheight = fontRenderClass.getInstance().getLineHeight(self.long_text.getFont()) lines = int(s.height() / lineheight) self.pageHeight = int(lines * lineheight) self.instance.resize(eSize(s.width(), self.pageHeight + int(lineheight / 6))) self.scrollbar.move(ePoint(s.width() - 20, 0)) self.scrollbar.resize(eSize(20, self.pageHeight + int(lineheight / 6))) self.scrollbar.setOrientation(eSlider.orVertical) self.scrollbar.setRange(0, 100) self.scrollbar.setBorderWidth(1) self.long_text.move(ePoint(0, 0)) self.long_text.resize(eSize(s.width() - 30, self.pageHeight * 16)) self.setText(self.message)
def setItemsPerPage(self): if self.listHeight > 0: itemHeight = self.listHeight / config.misc.graph_mepg.items_per_page.getValue() else: itemHeight = 54 # some default (270/5) self.instance.resize(eSize(self.listWidth, itemHeight * config.misc.graph_mepg.items_per_page.getValue())) self.l.setItemHeight(itemHeight)
def appendText(self, text): old_text = self.getText() if len(str(old_text)) >0: self.message += text else: self.message = text if self.long_text is not None: self.long_text.setText(self.message) text_height=self.long_text.calculateSize().height() total=self.pageHeight pages=1 while total < text_height: total=total+self.pageHeight pages=pages+1 if pages > 1: s = self.long_text.size() self.long_text.resize(eSize(s.width(), self.pageHeight*pages)) self.scrollbar.show() self.total = total self.pages = pages self.updateScrollbar() else: self.scrollbar.hide() self.total = None self.pages = None
def setItemsPerPage(self): self.itemHeight = 94 self.itemWidth = 188 self.l.setItemHeight(self.itemHeight) self.instance.resize(eSize(self.itemWidth+15, (self.listHeight / self.itemHeight) * self.itemHeight)) self.listHeight = self.instance.size().height() self.listWidth = self.instance.size().width()
def updateDescription(self): # print "[SF-Plugin] MovieSelection.updateDescription DescriptionBorder height =" + str(self["DescriptionBorder"].instance.size().height()) self["DescriptionBorder"].show() self["list"].instance.resize(eSize(self.listWidth, self.listHeight - self["DescriptionBorder"].instance.size().height()))
def resize(self, w, h): if config.av.pip_mode.value == 2: self.instance.resize(eSize(*(340, 264))) self["video"].instance.resize(eSize(*(340, 264))) self.setSizePosMainWindow(0, 142, 360, 284) return config.av.pip.value[2] = w config.av.pip.value[3] = h config.av.pip.save() if config.av.pip_mode.value == "standard": self.instance.resize(eSize(*(w, h))) self["video"].instance.resize(eSize(*(w, h))) self.setSizePosMainWindow() elif config.av.pip_mode.value == "cascade": self.instance.resize(eSize(*(w, h))) self["video"].instance.resize(eSize(*(w, h))) self.setSizePosMainWindow(0, h, MAX_X - w, MAX_Y - h) elif config.av.pip_mode.value == "split": self.instance.resize(eSize(*(MAX_X / 2, MAX_Y))) self["video"].instance.resize(eSize(*(MAX_X / 2, MAX_Y))) self.setSizePosMainWindow(0, 0, MAX_X / 2, MAX_Y) elif config.av.pip_mode.value == "byside": self.instance.resize(eSize(*(MAX_X / 2, MAX_Y / 2))) self["video"].instance.resize(eSize(*(MAX_X / 2, MAX_Y / 2))) self.setSizePosMainWindow(0, MAX_Y / 4, MAX_X / 2, MAX_Y / 2) elif config.av.pip_mode.value in "bigpig external": self.instance.resize(eSize(*(MAX_X, MAX_Y))) self["video"].instance.resize(eSize(*(MAX_X, MAX_Y))) self.setSizePosMainWindow()
def update(self): self.updateDynamicContent() height = self.instance.size().height() widths = [] # Set background transparency if not config.infobartunerstate.background_transparency.value: self["Background"].show() else: self["Background"].hide() self["Type"].hide() self["Progress"].hide() for i, c in enumerate( config.infobartunerstate.fields.dict().itervalues() ): fieldid = "Field"+str(i) field = c.value text = "" #print "IBTS DEBUG", self.plugin, field if field == "TypeIcon": self["Type"].show() if self.type == TIMER: self["Type"].setPixmapNum(3) elif self.type == RECORD: self["Type"].setPixmapNum(0) elif self.type == FINISHED: self["Type"].setPixmapNum(2) elif self.type == INFO: self["Type"].setPixmapNum(3) elif self.type == LIVE: self["Type"].setPixmapNum(4) elif self.type == UNKNOWN: self["Type"].setPixmapNum(5) elif self.type == STREAM: self["Type"].setPixmapNum(1) else: widths.append( 0 ) continue # No resize necessary widths.append( self.typewidth ) continue elif field == "TypeText": text = _( self.text ) elif field == "Tuner": if self.tuner: text = self.tuner elif field == "TunerType": if self.tunertype: text = self.tunertype elif field == "Number": if isinstance( self.number, int ): text = _("%d") % ( self.number ) elif isinstance( self.number, basestring ): text = self.number elif field == "Channel": text = self.channel elif field == "Name": text = self.name elif field == "TimeLeft": if self.endless: # Add infinity symbol for indefinitely recordings text = INFINITY elif isinstance( self.timeleft, int ): # Show timeleft recording time text = _("%d Min") % ( self.timeleft ) elif field == "TimeElapsed": if isinstance( self.timeelapsed, int ): text = _("%d Min") % ( self.timeelapsed ) elif field == "TimeLeftDuration": # Calculate timeleft minutes if self.endless: # Add infinity symbol for indefinitely recordings text = INFINITY elif self.type is FINISHED: if isinstance( self.duration, int ): text = _("%d Min") % ( self.duration ) elif isinstance( self.timeleft, int ): # Show timeleft recording time text = _("%d Min") % ( self.timeleft ) elif field == "Begin": lbegin = self.begin and localtime( self.begin ) text = lbegin and strftime( config.infobartunerstate.time_format_begin.value, lbegin ) elif field == "End": lend = self.end and localtime( self.end ) text = lend and strftime( config.infobartunerstate.time_format_end.value, lend ) elif field == "BeginEnd": if self.progress is None: lbegin = self.begin and localtime( self.begin ) text = lbegin and strftime( config.infobartunerstate.time_format_begin.value, lbegin ) elif self.progress > 0: lend = self.end and localtime( self.end ) text = lend and strftime( config.infobartunerstate.time_format_end.value, lend ) elif field == "Duration": if isinstance( self.duration, int ): text = _("%d Min") % ( self.duration ) elif field == "TimerProgressText": if isinstance( self.progress, int ): text = _("%d %%") % ( self.progress ) elif field == "TimerProgressGraphical": if self.progress is not None: self["Progress"].setValue( self.progress ) self["Progress"].show() # No resize necessary widths.append( self.progresswidth ) else: if not config.infobartunerstate.placeholder_pogressbar.value: widths.append( 0 ) else: widths.append( self.progresswidth ) continue elif field == "TimerDestination": text = self.destination elif field == "StreamClient": text = self.client or self.ip elif field == "StreamClientPort": if self.port: text = self.client or self.ip text += ":" + str(self.port) elif field == "DestinationStreamClient": text = self.destination or self.client or self.ip elif field == "FileSize": if isinstance( self.filesize, int ): text = _("%d MB") % ( self.filesize ) elif field == "FreeSpace": if isinstance( self.freespace, int ): text = _("%d GB") % ( self.freespace ) elif field == "None": # text is already initialized with "" pass # Set text, append field, resize field and append width self[fieldid].setText( text ) # Set horizontal alignment if field == 'Number' or field == 'TimeLeftDuration' or field == 'TimeLeft' or field == 'TimeElapsed' or field == 'Duration' or field == 'TimerProgressText' or field == 'FileSize' or field == 'FreeSpace': self[fieldid].instance.setHAlign(2) # import _enigma # alignRight = _enigma.eLabel_alignRight #Workaround#1 self[fieldid].instance.resize( eSize(1000, height) ) width = max(self[fieldid].instance.calculateSize().width(), 0) #print width #Workaround#2: Width calculation seems to be not enough width = int( width * 1.10 ) #Workaround#3: Calculation of left aligned fields seems to be broken if 0 < width and width < 30: width = 30 #print "IBTS Update", field, width, self[fieldid].instance.calculateSize().width() #self[fieldid].instance.resize( eSize(width, height) ) widths.append( width ) self.widths = widths
def resize(self, w, h): self.instance.resize(eSize(*(w, h))) self["label"].instance.resize(eSize(*(w, h)))
def calcMoving(self): self.X = self.Y = 0 if not (self.txtflags & RT_WRAP): self.txtext = self.txtext.replace("\xe0\x8a", " ").replace( chr(0x8A), " ").replace("\n", " ").replace("\r", " ") self.scroll_label.setText(self.txtext) if self.txtext == "" or \ self.type == NONE or \ self.scroll_label is None: return False if self.direction in (LEFT, RIGHT) or not (self.txtflags & RT_WRAP): self.scroll_label.resize( eSize(self.txfont.pointSize * len(self.txtext), self.H) ) # stupid workaround, have no better idea right now... text_size = self.scroll_label.calculateSize() text_width = text_size.width() text_height = text_size.height() if self.direction in (LEFT, RIGHT) or not (self.txtflags & RT_WRAP): text_width += 10 self.mStop = None # text height correction if necessary: if self.lineHeight and self.direction in (TOP, BOTTOM): text_height = max(text_height, (text_height + self.lineHeight - 1) / self.lineHeight * self.lineHeight) # self.type = 0 - NONE; 1 - RUNNING; 2 - SWIMMING; 3 - AUTO(???) # self.direction = 0 - LEFT; 1 - RIGHT; 2 - TOP; 3 - BOTTOM # self.halign = 0 - LEFT; 1 - RIGHT; 2 - CENTER; 3 - BLOCK if self.direction in (LEFT, RIGHT): if not self.mAlways and text_width <= self.W: return False if self.type == RUNNING: self.A = self.X - text_width - self.soffset[0] - abs( self.mStep) self.B = self.W - self.soffset[0] + abs(self.mStep) if self.direction == LEFT: self.mStep = -abs(self.mStep) self.mStop = self.X self.P = self.B else: self.mStep = abs(self.mStep) self.mStop = self.B - text_width + self.soffset[ 0] - self.mStep self.P = self.A if not self.mStartPoint is None: if self.direction == LEFT: self.mStop = self.P = max( self.A, min(self.W, self.mStartPoint)) else: self.mStop = self.P = max( self.A, min( self.B, self.mStartPoint - text_width + self.soffset[0])) elif self.type == SWIMMING: if text_width < self.W: self.A = self.X + 1 # incomprehensible indent '+ 1' ??? self.B = self.W - text_width - 1 # incomprehensible indent '- 1' ??? if self.halign == LEFT: self.P = self.A self.mStep = abs(self.mStep) elif self.halign == RIGHT: self.P = self.B self.mStep = -abs(self.mStep) else: # if self.halign in (CENTER, BLOCK): self.P = int(self.B / 2) self.mStep = (self.direction == RIGHT) and abs( self.mStep) or -abs(self.mStep) else: if text_width == self.W: text_width += max(2, text_width / 20) self.A = self.W - text_width self.B = self.X if self.halign == LEFT: self.P = self.B self.mStep = -abs(self.mStep) elif self.halign == RIGHT: self.P = self.A self.mStep = abs(self.mStep) else: # if self.halign in (CENTER, BLOCK): self.P = int(self.A / 2) self.mStep = (self.direction == RIGHT) and abs( self.mStep) or -abs(self.mStep) else: return False elif self.direction in (TOP, BOTTOM): if not self.mAlways and text_height <= self.H: return False if self.type == RUNNING: self.A = self.Y - text_height - self.soffset[1] - abs( self.mStep) self.B = self.H - self.soffset[1] + abs(self.mStep) if self.direction == TOP: self.mStep = -abs(self.mStep) self.mStop = self.Y self.P = self.B else: self.mStep = abs(self.mStep) self.mStop = self.B - text_height + self.soffset[ 1] - self.mStep self.P = self.A if not self.mStartPoint is None: if self.direction == TOP: self.mStop = self.P = max( self.A, min(self.H, self.mStartPoint)) else: self.mStop = self.P = max( self.A, min( self.B, self.mStartPoint - text_height + self.soffset[1])) elif self.type == SWIMMING: if text_height < self.H: self.A = self.Y self.B = self.H - text_height if self.direction == TOP: self.P = self.B self.mStep = -abs(self.mStep) else: self.P = self.A self.mStep = abs(self.mStep) else: if text_height == self.H: text_height += max(2, text_height / 40) self.A = self.H - text_height self.B = self.Y if self.direction == TOP: self.P = self.B self.mStep = -abs(self.mStep) self.mStop = self.B else: self.P = self.A self.mStep = abs(self.mStep) self.mStop = self.A else: return False else: return False self.xW = max(self.W, text_width) self.xH = max(self.H, text_height) self.scroll_label.resize(eSize(self.xW, self.xH)) if self.mStartDelay: if self.direction in (LEFT, RIGHT): self.moveLabel(self.P, self.Y) else: # if self.direction in (TOP,BOTTOM): self.moveLabel(self.X, self.P) self.mCount = self.mRepeat self.mTimer.start(self.mStartDelay, True) return True
def size(self, value): if isinstance(value, tuple): self.guiObject.resize(eSize(*value)) else: self.guiObject.resize(parseSize(value, self.scaleTuple, self.guiObject, self.desktop))
borderWidth = 3 else: borderWidth = int(borderwidth) face = eSubtitleWidget.__dict__[get_attr("name")] eSubtitleWidget.setFontStyle(face, font, haveColor, foregroundColor, borderColor, borderWidth) for windowstyle in skin.findall("windowstyle"): style = eWindowStyleSkinned() style_id = windowstyle.attrib.get("id") if style_id: style_id = int(style_id) else: style_id = 0 # defaults font = gFont("Regular", 20) offset = eSize(20, 5) for title in windowstyle.findall("title"): get_attr = title.attrib.get offset = parseSize(get_attr("offset"), ((1,1),(1,1))) font = parseFont(get_attr("font"), ((1,1),(1,1))) style.setTitleFont(font) style.setTitleOffset(offset) #print " ", font, offset for borderset in windowstyle.findall("borderset"): bsName = str(borderset.attrib.get("name")) for pixmap in borderset.findall("pixmap"): get_attr = pixmap.attrib.get bpName = get_attr("pos") filename = get_attr("filename") if filename and bpName:
def parseSize(s, scale, object = None, desktop = None): (x, y) = parseValuePair(s, scale, object, desktop) return eSize(x, y)
def __init__(self, session, filelist, index, path): self.textcolor = config.pic.textcolor.value self.bgcolor = config.pic.bgcolor.value space = config.pic.framesize.value self.size_w = size_w = getDesktop(0).size().width() self.size_h = size_h = getDesktop(0).size().height() if config.usage.pic_resolution.value and (size_w, size_h) != eval( config.usage.pic_resolution.value): (size_w, size_h) = eval(config.usage.pic_resolution.value) gMainDC.getInstance().setResolution(size_w, size_h) getDesktop(0).resize(eSize(size_w, size_h)) self.skin = "<screen position=\"0,0\" size=\"" + str( size_w ) + "," + str(size_h) + "\" flags=\"wfNoBorder\" > \ <eLabel position=\"0,0\" zPosition=\"0\" size=\"" + str(size_w) + "," + str( size_h ) + "\" backgroundColor=\"" + self.bgcolor + "\" /><widget name=\"pic\" position=\"" + str( space) + "," + str(space) + "\" size=\"" + str( size_w - (space * 2)) + "," + str( size_h - (space * 2) ) + "\" zPosition=\"1\" alphatest=\"on\" /> \ <widget name=\"point\" position=\"" + str(space + 5) + "," + str( space + 2 ) + "\" size=\"20,20\" zPosition=\"2\" pixmap=\"icons/record.png\" alphatest=\"on\" /> \ <widget name=\"play_icon\" position=\"" + str(space + 25) + "," + str( space + 2 ) + "\" size=\"20,20\" zPosition=\"2\" pixmap=\"icons/ico_mp_play.png\" alphatest=\"on\" /> \ <widget source=\"file\" render=\"Label\" position=\"" + str( space + 45 ) + "," + str(space) + "\" size=\"" + str( size_w - (space * 2) - 50 ) + ",25\" font=\"Regular;20\" borderWidth=\"1\" borderColor=\"#000000\" halign=\"left\" foregroundColor=\"" + self.textcolor + "\" zPosition=\"2\" noWrap=\"1\" transparent=\"1\" /></screen>" Screen.__init__(self, session) self["actions"] = ActionMap( [ "OkCancelActions", "ColorActions", "DirectionActions", "MovieSelectionActions" ], { "cancel": self.Exit, "green": self.PlayPause, "yellow": self.PlayPause, "blue": self.nextPic, "red": self.prevPic, "left": self.prevPic, "right": self.nextPic, "showEventInfo": self.StartExif, "contextMenu": self.KeyMenu, }, -1) self["point"] = Pixmap() self["pic"] = Pixmap() self["play_icon"] = Pixmap() self["file"] = StaticText(_("please wait, loading picture...")) self.old_index = 0 self.filelist = [] self.lastindex = index self.currPic = [] self.shownow = True self.dirlistcount = 0 for x in filelist: if len(filelist[0]) == 3: # orig. filelist if x[0][1] == False: self.filelist.append(path + x[0][0]) else: self.dirlistcount += 1 elif len(filelist[0]) == 2: # scanlist if x[0][1] == False: self.filelist.append(x[0][0]) else: self.dirlistcount += 1 else: # thumbnaillist self.filelist.append(x[T_FULL]) self.maxentry = len(self.filelist) - 1 self.index = index - self.dirlistcount if self.index < 0: self.index = 0 self.picload = ePicLoad() self.picload.PictureData.get().append(self.finish_decode) self.slideTimer = eTimer() self.slideTimer.callback.append(self.slidePic) self.oldref = None if self.maxentry >= 0: self.onLayoutFinish.append(self.setPicloadConf)
def loadSingleSkinData(desktop, skin, path_prefix): """loads skin data like colors, windowstyle etc.""" assert skin.tag == "skin", "root element in skin must be 'skin'!" for c in skin.findall("output"): id = c.attrib.get('id') if id: id = int(id) else: id = 0 if id == 0: # framebuffer for res in c.findall("resolution"): get_attr = res.attrib.get xres = get_attr("xres") if xres: xres = int(xres) else: xres = 720 yres = get_attr("yres") if yres: yres = int(yres) else: yres = 576 bpp = get_attr("bpp") if bpp: bpp = int(bpp) else: bpp = 32 #print "Resolution:", xres,yres,bpp from enigma import gMainDC gMainDC.getInstance().setResolution(xres, yres) desktop.resize(eSize(xres, yres)) if bpp != 32: # load palette (not yet implemented) pass if yres >= 1080: parameters["AutotimerEnabledIcon"] = (2, 1, 38, 36) parameters["AutotimerRecordIcon"] = (42, 5, 30, 30) parameters["ChoicelistDash"] = (0, 3, 1000, 30) parameters["ChoicelistName"] = (68, 3, 1000, 30) parameters["ChoicelistIcon"] = (7, 0, 52, 38) parameters["ConfigListSeperator"] = 300 parameters["DreamexplorerName"] = (62, 0, 1200, 38) parameters["DreamexplorerIcon"] = (15, 4, 30, 30) parameters["FileListName"] = (68, 4, 1000, 34) parameters["FileListIcon"] = (7, 4, 52, 37) parameters["FileListMultiName"] = (90, 3, 1000, 32) parameters["FileListMultiIcon"] = (45, 4, 30, 30) parameters["FileListMultiLock"] = (2, 0, 36, 36) parameters["HelpMenuListHlp"] = (0, 0, 900, 42) parameters["HelpMenuListExtHlp0"] = (0, 0, 900, 39) parameters["HelpMenuListExtHlp1"] = (0, 42, 900, 30) parameters["PartnerBoxEntryListName"] = (8, 2, 225, 38) parameters["PartnerBoxEntryListIP"] = (180, 2, 225, 38) parameters["PartnerBoxEntryListPort"] = (405, 2, 150, 38) parameters["PartnerBoxEntryListType"] = (615, 2, 150, 38) parameters["PartnerBoxTimerServicename"] = (0, 0, 45) parameters["PartnerBoxTimerName"] = (0, 42, 30) parameters["PartnerBoxE1TimerTime"] = (0, 78, 255, 30) parameters["PartnerBoxE1TimerState"] = (255, 78, 255, 30) parameters["PartnerBoxE2TimerTime"] = (0, 78, 225, 30) parameters["PartnerBoxE2TimerState"] = (225, 78, 225, 30) parameters["PartnerBoxE2TimerIcon"] = (1050, 8, 20, 20) parameters["PartnerBoxE2TimerIconRepeat"] = (1050, 38, 20, 20) parameters["PartnerBoxBouquetListName"] = (0, 0, 45) parameters["PartnerBoxChannelListName"] = (0, 0, 45) parameters["PartnerBoxChannelListTitle"] = (0, 42, 30) parameters["PartnerBoxChannelListTime"] = (0, 78, 225, 30) parameters["PicturePlayerThumb"] = (30, 285, 45, 300, 30, 25) parameters["PlayListName"] = (38, 2, 1000, 34) parameters["PlayListIcon"] = (7, 7, 24, 24) parameters["PluginBrowserName"] = (180, 8, 38) parameters["PluginBrowserDescr"] = (180, 42, 25) parameters["PluginBrowserIcon"] = (15, 8, 150, 60) parameters["PluginBrowserDownloadName"] = (120, 8, 38) parameters["PluginBrowserDownloadDescr"] = (120, 42, 25) parameters["PluginBrowserDownloadIcon"] = (15, 0, 90, 76) parameters["ServiceInfo"] = (0, 0, 450, 50) parameters["ServiceInfoLeft"] = (0, 0, 450, 45) parameters["ServiceInfoRight"] = (450, 0, 1000, 45) parameters["SelectionListDescr"] = (45, 3, 1000, 32) parameters["SelectionListLock"] = (0, 2, 36, 36) parameters["SelectionListLockOff"] = (0, 2, 36, 36) parameters["VirtualKeyboard"] = (68, 68) parameters["SHOUTcastListItem"] = (30, 27, 35, 96, 35, 33, 60, 32) parameters["EPGImportFilterListDescr"] = (30, 3, 500, 30) parameters["EPGImportFilterListLockOff"] = (0, 0, 30, 30) parameters["EPGImportFilterListLockOn"] = (0, 0, 30, 30) for skininclude in skin.findall("include"): filename = skininclude.attrib.get("filename") if filename: skinfile = resolveFilename(SCOPE_ACTIVE_SKIN, filename, path_prefix=path_prefix) if not fileExists(skinfile): skinfile = resolveFilename(SCOPE_SKIN_IMAGE, filename, path_prefix=path_prefix) if fileExists(skinfile): print "[Skin] Loading include:", skinfile loadSkin(skinfile) for c in skin.findall('switchpixmap'): for pixmap in c.findall('pixmap'): get_attr = pixmap.attrib.get name = get_attr('name') if not name: raise SkinError('[Skin] pixmap needs name attribute') filename = get_attr('filename') if not filename: raise SkinError('[Skin] pixmap needs filename attribute') resolved_png = resolveFilename(SCOPE_ACTIVE_SKIN, filename, path_prefix=path_prefix) if fileExists(resolved_png): switchPixmap[name] = LoadPixmap(resolved_png, cached=True) else: raise SkinError( '[Skin] switchpixmap pixmap filename="%s" (%s) not found' % (filename, resolved_png)) for c in skin.findall("colors"): for color in c.findall("color"): get_attr = color.attrib.get name = get_attr("name") color = get_attr("value") if name and color: colorNames[name] = parseColor(color) #print "Color:", name, color else: raise SkinError("[Skin] need color and name, got %s %s" % (name, color)) for c in skin.findall("fonts"): for font in c.findall("font"): get_attr = font.attrib.get filename = get_attr("filename", "<NONAME>") name = get_attr("name", "Regular") scale = get_attr("scale") if scale: scale = int(scale) else: scale = 100 is_replacement = get_attr("replacement") and True or False render = get_attr("render") if render: render = int(render) else: render = 0 resolved_font = resolveFilename(SCOPE_FONTS, filename, path_prefix=path_prefix) if not fileExists( resolved_font ): #when font is not available look at current skin path resolved_font = resolveFilename(SCOPE_ACTIVE_SKIN, filename) if fileExists(resolveFilename(SCOPE_CURRENT_SKIN, filename)): resolved_font = resolveFilename(SCOPE_CURRENT_SKIN, filename) elif fileExists(resolveFilename(SCOPE_ACTIVE_LCDSKIN, filename)): resolved_font = resolveFilename(SCOPE_ACTIVE_LCDSKIN, filename) addFont(resolved_font, name, scale, is_replacement, render) #print "Font: ", resolved_font, name, scale, is_replacement for alias in c.findall("alias"): get = alias.attrib.get try: name = get("name") font = get("font") size = int(get("size")) height = int(get("height", size)) # to be calculated some day width = int(get("width", size)) global fonts fonts[name] = (font, size, height, width) except Exception, ex: print "[Skin] Bad font alias", ex
def calcMoving(self): self.X = self.Y = 0 if not self.txtflags & RT_WRAP: self.txtext = self.txtext.replace('\xe0\x8a', ' ').replace( chr(138), ' ').replace('\n', ' ').replace('\r', ' ') self.scroll_label.setText(self.txtext) if self.txtext == '' or self.type == NONE or self.scroll_label is None: return False else: if self.direction in (LEFT, RIGHT) or not self.txtflags & RT_WRAP: self.scroll_label.resize( eSize(self.txfont.pointSize * len(self.txtext), self.H)) text_size = self.scroll_label.calculateSize() text_width = text_size.width() text_height = text_size.height() if self.direction in (LEFT, RIGHT) or not self.txtflags & RT_WRAP: text_width += 10 self.mStop = None if self.lineHeight and self.direction in (TOP, BOTTOM): text_height = max(text_height, (text_height + self.lineHeight - 1) / self.lineHeight * self.lineHeight) if self.direction in (LEFT, RIGHT): if not self.mAlways and text_width <= self.W: return False if self.type == RUNNING: self.A = self.X - text_width - self.soffset[0] - abs( self.mStep) self.B = self.W - self.soffset[0] + abs(self.mStep) if self.direction == LEFT: self.mStep = -abs(self.mStep) self.mStop = self.X self.P = self.B else: self.mStep = abs(self.mStep) self.mStop = self.B - text_width + self.soffset[ 0] - self.mStep self.P = self.A if self.mStartPoint is not None: if self.direction == LEFT: self.mStop = self.P = max( self.A, min(self.W, self.mStartPoint)) else: self.mStop = self.P = max( self.A, min( self.B, self.mStartPoint - text_width + self.soffset[0])) elif self.type == SWIMMING: if text_width < self.W: self.A = self.X + 1 self.B = self.W - text_width - 1 if self.halign == LEFT: self.P = self.A self.mStep = abs(self.mStep) elif self.halign == RIGHT: self.P = self.B self.mStep = -abs(self.mStep) else: self.P = int(self.B / 2) self.mStep = self.direction == RIGHT and abs( self.mStep) or -abs(self.mStep) else: if text_width == self.W: text_width += max(2, text_width / 20) self.A = self.W - text_width self.B = self.X if self.halign == LEFT: self.P = self.B self.mStep = -abs(self.mStep) elif self.halign == RIGHT: self.P = self.A self.mStep = abs(self.mStep) else: self.P = int(self.A / 2) self.mStep = self.direction == RIGHT and abs( self.mStep) or -abs(self.mStep) else: return False elif self.direction in (TOP, BOTTOM): if not self.mAlways and text_height <= self.H: return False if self.type == RUNNING: self.A = self.Y - text_height - self.soffset[1] - abs( self.mStep) self.B = self.H - self.soffset[1] + abs(self.mStep) if self.direction == TOP: self.mStep = -abs(self.mStep) self.mStop = self.Y self.P = self.B else: self.mStep = abs(self.mStep) self.mStop = self.B - text_height + self.soffset[ 1] - self.mStep self.P = self.A if self.mStartPoint is not None: if self.direction == TOP: self.mStop = self.P = max( self.A, min(self.H, self.mStartPoint)) else: self.mStop = self.P = max( self.A, min( self.B, self.mStartPoint - text_height + self.soffset[1])) elif self.type == SWIMMING: if text_height < self.H: self.A = self.Y self.B = self.H - text_height if self.direction == TOP: self.P = self.B self.mStep = -abs(self.mStep) else: self.P = self.A self.mStep = abs(self.mStep) else: if text_height == self.H: text_height += max(2, text_height / 40) self.A = self.H - text_height self.B = self.Y if self.direction == TOP: self.P = self.B self.mStep = -abs(self.mStep) self.mStop = self.B else: self.P = self.A self.mStep = abs(self.mStep) self.mStop = self.A else: return False else: return False self.xW = max(self.W, text_width) self.xH = max(self.H, text_height) self.scroll_label.resize(eSize(self.xW, self.xH)) if self.mStartDelay: if self.direction in (LEFT, RIGHT): self.moveLabel(self.P, self.Y) else: self.moveLabel(self.X, self.P) self.mCount = self.mRepeat self.mTimer.start(self.mStartDelay, True) return True
def loadSingleSkinData(desktop, screenID, domSkin, pathSkin, scope=SCOPE_CURRENT_SKIN): """Loads skin data like colors, windowstyle etc.""" assert domSkin.tag == "skin", "root element in skin must be 'skin'!" global colors, fonts, menus, parameters, setups, switchPixmap for tag in domSkin.findall("output"): scrnID = int(tag.attrib.get("id", GUI_SKIN_ID)) if scrnID == GUI_SKIN_ID: for res in tag.findall("resolution"): xres = res.attrib.get("xres") xres = int(xres) if xres else 720 yres = res.attrib.get("yres") yres = int(yres) if yres else 576 bpp = res.attrib.get("bpp") bpp = int(bpp) if bpp else 32 # print("[Skin] DEBUG: Resolution xres=%d, yres=%d, bpp=%d." % (xres, yres, bpp)) from enigma import gMainDC gMainDC.getInstance().setResolution(xres, yres) desktop.resize(eSize(xres, yres)) if bpp != 32: pass # Load palette (Not yet implemented!) for tag in domSkin.findall("include"): filename = tag.attrib.get("filename") if filename: filename = resolveFilename(scope, filename, path_prefix=pathSkin) if isfile(filename): loadSkin(filename, scope=scope, desktop=desktop, screenID=screenID) else: raise SkinError("Included file '%s' not found" % filename) for tag in domSkin.findall("switchpixmap"): for pixmap in tag.findall("pixmap"): name = pixmap.attrib.get("name") if not name: raise SkinError("Pixmap needs name attribute") filename = pixmap.attrib.get("filename") if not filename: raise SkinError("Pixmap needs filename attribute") resolved = resolveFilename(scope, filename, path_prefix=pathSkin) if isfile(resolved): switchPixmap[name] = LoadPixmap(resolved, cached=True) else: raise SkinError("The switchpixmap pixmap filename='%s' (%s) not found" % (filename, resolved)) for tag in domSkin.findall("colors"): for color in tag.findall("color"): name = color.attrib.get("name") color = color.attrib.get("value") if name and color: colors[name] = parseColor(color) # print("[Skin] DEBUG: Color name='%s', color='%s'." % (name, color)) else: raise SkinError("Tag 'color' needs a name and color, got name='%s' and color='%s'" % (name, color)) for tag in domSkin.findall("fonts"): for font in tag.findall("font"): filename = font.attrib.get("filename", "<NONAME>") name = font.attrib.get("name", "Regular") scale = font.attrib.get("scale") scale = int(scale) if scale else 100 isReplacement = font.attrib.get("replacement") and True or False render = font.attrib.get("render") if render: render = int(render) else: render = 0 filename = resolveFilename(SCOPE_FONTS, filename, path_prefix=pathSkin) if isfile(filename): addFont(filename, name, scale, isReplacement, render) # Log provided by C++ addFont code. # print("[Skin] Add font: Font path='%s', name='%s', scale=%d, isReplacement=%s, render=%d." % (filename, name, scale, isReplacement, render)) else: raise SkinError("Font file '%s' not found" % filename) fallbackFont = resolveFilename(SCOPE_FONTS, "fallback.font", path_prefix=pathSkin) if isfile(fallbackFont): addFont(fallbackFont, "Fallback", 100, -1, 0) # else: # As this is optional don't raise an error. # raise SkinError("Fallback font '%s' not found" % fallbackFont) for alias in tag.findall("alias"): try: name = alias.attrib.get("name") font = alias.attrib.get("font") size = int(alias.attrib.get("size")) height = int(alias.attrib.get("height", size)) # To be calculated some day. width = int(alias.attrib.get("width", size)) fonts[name] = (font, size, height, width) # print("[Skin] Add font alias: name='%s', font='%s', size=%d, height=%s, width=%d." % (name, font, size, height, width)) except Exception as err: raise SkinError("Bad font alias: '%s'" % str(err)) for tag in domSkin.findall("parameters"): for parameter in tag.findall("parameter"): try: name = parameter.attrib.get("name") value = parameter.attrib.get("value") parameters[name] = map(parseParameter, [x.strip() for x in value.split(",")]) if "," in value else parseParameter(value) except Exception as err: raise SkinError("Bad parameter: '%s'" % str(err)) for tag in domSkin.findall("menus"): for setup in tag.findall("menu"): key = setup.attrib.get("key") image = setup.attrib.get("image") if key and image: menus[key] = image # print("[Skin] DEBUG: Menu key='%s', image='%s'." % (key, image)) else: raise SkinError("Tag menu needs key and image, got key='%s' and image='%s'" % (key, image)) for tag in domSkin.findall("setups"): for setup in tag.findall("setup"): key = setup.attrib.get("key") image = setup.attrib.get("image") if key and image: setups[key] = image # print("[Skin] DEBUG: Setup key='%s', image='%s'." % (key, image)) else: raise SkinError("Tag setup needs key and image, got key='%s' and image='%s'" % (key, image)) for tag in domSkin.findall("constant-widgets"): for constant_widget in tag.findall("constant-widget"): name = constant_widget.attrib.get("name") if name: constantWidgets[name] = constant_widget for tag in domSkin.findall("variables"): for parameter in tag.findall("variable"): name = parameter.attrib.get("name") value = parameter.attrib.get("value") x, y = value.split(",") if value and name: variables[name] = "%s,%s" % (str(x), str(y)) for tag in domSkin.findall("subtitles"): from enigma import eSubtitleWidget scale = ((1, 1), (1, 1)) for substyle in tag.findall("sub"): font = parseFont(substyle.attrib.get("font"), scale) col = substyle.attrib.get("foregroundColor") if col: foregroundColor = parseColor(col) haveColor = 1 else: foregroundColor = gRGB(0xFFFFFF) haveColor = 0 col = substyle.attrib.get("borderColor") if col: borderColor = parseColor(col) else: borderColor = gRGB(0) borderwidth = substyle.attrib.get("borderWidth") if borderwidth is None: borderWidth = 3 # Default: Use a subtitle border. else: borderWidth = int(borderwidth) face = eSubtitleWidget.__dict__[substyle.attrib.get("name")] eSubtitleWidget.setFontStyle(face, font, haveColor, foregroundColor, borderColor, borderWidth) for tag in domSkin.findall("windowstyle"): style = eWindowStyleSkinned() scrnID = int(tag.attrib.get("id", GUI_SKIN_ID)) font = gFont("Regular", 20) # Default offset = eSize(20, 5) # Default for title in tag.findall("title"): offset = parseSize(title.attrib.get("offset"), ((1, 1), (1, 1))) font = parseFont(title.attrib.get("font"), ((1, 1), (1, 1))) style.setTitleFont(font) style.setTitleOffset(offset) # print("[Skin] DEBUG: WindowStyle font, offset - '%s' '%s'." % (str(font), str(offset))) for borderset in tag.findall("borderset"): bsName = str(borderset.attrib.get("name")) for pixmap in borderset.findall("pixmap"): bpName = pixmap.attrib.get("pos") filename = pixmap.attrib.get("filename") if filename and bpName: png = loadPixmap(resolveFilename(scope, filename, path_prefix=pathSkin), desktop) try: style.setPixmap(eWindowStyleSkinned.__dict__[bsName], eWindowStyleSkinned.__dict__[bpName], png) except Exception: pass # print("[Skin] DEBUG: WindowStyle borderset name, filename - '%s' '%s'." % (bpName, filename)) for color in tag.findall("color"): colorType = color.attrib.get("name") color = parseColor(color.attrib.get("color")) try: style.setColor(eWindowStyleSkinned.__dict__["col" + colorType], color) except Exception: raise SkinError("Unknown color type '%s'" % colorType) # print("[Skin] DEBUG: WindowStyle color type, color -" % (colorType, str(color))) x = eWindowStyleManager.getInstance() x.setStyle(scrnID, style) for tag in domSkin.findall("margin"): scrnID = int(tag.attrib.get("id", GUI_SKIN_ID)) r = eRect(0, 0, 0, 0) v = tag.attrib.get("left") if v: r.setLeft(int(v)) v = tag.attrib.get("top") if v: r.setTop(int(v)) v = tag.attrib.get("right") if v: r.setRight(int(v)) v = tag.attrib.get("bottom") if v: r.setBottom(int(v)) # The "desktop" parameter is hard-coded to the GUI screen, so we must ask # for the one that this actually applies to. getDesktop(scrnID).setMargins(r)
def applySkin(self, desktop, screen): def retValue(val, limit, default, Min=False): try: if Min: x = min(limit, int(val)) else: x = max(limit, int(val)) except: x = default return x def setWrapFlag(attrib, value): if (attrib.lower() == "wrap" and value == "0") or \ (attrib.lower() == "nowrap" and value != "0"): self.txtflags &= ~RT_WRAP else: self.txtflags |= RT_WRAP self.halign = valign = eLabel.alignLeft if self.skinAttributes: attribs = [] for (attrib, value) in self.skinAttributes: if attrib == "font": self.txfont = parseFont(value, ((1, 1), (1, 1))) elif attrib == "foregroundColor": self.scroll_label.setForegroundColor(parseColor(value)) elif attrib in ("shadowColor", "borderColor"): # fake for openpli-enigma2 self.scroll_label.setShadowColor(parseColor(value)) elif attrib == "shadowOffset": x, y = value.split(',') self.soffset = (int(x), int(y)) self.scroll_label.setShadowOffset(ePoint(self.soffset)) elif attrib == "borderWidth": # fake for openpli-enigma2 self.soffset = (-int(value), -int(value)) elif attrib == "valign" and value in ("top", "center", "bottom"): valign = { "top": eLabel.alignTop, "center": eLabel.alignCenter, "bottom": eLabel.alignBottom }[value] self.txtflags |= { "top": RT_VALIGN_TOP, "center": RT_VALIGN_CENTER, "bottom": RT_VALIGN_BOTTOM }[value] elif attrib == "halign" and value in ("left", "center", "right", "block"): self.halign = { "left": eLabel.alignLeft, "center": eLabel.alignCenter, "right": eLabel.alignRight, "block": eLabel.alignBlock }[value] self.txtflags |= { "left": RT_HALIGN_LEFT, "center": RT_HALIGN_CENTER, "right": RT_HALIGN_RIGHT, "block": RT_HALIGN_BLOCK }[value] elif attrib == "noWrap": setWrapFlag(attrib, value) elif attrib == "options": options = value.split(',') for o in options: if '=' in o: opt, val = (x.strip() for x in o.split('=', 1)) else: opt, val = o.strip(), "" if opt == "": continue elif opt in ("wrap", "nowrap"): setWrapFlag(opt, val) elif opt == "movetype" and val in ("none", "running", "swimming"): self.type = { "none": NONE, "running": RUNNING, "swimming": SWIMMING }[val] elif opt == "direction" and val in ("left", "right", "top", "bottom"): self.direction = { "left": LEFT, "right": RIGHT, "top": TOP, "bottom": BOTTOM }[val] elif opt == "step" and val: self.mStep = retValue(val, 1, self.mStep) elif opt == "steptime" and val: self.mStepTimeout = retValue( val, 25, self.mStepTimeout) elif opt == "startdelay" and val: self.mStartDelay = retValue( val, 0, self.mStartDelay) elif opt == "pause" and val: self.mLoopTimeout = retValue( val, 0, self.mLoopTimeout) elif opt == "oneshot" and val: self.mOneShot = retValue(val, 0, self.mOneShot) elif opt == "repeat" and val: self.mRepeat = retValue(val, 0, self.mRepeat) elif opt == "always" and val: self.mAlways = retValue(val, 0, self.mAlways) elif opt == "startpoint" and val: self.mStartPoint = int(val) elif opt == "pagedelay" and val: self.mPageDelay = retValue(val, 0, self.mPageDelay) elif opt == "pagelength" and val: self.mPageLength = retValue( val, 0, self.mPageLength) else: attribs.append((attrib, value)) if attrib == "backgroundColor": self.scroll_label.setBackgroundColor(parseColor(value)) elif attrib == "transparent": self.scroll_label.setTransparent(int(value)) self.skinAttributes = attribs ret = Renderer.applySkin(self, desktop, screen) if self.mOneShot: self.mOneShot = max(self.mStepTimeout, self.mOneShot) if self.mLoopTimeout: self.mLoopTimeout = max(self.mStepTimeout, self.mLoopTimeout) if self.mPageDelay: self.mPageDelay = max(self.mStepTimeout, self.mPageDelay) self.scroll_label.setFont(self.txfont) if not (self.txtflags & RT_WRAP): self.scroll_label.setNoWrap(1) self.scroll_label.setVAlign(valign) self.scroll_label.setHAlign(self.halign) self.scroll_label.move(ePoint(0, 0)) self.scroll_label.resize(eSize(self.W, self.H)) # test for auto correction text height: if self.direction in (TOP, BOTTOM): from enigma import fontRenderClass flh = int(fontRenderClass.getInstance().getLineHeight(self.txfont) or self.txfont.pointSize / 6 + self.txfont.pointSize) self.scroll_label.setText("WQq") if flh > self.scroll_label.calculateSize().height(): self.lineHeight = flh self.scroll_label.setText("") return ret
def loadSingleSkinData(desktop, skin, path_prefix): """loads skin data like colors, windowstyle etc.""" assert skin.tag == "skin", "root element in skin must be 'skin'!" for c in skin.findall("output"): id = c.attrib.get('id') if id: id = int(id) else: id = 0 if id == 0: # framebuffer for res in c.findall("resolution"): get_attr = res.attrib.get xres = get_attr("xres") if xres: xres = int(xres) else: xres = 720 yres = get_attr("yres") if yres: yres = int(yres) else: yres = 576 bpp = get_attr("bpp") if bpp: bpp = int(bpp) else: bpp = 32 #print "Resolution:", xres,yres,bpp from enigma import gMainDC gMainDC.getInstance().setResolution(xres, yres) desktop.resize(eSize(xres, yres)) if bpp != 32: # load palette (not yet implemented) pass for skininclude in skin.findall("include"): filename = skininclude.attrib.get("filename") if filename: skinfile = resolveFilename(SCOPE_ACTIVE_SKIN, filename, path_prefix=path_prefix) if not fileExists(skinfile): skinfile = resolveFilename(SCOPE_SKIN_IMAGE, filename, path_prefix=path_prefix) if fileExists(skinfile): print "[SKIN] loading include:", skinfile loadSkin(skinfile) for c in skin.findall("colors"): for color in c.findall("color"): get_attr = color.attrib.get name = get_attr("name") color = get_attr("value") if name and color: colorNames[name] = parseColor(color) if color[0] != '#': for key in colorNames: if key == color: colorNamesHuman[name] = colorNamesHuman[key] break else: humancolor = color[1:] if len(humancolor) >= 6: colorNamesHuman[name] = int(humancolor,16) else: print("need color and name, got %s %s" % (name, color)) for c in skin.findall("fonts"): for font in c.findall("font"): get_attr = font.attrib.get filename = get_attr("filename", "<NONAME>") name = get_attr("name", "Regular") scale = get_attr("scale") if scale: scale = int(scale) else: scale = 100 is_replacement = get_attr("replacement") and True or False render = get_attr("render") if render: render = int(render) else: render = 0 resolved_font = resolveFilename(SCOPE_FONTS, filename, path_prefix=path_prefix) if not fileExists(resolved_font): #when font is not available look at current skin path resolved_font = resolveFilename(SCOPE_ACTIVE_SKIN, filename) if fileExists(resolveFilename(SCOPE_CURRENT_SKIN, filename)): resolved_font = resolveFilename(SCOPE_CURRENT_SKIN, filename) elif fileExists(resolveFilename(SCOPE_ACTIVE_LCDSKIN, filename)): resolved_font = resolveFilename(SCOPE_ACTIVE_LCDSKIN, filename) addFont(resolved_font, name, scale, is_replacement, render) #print "Font: ", resolved_font, name, scale, is_replacement for alias in c.findall("alias"): get = alias.attrib.get try: name = get("name") font = get("font") size = int(get("size")) height = int(get("height", size)) # to be calculated some day width = int(get("width", size)) global fonts fonts[name] = (font, size, height, width) except Exception, ex: print "[SKIN] bad font alias", ex
def loadSingleSkinData(desktop, screenID, domSkin, pathSkin, scope=SCOPE_CURRENT_SKIN): """Loads skin data like colors, windowstyle etc.""" assert domSkin.tag == "skin", "root element in skin must be 'skin'!" global colors, fonts, menus, parameters, setups, switchPixmap for tag in domSkin.findall("output"): scrnID = int(tag.attrib.get("id", GUI_SKIN_ID)) if scrnID == GUI_SKIN_ID: for res in tag.findall("resolution"): xres = res.attrib.get("xres") xres = int(xres) if xres else 720 yres = res.attrib.get("yres") yres = int(yres) if yres else 576 bpp = res.attrib.get("bpp") bpp = int(bpp) if bpp else 32 # print("[Skin] DEBUG: Resolution xres=%d, yres=%d, bpp=%d." % (xres, yres, bpp)) from enigma import gMainDC gMainDC.getInstance().setResolution(xres, yres) desktop.resize(eSize(xres, yres)) if bpp != 32: pass # Load palette (Not yet implemented!) if yres >= 1080: parameters["AutotimerEnabledIcon"] = (2, 1, 38, 36) parameters["AutotimerRecordIcon"] = (42, 5, 30, 30) parameters["ChoicelistDash"] = (0, 3, 1000, 30) parameters["ChoicelistIcon"] = (7, 0, 52, 38) parameters["ChoicelistName"] = (68, 3, 1000, 30) parameters["ConfigListSeperator"] = 300 parameters["DreamexplorerIcon"] = (15, 4, 30, 30) parameters["DreamexplorerName"] = (62, 0, 1200, 38) parameters["EPGImportFilterListDescr"] = (30, 3, 500, 30) parameters["EPGImportFilterListLockOff"] = (0, 0, 30, 30) parameters["EPGImportFilterListLockOn"] = (0, 0, 30, 30) parameters["ExpandableListCategory"] = (60, 0, 655, 38) parameters["ExpandableListIcon"] = (5, 0, 45, 38) parameters["ExpandableListItem"] = (105, 0, 620, 38) parameters["ExpandableListLock"] = (60, 1, 38, 36) parameters["FileListIcon"] = (7, 4, 52, 37) parameters["FileListMultiIcon"] = (45, 4, 30, 30) parameters["FileListMultiLock"] = (2, 0, 36, 36) parameters["FileListMultiName"] = (90, 3, 1000, 32) parameters["FileListName"] = (68, 4, 1000, 34) parameters["HelpMenuListExtHlp0"] = (0, 0, 900, 39) parameters["HelpMenuListExtHlp1"] = (0, 42, 900, 30) parameters["HelpMenuListHlp"] = (0, 0, 900, 42) parameters["PartnerBoxBouquetListName"] = (0, 0, 45) parameters["PartnerBoxChannelListName"] = (0, 0, 45) parameters["PartnerBoxChannelListTime"] = (0, 78, 225, 30) parameters["PartnerBoxChannelListTitle"] = (0, 42, 30) parameters["PartnerBoxE1TimerState"] = (255, 78, 255, 30) parameters["PartnerBoxE1TimerTime"] = (0, 78, 255, 30) parameters["PartnerBoxE2TimerIcon"] = (1050, 8, 20, 20) parameters["PartnerBoxE2TimerIconRepeat"] = (1050, 38, 20, 20) parameters["PartnerBoxE2TimerState"] = (225, 78, 225, 30) parameters["PartnerBoxE2TimerTime"] = (0, 78, 225, 30) parameters["PartnerBoxEntryListIP"] = (180, 2, 225, 38) parameters["PartnerBoxEntryListName"] = (8, 2, 225, 38) parameters["PartnerBoxEntryListPort"] = (405, 2, 150, 38) parameters["PartnerBoxEntryListType"] = (615, 2, 150, 38) parameters["PartnerBoxTimerName"] = (0, 42, 30) parameters["PartnerBoxTimerServicename"] = (0, 0, 45) parameters["PicturePlayerThumb"] = (30, 285, 45, 300, 30, 25) parameters["PlayListIcon"] = (7, 7, 24, 24) parameters["PlayListName"] = (38, 2, 1000, 34) parameters["PluginBrowserDescr"] = (180, 42, 25) parameters["PluginBrowserDownloadDescr"] = (120, 42, 25) parameters["PluginBrowserDownloadIcon"] = (15, 0, 90, 76) parameters["PluginBrowserDownloadName"] = (120, 8, 38) parameters["PluginBrowserIcon"] = (15, 8, 150, 60) parameters["PluginBrowserName"] = (180, 8, 38) parameters["SHOUTcastListItem"] = (30, 27, 35, 96, 35, 33, 60, 32) parameters["SelectionListDescr"] = (45, 3, 1000, 32) parameters["SelectionListLock"] = (0, 2, 36, 36) parameters["SelectionListLockOff"] = (0, 2, 36, 36) parameters["ServiceInfo"] = (0, 0, 450, 50) parameters["ServiceInfoLeft"] = (0, 0, 450, 45) parameters["ServiceInfoRight"] = (450, 0, 1000, 45) parameters["VirtualKeyBoard"] = (68, 68) parameters["VirtualKeyBoardAlignment"] = (0, 0) parameters["VirtualKeyBoardPadding"] = (7, 7) parameters["VirtualKeyBoardShiftColors"] = (0x00ffffff, 0x00ffffff, 0x0000ffff, 0x00ff00ff) for tag in domSkin.findall("include"): filename = tag.attrib.get("filename") if filename: filename = resolveFilename(scope, filename, path_prefix=pathSkin) if isfile(filename): loadSkin(filename, scope=scope, desktop=desktop, screenID=screenID) else: raise SkinError("Included file '%s' not found" % filename) for tag in domSkin.findall("switchpixmap"): for pixmap in tag.findall("pixmap"): name = pixmap.attrib.get("name") if not name: raise SkinError("Pixmap needs name attribute") filename = pixmap.attrib.get("filename") if not filename: raise SkinError("Pixmap needs filename attribute") resolved = resolveFilename(scope, filename, path_prefix=pathSkin) if isfile(resolved): switchPixmap[name] = LoadPixmap(resolved, cached=True) else: raise SkinError("The switchpixmap pixmap filename='%s' (%s) not found" % (filename, resolved)) for tag in domSkin.findall("colors"): for color in tag.findall("color"): name = color.attrib.get("name") color = color.attrib.get("value") if name and color: colors[name] = parseColor(color) # print("[Skin] DEBUG: Color name='%s', color='%s'." % (name, color)) else: raise SkinError("Tag 'color' needs a name and color, got name='%s' and color='%s'" % (name, color)) for tag in domSkin.findall("fonts"): for font in tag.findall("font"): filename = font.attrib.get("filename", "<NONAME>") name = font.attrib.get("name", "Regular") scale = font.attrib.get("scale") scale = int(scale) if scale else 100 isReplacement = font.attrib.get("replacement") and True or False render = font.attrib.get("render") if render: render = int(render) else: render = 0 filename = resolveFilename(SCOPE_FONTS, filename, path_prefix=pathSkin) if isfile(filename): addFont(filename, name, scale, isReplacement, render) # Log provided by C++ addFont code. # print("[Skin] Add font: Font path='%s', name='%s', scale=%d, isReplacement=%s, render=%d." % (filename, name, scale, isReplacement, render)) else: raise SkinError("Font file '%s' not found" % filename) fallbackFont = resolveFilename(SCOPE_FONTS, "fallback.font", path_prefix=pathSkin) if isfile(fallbackFont): addFont(fallbackFont, "Fallback", 100, -1, 0) # else: # As this is optional don't raise an error. # raise SkinError("Fallback font '%s' not found" % fallbackFont) for alias in tag.findall("alias"): try: name = alias.attrib.get("name") font = alias.attrib.get("font") size = int(alias.attrib.get("size")) height = int(alias.attrib.get("height", size)) # To be calculated some day. width = int(alias.attrib.get("width", size)) fonts[name] = (font, size, height, width) # print("[Skin] Add font alias: name='%s', font='%s', size=%d, height=%s, width=%d." % (name, font, size, height, width)) except Exception as err: raise SkinError("Bad font alias: '%s'" % str(err)) for tag in domSkin.findall("parameters"): for parameter in tag.findall("parameter"): try: name = parameter.attrib.get("name") value = parameter.attrib.get("value") parameters[name] = map(parseParameter, [x.strip() for x in value.split(",")]) if "," in value else parseParameter(value) except Exception as err: raise SkinError("Bad parameter: '%s'" % str(err)) for tag in domSkin.findall("menus"): for setup in tag.findall("menu"): key = setup.attrib.get("key") image = setup.attrib.get("image") if key and image: menus[key] = image # print("[Skin] DEBUG: Menu key='%s', image='%s'." % (key, image)) else: raise SkinError("Tag menu needs key and image, got key='%s' and image='%s'" % (key, image)) for tag in domSkin.findall("setups"): for setup in tag.findall("setup"): key = setup.attrib.get("key") image = setup.attrib.get("image") if key and image: setups[key] = image # print("[Skin] DEBUG: Setup key='%s', image='%s'." % (key, image)) else: raise SkinError("Tag setup needs key and image, got key='%s' and image='%s'" % (key, image)) for tag in domSkin.findall("subtitles"): from enigma import eSubtitleWidget scale = ((1, 1), (1, 1)) for substyle in tag.findall("sub"): font = parseFont(substyle.attrib.get("font"), scale) col = substyle.attrib.get("foregroundColor") if col: foregroundColor = parseColor(col) haveColor = 1 else: foregroundColor = gRGB(0xFFFFFF) haveColor = 0 col = substyle.attrib.get("borderColor") if col: borderColor = parseColor(col) else: borderColor = gRGB(0) borderwidth = substyle.attrib.get("borderWidth") if borderwidth is None: borderWidth = 3 # Default: Use a subtitle border. else: borderWidth = int(borderwidth) face = eSubtitleWidget.__dict__[substyle.attrib.get("name")] eSubtitleWidget.setFontStyle(face, font, haveColor, foregroundColor, borderColor, borderWidth) for tag in domSkin.findall("windowstyle"): style = eWindowStyleSkinned() scrnID = int(tag.attrib.get("id", GUI_SKIN_ID)) font = gFont("Regular", 20) # Default offset = eSize(20, 5) # Default for title in tag.findall("title"): offset = parseSize(title.attrib.get("offset"), ((1, 1), (1, 1))) font = parseFont(title.attrib.get("font"), ((1, 1), (1, 1))) style.setTitleFont(font) style.setTitleOffset(offset) # print("[Skin] DEBUG: WindowStyle font, offset - '%s' '%s'." % (str(font), str(offset))) for borderset in tag.findall("borderset"): bsName = str(borderset.attrib.get("name")) for pixmap in borderset.findall("pixmap"): bpName = pixmap.attrib.get("pos") filename = pixmap.attrib.get("filename") if filename and bpName: png = loadPixmap(resolveFilename(scope, filename, path_prefix=pathSkin), desktop) try: style.setPixmap(eWindowStyleSkinned.__dict__[bsName], eWindowStyleSkinned.__dict__[bpName], png) except Exception: pass # print("[Skin] DEBUG: WindowStyle borderset name, filename - '%s' '%s'." % (bpName, filename)) for color in tag.findall("color"): colorType = color.attrib.get("name") color = parseColor(color.attrib.get("color")) try: style.setColor(eWindowStyleSkinned.__dict__["col" + colorType], color) except Exception: raise SkinError("Unknown color type '%s'" % colorType) # print("[Skin] DEBUG: WindowStyle color type, color -" % (colorType, str(color))) x = eWindowStyleManager.getInstance() x.setStyle(scrnID, style) for tag in domSkin.findall("margin"): scrnID = int(tag.attrib.get("id", GUI_SKIN_ID)) r = eRect(0, 0, 0, 0) v = tag.attrib.get("left") if v: r.setLeft(int(v)) v = tag.attrib.get("top") if v: r.setTop(int(v)) v = tag.attrib.get("right") if v: r.setRight(int(v)) v = tag.attrib.get("bottom") if v: r.setBottom(int(v)) # The "desktop" parameter is hard-coded to the GUI screen, so we must ask # for the one that this actually applies to. getDesktop(scrnID).setMargins(r)
def layoutFinished(self): if not self["videofps"].text: self.instance.resize(eSize(self.instance.size().width(), self["config"].l.getItemSize().height()*len(self["config"].getList()) + 10))
def applySkin(self, desktop, screen): def retValue(val, limit, default, Min=False): try: if Min: x = min(limit, int(val)) else: x = max(limit, int(val)) except: x = default return x self.halign = valign = eLabel.alignLeft if self.skinAttributes: attribs = [ ] for (attrib, value) in self.skinAttributes: if attrib == "font": self.txfont = parseFont(value, ((1,1),(1,1))) elif attrib == "foregroundColor": self.fcolor = parseColor(value) elif attrib == "backgroundColor": self.bcolor = parseColor(value) elif attrib == "shadowColor": self.scolor = parseColor(value) elif attrib == "shadowOffset": x, y = value.split(',') self.soffset = (int(x),int(y)) elif attrib == "valign" and value in ("top","center","bottom"): valign = { "top": eLabel.alignTop, "center": eLabel.alignCenter, "bottom": eLabel.alignBottom }[value] self.txtflags |= { "top": RT_VALIGN_TOP, "center": RT_VALIGN_CENTER, "bottom": RT_VALIGN_BOTTOM }[value] elif attrib == "halign" and value in ("left","center","right","block"): self.halign = { "left": eLabel.alignLeft, "center": eLabel.alignCenter, "right": eLabel.alignRight, "block": eLabel.alignBlock }[value] self.txtflags |= { "left": RT_HALIGN_LEFT, "center": RT_HALIGN_CENTER, "right": RT_HALIGN_RIGHT, "block": RT_HALIGN_BLOCK }[value] elif attrib == "noWrap": if value == "0": self.txtflags |= RT_WRAP else: self.txtflags &= ~RT_WRAP elif attrib == "options": options = value.split(',') for opt in options: val = '' pos = opt.find('=') if pos != -1: val = opt[pos+1:].strip() opt = opt[:pos].strip() if opt == "wrap": if val == "0": self.txtflags &= ~RT_WRAP else: self.txtflags |= RT_WRAP elif opt == "nowrap": if val == "0": self.txtflags |= RT_WRAP else: self.txtflags &= ~RT_WRAP elif opt == "movetype" and val in ("none","running","swimming"): self.type = {"none": NONE, "running": RUNNING, "swimming": SWIMMING}[val] elif opt =="direction" and val in ("left","right","top","bottom"): self.direction = { "left": LEFT, "right": RIGHT, "top": TOP, "bottom": BOTTOM }[val] elif opt == "step" and val: #retValue(val, limit, default, Min=False) self.mStep = retValue(val, 1, self.mStep) elif opt == "steptime" and val: self.mStepTimeout = retValue(val, 25, self.mStepTimeout) elif opt == "startdelay" and val: self.mStartDelay = retValue(val, 0, self.mStartDelay) elif opt == "pause" and val: self.mLoopTimeout = retValue(val, 0, self.mLoopTimeout) elif opt == "oneshot" and val: self.mOneShot = retValue(val, 0, self.mOneShot) elif opt =="repeat" and val: self.mRepeat = retValue(val, 0, self.mRepeat) elif opt =="always" and val: self.mAlways = retValue(val, 0, self.mAlways) elif opt =="startpoint" and val: self.mStartPoint = int(val) else: attribs.append((attrib,value)) self.skinAttributes = attribs ret = Renderer.applySkin(self, desktop, screen) #if self.type == RUNNING and self.direction in (LEFT,RIGHT): # self.halign = eLabel.alignLeft # self.txtflags = RT_HALIGN_LEFT | (self.txtflags & RT_WRAP) if self.mOneShot: self.mOneShot = max(self.mStepTimeout, self.mOneShot) if self.mLoopTimeout: self.mLoopTimeout = max(self.mStepTimeout, self.mLoopTimeout) self.test_label.setFont(self.txfont) #self.test_label.setForegroundColor(self.fcolor) #self.test_label.setBackgroundColor(self.bcolor) #if not self.scolor is None: # self.test_label.setShadowColor(self.scolor) # self.test_label.setShadowOffset(ePoint(self.soffset[0], self.soffset[1])) if not (self.txtflags & RT_WRAP): self.test_label.setNoWrap(1) self.test_label.setVAlign(valign) self.test_label.setHAlign(self.halign) self.test_label.move( ePoint(self.W,self.H) ) self.test_label.resize( eSize(self.W,self.H) ) #self.test_label.hide() #self.changed((self.CHANGED_DEFAULT,)) return ret
def reorder(self, widths, overwidth=0): # Get initial padding / offset position and apply user offset padding = self.padding + int(config.infobartunerstate.offset_padding.value) #print "IBTS px, self.padding, config.padding", px, self.padding, int(config.infobartunerstate.offset_padding.value) # Calculate field spacing spacing = self.spacing + int(config.infobartunerstate.offset_spacing.value) #print "IBTS spacing, self.spaceing, config.spacing", spacing, self.spacing, int(config.infobartunerstate.offset_spacing.value) px = padding py = 0 sh = self.instance.size().height() #print self.widths fieldwidths = config.infobartunerstate.fieldswidth.dict().values() for i, (c, width) in enumerate( zip( config.infobartunerstate.fields.dict().values(), widths ) ): fieldid = "Field"+str(i) field = c.value if field == "TypeIcon": self["Type"].instance.move( ePoint(px, py) ) elif field == "TimerProgressGraphical": #self[field].instance.resize( eSize(width, sh) ) # Center the progress field vertically y = int( ( sh - self["Progress"].instance.size().height() ) / 2 ) self["Progress"].instance.move( ePoint(px, y) ) elif field == "Name": if config.infobartunerstate.variable_field_width.value: width -= max(0, overwidth) else: width -= overwidth self[fieldid].instance.resize( eSize(width, sh) ) self[fieldid].instance.move( ePoint(px, py) ) #elif field == "None": # pass else: self[fieldid].instance.resize( eSize(width, sh) ) self[fieldid].instance.move( ePoint(px, py) ) #TODO I think we could simplify this # Avoid unnecesarry resize and move operations #for j, fieldwidth in enumerate( config.infobartunerstate.fieldswidth.dict().values() ): # if i == j and int(fieldwidth.value) > 0 and not (field == "TimerProgressGraphical" or field == "TypeIcon" or field == "None"): if fieldwidths: fieldwidth = int( fieldwidths[i].value ) if fieldwidth > 0 and not (field == "TimerProgressGraphical" or field == "TypeIcon" or field == "None"): # Handle new maximum width if width > 0: overwidth += fieldwidth - width else: overwidth += fieldwidth - width + spacing width = fieldwidth self[fieldid].instance.resize( eSize(width, sh) ) self[fieldid].instance.move( ePoint(px, py) ) if width: px += width + spacing # Set background bw = self["Background"].instance.size().width() # Avoid background start position is within our window bw = px-bw if px-bw<0 else 0 self["Background"].instance.move( ePoint(bw, py) ) self.instance.resize( eSize(px, sh) )
def loadSingleSkinData(desktop, skin, path_prefix): """loads skin data like colors, windowstyle etc.""" assert skin.tag == "skin", "root element in skin must be 'skin'!" for c in skin.findall("output"): id = c.attrib.get('id') if id: id = int(id) else: id = 0 if id == 0: # framebuffer for res in c.findall("resolution"): get_attr = res.attrib.get xres = get_attr("xres") if xres: xres = int(xres) else: xres = 720 yres = get_attr("yres") if yres: yres = int(yres) else: yres = 576 bpp = get_attr("bpp") if bpp: bpp = int(bpp) else: bpp = 32 #print "Resolution:", xres,yres,bpp from enigma import gMainDC gMainDC.getInstance().setResolution(xres, yres) desktop.resize(eSize(xres, yres)) if bpp != 32: # load palette (not yet implemented) pass for skininclude in skin.findall("include"): filename = skininclude.attrib.get("filename") if filename: skinfile = resolveFilename(SCOPE_ACTIVE_SKIN, filename, path_prefix=path_prefix) if not fileExists(skinfile): skinfile = resolveFilename(SCOPE_SKIN_IMAGE, filename, path_prefix=path_prefix) if fileExists(skinfile): print "[SKIN] loading include:", skinfile loadSkin(skinfile) for c in skin.findall("colors"): for color in c.findall("color"): get_attr = color.attrib.get name = get_attr("name") color = get_attr("value") if name and color: colorNames[name] = parseColor(color) #print "Color:", name, color else: raise SkinError("need color and name, got %s %s" % (name, color)) for c in skin.findall("parameters"): for parameter in c.findall("parameter"): get = parameter.attrib.get try: name = get("name") value = get("value") if name.find('Font') != -1: font = value.split(";") if isinstance(font, list) and len(font) == 2: parameters[name] = (str(font[0]), int(font[1])) else: parameters[name] = map(int, value.split(",")) except Exception, ex: print "[SKIN] bad parameter", ex
def applySkin(self, desktop, parent): scrollbarWidth = 10 itemHeight = 30 scrollbarBorderWidth = 1 ret = False if self.skinAttributes: widget_attribs = [] scrollbar_attribs = [] remove_attribs = [] for attrib, value in self.skinAttributes: if 'itemHeight' in attrib: itemHeight = int(value) remove_attribs.append((attrib, value)) if 'scrollbarMode' in attrib: self.scrollbarmode = value remove_attribs.append((attrib, value)) if 'borderColor' in attrib or 'borderWidth' in attrib: scrollbar_attribs.append((attrib, value)) if 'transparent' in attrib or 'backgroundColor' in attrib: widget_attribs.append((attrib, value)) if 'scrollbarSliderForegroundColor' in attrib: scrollbar_attribs.append((attrib, value)) remove_attribs.append((attrib, value)) if 'scrollbarSliderBorderColor' in attrib: scrollbar_attribs.append((attrib, value)) remove_attribs.append((attrib, value)) if 'scrollbarSliderPicture' in attrib: scrollbar_attribs.append((attrib, value)) remove_attribs.append((attrib, value)) if 'scrollbarBackgroundPicture' in attrib: scrollbar_attribs.append((attrib, value)) remove_attribs.append((attrib, value)) if 'scrollbarWidth' in attrib: scrollbarWidth = int(value) remove_attribs.append((attrib, value)) if 'scrollbarSliderBorderWidth' in attrib: scrollbarBorderWidth = int(value) remove_attribs.append((attrib, value)) if 'split' in attrib: self.split = int(value) if self.split: self.right_text = eLabel(self.instance) self.skinAttributes.remove((attrib, value)) if 'colposition' in attrib: self.column = int(value) if 'dividechar' in attrib: self.splitchar = value for attrib, value in remove_attribs: self.skinAttributes.remove((attrib, value)) if self.split: skin.applyAllAttributes( self.long_text, desktop, self.skinAttributes + [('halign', 'left')], parent.scale) skin.applyAllAttributes( self.right_text, desktop, self.skinAttributes + [('transparent', '1'), ('halign', 'left' if self.column else 'right')], parent.scale) else: skin.applyAllAttributes(self.long_text, desktop, self.skinAttributes, parent.scale) skin.applyAllAttributes(self.instance, desktop, widget_attribs, parent.scale) skin.applyAllAttributes(self.scrollbar, desktop, scrollbar_attribs + widget_attribs, parent.scale) ret = True self.pageWidth = self.long_text.size().width() self.lineheight = fontRenderClass.getInstance().getLineHeight( self.long_text.getFont()) or itemHeight lines = int(self.long_text.size().height() / self.lineheight) self.pageHeight = int(lines * self.lineheight) self.instance.move(self.long_text.position()) self.instance.resize( eSize(self.pageWidth, self.pageHeight + int(self.lineheight / 6))) self.scrollbar.move(ePoint(self.pageWidth - scrollbarWidth, 0)) self.scrollbar.resize( eSize(scrollbarWidth, self.pageHeight + int(self.lineheight / 6))) self.scrollbar.setOrientation(eSlider.orVertical) self.scrollbar.setRange(0, 100) self.scrollbar.setBorderWidth(scrollbarBorderWidth) self.setText(self.message) return ret
def parseSize(str): x, y = str.split(',') return eSize(int(x), int(y))
def parseSize(self, str): ( x, y, ) = str.split(',') return eSize(int(x), int(y))
def applySkin(self, desktop, parent): scrollbarWidth = 10 itemHeight = 30 scrollbarBorderWidth = 1 ret = False if self.skinAttributes: widget_attribs = [] scrollbar_attribs = [] remove_attribs = [] for (attrib, value) in self.skinAttributes: if "itemHeight" in attrib: itemHeight = int(value) remove_attribs.append((attrib, value)) if "scrollbarMode" in attrib: self.scrollbarmode = value remove_attribs.append((attrib, value)) if "borderColor" in attrib or "borderWidth" in attrib: scrollbar_attribs.append((attrib, value)) if "transparent" in attrib or "backgroundColor" in attrib: widget_attribs.append((attrib, value)) if "scrollbarSliderForegroundColor" in attrib: scrollbar_attribs.append((attrib, value)) remove_attribs.append((attrib, value)) if "scrollbarSliderBorderColor" in attrib: scrollbar_attribs.append((attrib, value)) remove_attribs.append((attrib, value)) if "scrollbarSliderPicture" in attrib: scrollbar_attribs.append((attrib, value)) remove_attribs.append((attrib, value)) if "scrollbarBackgroundPicture" in attrib: scrollbar_attribs.append((attrib, value)) remove_attribs.append((attrib, value)) if "scrollbarWidth" in attrib: scrollbarWidth = int(value) remove_attribs.append((attrib, value)) if "scrollbarSliderBorderWidth" in attrib: scrollbarBorderWidth = int(value) remove_attribs.append((attrib, value)) if "split" in attrib: self.split = int(value) if self.split: self.right_text = eLabel(self.instance) self.skinAttributes.remove((attrib, value)) if "colposition" in attrib: self.column = int(value) if "dividechar" in attrib: self.splitchar = value for (attrib, value) in remove_attribs: self.skinAttributes.remove((attrib, value)) if self.split: skin.applyAllAttributes( self.long_text, desktop, self.skinAttributes + [("halign", "left")], parent.scale) skin.applyAllAttributes( self.right_text, desktop, self.skinAttributes + [("transparent", "1"), ("halign", "left" if self.column else "right")], parent.scale) else: skin.applyAllAttributes(self.long_text, desktop, self.skinAttributes, parent.scale) skin.applyAllAttributes(self.instance, desktop, widget_attribs, parent.scale) skin.applyAllAttributes(self.scrollbar, desktop, scrollbar_attribs + widget_attribs, parent.scale) ret = True self.pageWidth = self.long_text.size().width() self.lineheight = fontRenderClass.getInstance().getLineHeight( self.long_text.getFont() ) or itemHeight # assume a random lineheight if nothing is visible lines = int(self.long_text.size().height() / self.lineheight) self.pageHeight = int(lines * self.lineheight) self.instance.move(self.long_text.position()) self.instance.resize( eSize(self.pageWidth, self.pageHeight + int(self.lineheight / 6))) self.scrollbar.move(ePoint(self.pageWidth - scrollbarWidth, 0)) self.scrollbar.resize( eSize(scrollbarWidth, self.pageHeight + int(self.lineheight / 6))) self.scrollbar.setOrientation(eSlider.orVertical) self.scrollbar.setRange(0, 100) self.scrollbar.setBorderWidth(scrollbarBorderWidth) self.setText(self.message) return ret
def __close(self): gMainDC.getInstance().setResolution(self.xres, self.yres) getDesktop(0).resize(eSize(self.xres, self.yres))
def applySkin(self, desktop, parent): scrollbarWidth = 20 scrollbarBorderWidth = 1 ret = False if self.skinAttributes: widget_attribs = [] scrollbar_attribs = [] scrollbarAttrib = [ "borderColor", "borderWidth", "scrollbarSliderForegroundColor", "scrollbarSliderBorderColor" ] for (attrib, value) in self.skinAttributes[:]: if attrib in scrollbarAttrib: scrollbar_attribs.append((attrib, value)) self.skinAttributes.remove((attrib, value)) elif attrib in ("scrollbarSliderPicture", "sliderPixmap"): self.scrollbar.setPixmap(skin.loadPixmap(value, desktop)) self.skinAttributes.remove((attrib, value)) elif attrib in ("scrollbarBackgroundPicture", "scrollbarbackgroundPixmap"): self.scrollbar.setBackgroundPixmap( skin.loadPixmap(value, desktop)) self.skinAttributes.remove((attrib, value)) elif "transparent" in attrib or "backgroundColor" in attrib: widget_attribs.append((attrib, value)) elif "scrollbarWidth" in attrib: scrollbarWidth = skin.parseScale(value) self.skinAttributes.remove((attrib, value)) elif "scrollbarSliderBorderWidth" in attrib: scrollbarBorderWidth = skin.parseScale(value) self.skinAttributes.remove((attrib, value)) elif "split" in attrib: self.split = 1 if value.lower() in ("1", "enabled", "on", "split", "true", "yes") else 0 if self.split: self.right_text = eLabel(self.instance) self.skinAttributes.remove((attrib, value)) elif "colposition" in attrib: self.column = skin.parseScale(value) elif "dividechar" in attrib: self.splitchar = value if self.split: skin.applyAllAttributes( self.long_text, desktop, self.skinAttributes + [("halign", "left")], parent.scale) skin.applyAllAttributes( self.right_text, desktop, self.skinAttributes + [("transparent", "1"), ("halign", "left" if self.column else "right")], parent.scale) else: skin.applyAllAttributes(self.long_text, desktop, self.skinAttributes, parent.scale) skin.applyAllAttributes(self.instance, desktop, widget_attribs, parent.scale) skin.applyAllAttributes(self.scrollbar, desktop, scrollbar_attribs + widget_attribs, parent.scale) ret = True self.pageWidth = self.long_text.size().width() lineheight = fontRenderClass.getInstance().getLineHeight( self.long_text.getFont( )) or 30 # assume a random lineheight if nothing is visible lines = int(self.long_text.size().height() / lineheight) self.pageHeight = int(lines * lineheight) self.instance.move(self.long_text.position()) self.instance.resize( eSize(self.pageWidth, self.pageHeight + int(lineheight / 6))) self.scrollbar.move(ePoint(self.pageWidth - scrollbarWidth, 0)) self.scrollbar.resize( eSize(scrollbarWidth, self.pageHeight + int(lineheight / 6))) self.scrollbar.setOrientation(eSlider.orVertical) self.scrollbar.setRange(0, 100) self.scrollbar.setBorderWidth(scrollbarBorderWidth) self.setText(self.message) return ret
def resize(self, w, h): self.instance.resize(eSize(*(w, h))) self["video"].instance.resize(eSize(*(w, h)))
def onShow(self): Pixmap.onShow(self) sc = AVSwitch().getFramebufferScale() self._aspectRatio = eSize(sc[0], sc[1]) self._scaleSize = self.instance.size() self.picload.setPara((self._scaleSize.width(), self._scaleSize.height(), sc[0], sc[1], True, 2, '#ff000000'))
def postWidgetCreate(self, instance): instance.setDecoder(self.decoder) instance.setFBSize(eSize(self.fb_width, self.fb_height))
def applySkin(self, desktop, screen): def retValue(val, limit, default, Min=False): try: if Min: x = min(limit, int(val)) else: x = max(limit, int(val)) except: x = default return x def setWrapFlag(attrib, value): if attrib.lower() == 'wrap' and value == '0' or attrib.lower( ) == 'nowrap' and value != '0': self.txtflags &= ~RT_WRAP else: self.txtflags |= RT_WRAP self.halign = valign = eLabel.alignLeft if self.skinAttributes: attribs = [] for attrib, value in self.skinAttributes: if attrib == 'font': self.txfont = parseFont(value, ((1, 1), (1, 1))) elif attrib == 'foregroundColor': self.scroll_label.setForegroundColor(parseColor(value)) elif attrib in ('shadowColor', 'borderColor'): self.scroll_label.setShadowColor(parseColor(value)) elif attrib == 'shadowOffset': x, y = value.split(',') self.soffset = (int(x), int(y)) self.scroll_label.setShadowOffset(ePoint(self.soffset)) elif attrib == 'borderWidth': self.soffset = (-int(value), -int(value)) elif attrib == 'valign' and value in ('top', 'center', 'bottom'): valign = { 'top': eLabel.alignTop, 'center': eLabel.alignCenter, 'bottom': eLabel.alignBottom }[value] self.txtflags |= { 'top': RT_VALIGN_TOP, 'center': RT_VALIGN_CENTER, 'bottom': RT_VALIGN_BOTTOM }[value] elif attrib == 'halign' and value in ('left', 'center', 'right', 'block'): self.halign = { 'left': eLabel.alignLeft, 'center': eLabel.alignCenter, 'right': eLabel.alignRight, 'block': eLabel.alignBlock }[value] self.txtflags |= { 'left': RT_HALIGN_LEFT, 'center': RT_HALIGN_CENTER, 'right': RT_HALIGN_RIGHT, 'block': RT_HALIGN_BLOCK }[value] elif attrib == 'noWrap': setWrapFlag(attrib, value) elif attrib == 'options': options = value.split(',') for o in options: if '=' in o: opt, val = (x.strip() for x in o.split('=', 1)) else: opt, val = o.strip(), '' if opt == '': continue elif opt in ('wrap', 'nowrap'): setWrapFlag(opt, val) elif opt == 'movetype' and val in ('none', 'running', 'swimming'): self.type = { 'none': NONE, 'running': RUNNING, 'swimming': SWIMMING }[val] elif opt == 'direction' and val in ('left', 'right', 'top', 'bottom'): self.direction = { 'left': LEFT, 'right': RIGHT, 'top': TOP, 'bottom': BOTTOM }[val] elif opt == 'step' and val: self.mStep = retValue(val, 1, self.mStep) elif opt == 'steptime' and val: self.mStepTimeout = retValue( val, 25, self.mStepTimeout) elif opt == 'startdelay' and val: self.mStartDelay = retValue( val, 0, self.mStartDelay) elif opt == 'pause' and val: self.mLoopTimeout = retValue( val, 0, self.mLoopTimeout) elif opt == 'oneshot' and val: self.mOneShot = retValue(val, 0, self.mOneShot) elif opt == 'repeat' and val: self.mRepeat = retValue(val, 0, self.mRepeat) elif opt == 'always' and val: self.mAlways = retValue(val, 0, self.mAlways) elif opt == 'startpoint' and val: self.mStartPoint = int(val) elif opt == 'pagedelay' and val: self.mPageDelay = retValue(val, 0, self.mPageDelay) elif opt == 'pagelength' and val: self.mPageLength = retValue( val, 0, self.mPageLength) else: attribs.append((attrib, value)) if attrib == 'backgroundColor': self.scroll_label.setBackgroundColor(parseColor(value)) elif attrib == 'transparent': self.scroll_label.setTransparent(int(value)) self.skinAttributes = attribs ret = Renderer.applySkin(self, desktop, screen) if self.mOneShot: self.mOneShot = max(self.mStepTimeout, self.mOneShot) if self.mLoopTimeout: self.mLoopTimeout = max(self.mStepTimeout, self.mLoopTimeout) if self.mPageDelay: self.mPageDelay = max(self.mStepTimeout, self.mPageDelay) self.scroll_label.setFont(self.txfont) if not self.txtflags & RT_WRAP: self.scroll_label.setNoWrap(1) self.scroll_label.setVAlign(valign) self.scroll_label.setHAlign(self.halign) self.scroll_label.move(ePoint(0, 0)) self.scroll_label.resize(eSize(self.W, self.H)) if self.direction in (TOP, BOTTOM): from enigma import fontRenderClass flh = int(fontRenderClass.getInstance().getLineHeight(self.txfont) or self.txfont.pointSize / 6 + self.txfont.pointSize) self.scroll_label.setText('WQq') if flh > self.scroll_label.calculateSize().height(): self.lineHeight = flh self.scroll_label.setText('') return ret
def parseSize(s, scale, object=None, desktop=None): return eSize(*parseValuePair(s, scale, object, desktop))