def __init__(self, node=None): super(WidgetObject, self).__init__(node) self.type = 'widget' self.properties = self.properties + ( ('style','Style', PROP_TYPE_STRING), ('left', 'Navigate Left', PROP_TYPE_OPTION, self.get_navigation_widgets), ('right', 'Navigate Right', PROP_TYPE_OPTION, self.get_navigation_widgets), ('up', 'Navigate Up', PROP_TYPE_OPTION, self.get_navigation_widgets), ('down', 'Navigate Down', PROP_TYPE_OPTION, self.get_navigation_widgets), ) if node: self.style = attr_str(node, 'style', '') self.left = attr_str(node, 'left', '') self.right = attr_str(node, 'right', '') self.up = attr_str(node, 'up', '') self.down = attr_str(node, 'down', '') else: self.style = '' self.right = '' self.left = '' self.up = '' self.down = '' if self.name is None: self.name = 'widget%d' % WidgetObject.count WidgetObject.count += 1 self.skin_object = osd_skin.OSDWidget((0,0), (0,0), (0,0), self.name, self.style, None)
def __init__(self, node=None): super(ColorObject, self).__init__(node) self.properties = ( ('name', 'Name', PROP_TYPE_STRING), ('red', 'Red', PROP_TYPE_INT, (0, 0xff)), ('green', 'Green', PROP_TYPE_INT, (0, 0xff)), ('blue', 'Blue', PROP_TYPE_INT, (0, 0xff)), ('alpha', 'Alpha', PROP_TYPE_INT, (0, 0xff)), ) self.type = 'color' if node: self.name = attr_str(node, 'label', '') value = attr_color(node, 'value', (0 , 0, 0), False) self.red = value[0] self.green = value[1] self.blue = value[2] if len(value) == 4: self.alpha = value[3] else: self.alpha = 0xff else: self.name = 'Color%d' % ColorObject.count ColorObject.count += 1 self.red = 0xff self.green = 0xff self.blue = 0xff self.alpha = 0xff
def _load_handler(self, fxd, node): file_geometry = attr_str(node, 'geometry', '800x600') if file_geometry: w, h = file_geometry.split('x') else: w = config.CONF.width h = config.CONF.height self.width = int(w) self.height = int(h) self.include = attr_str(node, 'include', '') if self.include: load_skin(self.include) self.icontheme = attr_str(node, 'icontheme', '') if self.icontheme: osd_skin.set_icon_theme(self.icontheme) for cnode in node.children: obj = None if cnode.name == 'font': obj = FontObject(cnode) elif cnode.name == 'color': obj = ColorObject(cnode) elif cnode.name == 'osd': obj = DialogObject(cnode) elif cnode.name == 'widgetstyle': obj = WidgetStyleObject(cnode) elif cnode.name == 'name': self.name = cnode.textof() elif cnode.name == 'author': self.email = attr_str(cnode, 'email', '') self.author = cnode.textof() elif cnode.name == 'description': self.description = cnode.textof() elif cnode.name == 'version': self.version = cnode.textof() if obj: self.add_child(obj) for child in self.children: if isinstance(child, WidgetStyleObject): child.update_widget_style()
def __init__(self, node=None): super(FontObject, self).__init__(node) self.type = 'font' self.properties = ( ('name', 'Name', PROP_TYPE_STRING), ('font', 'Font', PROP_TYPE_STRING, self.get_fonts), ('size', 'Size', PROP_TYPE_INT, (1, 100)), ('color', 'Color', PROP_TYPE_STRING), ) if node: self.name = attr_str(node, 'label', '') self.font = attr_str(node, 'name', '') self.size = attr_int(node, 'size', 0) self.color = attr_str(node, 'color', '') else: self.name = 'Font%d' % FontObject.count FontObject.count += 1 self.font = '' self.size = 10 self.color = ''
def __init__(self, node=None): super(ImageObject, self).__init__(node) self.type = 'image' self.properties = self.properties + ( ('expr', 'Expression', PROP_TYPE_STRING), ('src', 'Source', PROP_TYPE_IMAGE), ('src_is_expr', 'Source is Expression', PROP_TYPE_BOOL), ('scale', 'Scaling', PROP_TYPE_OPTION, ('noscale', 'horizontal','vertical','both','aspect')), ('align', 'H Align', PROP_TYPE_OPTION, ('left', 'center', 'right')), ('valign', 'V Align', PROP_TYPE_OPTION, ('top', 'center', 'bottom')), ) if node: self.expr = attr_str(node, 'expression', 'True') self.src = attr_str(node, 'srcexpr', '') if self.src: self.src_is_expr = True else: self.src_is_expr = False self.src = attr_str(node, 'src', '') self.scale = attr_str(node, 'scale', 'noscale') self.align = attr_str(node, 'align', 'left') self.valign = attr_str(node, 'valign', 'top') else: self.expr = 'True' self.src = '' self.src_is_expr = False self.scale = 'noscale' self.align = 'left' self.valign = 'top' if self.name is None: self.name = 'Image%d' % ImageObject.count ImageObject.count += 1 self.skin_object = osd_skin.OSDImage((self.x, self.y), (self.width, self.height), None, self.expr, None, self.scale, self.valign, self.align)
def __init__(self, node=None): super(TextObject, self).__init__(node) self.properties = self.properties + ( ('expr', 'Expression', PROP_TYPE_STRING), ('font', 'Font', PROP_TYPE_STRING, self.get_font_names), ('align', 'H Align', PROP_TYPE_OPTION, ('left', 'center', 'right')), ('valign', 'V Align', PROP_TYPE_OPTION, ('top', 'center', 'bottom')), ('fgcolor', 'Foreground', PROP_TYPE_STRING, self.get_color_names), ('bgcolor', 'Background', PROP_TYPE_STRING, self.get_color_names), ) self.type = 'text' if node: self.expr = attr_str(node, 'expression', '') self.font = attr_str(node, 'font', '') self.align = attr_str(node, 'align', 'left') self.valign = attr_str(node, 'valign', 'top') self.fgcolor = attr_str(node, 'fgcolor', '') self.bgcolor = attr_str(node, 'bgcolor', '') else: self.expr = '' self.font = '' self.align = 'left' self.valign = 'center' self.fgcolor = '' self.bgcolor = '' if self.name is None: self.name = 'Text%d' % TextObject.count TextObject.count += 1 self.skin_object = osd_skin.OSDText((self.x, self.y), (self.width, self.height),self.expr, None, None, None, self.valign, self.align)
def __init__(self, node=None): super(DialogChildObject, self).__init__(node) self.properties = (('name', 'Name', PROP_TYPE_STRING), ('x', 'X', PROP_TYPE_STRING), ('y', 'Y', PROP_TYPE_STRING), ('width', 'Width', PROP_TYPE_STRING), ('height', 'Height', PROP_TYPE_STRING), ) if node: self.name = attr_str(node, 'name', None) self.x = attr_str(node, 'x', '0') self.y = attr_str(node, 'y', '0') self.width = attr_str(node, 'width', '100') self.height = attr_str(node, 'height', '100') else: self.name = None self.x = '0' self.y = '0' self.width = '100' self.height = '100' self.skin_object = None
def __init__(self, node=None): super(WidgetStyleObject, self).__init__() self.info_dict = {'width': 100, 'height': 100, 'model':ButtonModel('Test')} self.has_children = True self.children = [] if node: self.name = attr_str(node, 'name', '') for cnode in node.children: if cnode.name == 'widgetstate': self.add_child(WidgetStateObject(cnode)) else: self.name = 'Style%d' % WidgetStyleObject.count WidgetStyleObject.count += 1 self.orig_style = None self.type = 'style' self.properties = (('name', 'Name', PROP_TYPE_STRING),)
def __init__(self, node=None): super(DialogObject, self).__init__(node) self.type = 'dialog' self.has_children = True self.children = [] self.info_dict = {} self.properties = ( ('name', 'Name', PROP_TYPE_STRING, ('volume', 'message', '1button', '2button', '3button' , 'menu', 'bboptionsmenu', 'play_state')), ('x', 'X', PROP_TYPE_INT, (0, 2000)), ('y', 'Y', PROP_TYPE_INT, (0, 2000)), ('width', 'Width', PROP_TYPE_INT, (0, 2000)), ('height', 'Height', PROP_TYPE_INT, (0, 2000)), ) if node: self.name = attr_str(node, 'name', '') if self.name in DIALOG_EXAMPLE_INFO: self.info_dict = copy.copy(DIALOG_EXAMPLE_INFO[self.name]) self.x = attr_int(node, 'x', 0) self.y = attr_int(node, 'y', 0) self.width = attr_int(node, 'width', 100) self.height = attr_int(node, 'height', 100) for cnode in node.children: obj = None if cnode.name == 'text': obj = TextObject(cnode) elif cnode.name == 'image': obj = ImageObject(cnode) elif cnode.name == 'percent': obj = PercentObject(cnode) elif cnode.name == 'widget': obj = WidgetObject(cnode) elif cnode.name == 'menu': obj = MenuObject(cnode) if obj: self.add_child(obj) else: self.name = 'dialog%d' % DialogObject.count DialogObject.count += 1 self.width = 100 self.height = 100 self.x = 0 self.y = 0
def __init__(self, node=None): self.info_dict = {} super(WidgetStateObject, self).__init__(node) if node: self.name = attr_str(node, 'state', '') else: self.name = 'State%d' % WidgetStyleObject.count WidgetStateObject.count += 1 self.x = 0 self.y = 0 self.width = 100 self.height = 100 self.type = 'state' self.properties = (('name', 'State', PROP_TYPE_STRING, ('normal', 'active', 'disabled', 'pressed', 'highlighted', 'normal_selected', 'normal_unselected', 'active_selected','active_unselected','disabled_selected', 'disabled_unselected','highlighted_selected', 'highlighted_unselected')),)