def __init__(self, template="ButtonDefault", **kwargs): LUIObject.__init__(self, x=0, y=0, solid=True) self._template = template self._button_sprite = LUISprite(self, template, "skin") self._button_sprite.width = width self._button_sprite.height = height LUIInitialState.init(self, kwargs)
def __init__(self, text=u"Label", shadow=None, font_size=14, font="label", color=None, wordwrap=False, **kwargs): """ Creates a new label. If shadow is True, a small text shadow will be rendered below the actual text. """ LUIObject.__init__(self) LUIInitialState.init(self, kwargs) self._text = LUIText( self, unicode(text), font, font_size, 0, 0, wordwrap ) self._text.z_offset = 1 if color is None: self.color = LUILabel.DEFAULT_COLOR else: self.color = color if shadow is None: shadow = LUILabel.DEFAULT_USE_SHADOW self._have_shadow = shadow if self._have_shadow: self._shadow_text = LUIText( self, unicode(text), font, font_size, 0, 0, wordwrap ) self._shadow_text.top = 1 self._shadow_text.color = (0,0,0,0.6)
def __init__(self, parent=None, group=None, value=None, active=False, label=u"Radiobox", **kwargs): """ Constructs a new radiobox. group should be a handle to a LUIRadioboxGroup. value will be the value returned by group.value, in case the box was selected. By default, the radiobox is not active. """ assert group is not None, "LUIRadiobox needs a LUIRadioboxGroup!" LUIObject.__init__(self, x=0, y=0, solid=True) self._sprite = LUISprite(self, "Radiobox_Default", "skin") self._label = LUILabel(parent=self, text=label, margin=(0, 0, 0, 23), center_vertical=True) self._value = value self._active = False self._hovered = False self._group = group self._group.register_box(self) if active: self.set_active() if parent: self.parent = parent LUIInitialState.init(self, kwargs)
def __init__(self, width=200, options=None, selected_option=None, **kwargs): """ Constructs a new selectbox with a given width """ LUIObject.__init__(self, x=0, y=0, w=width+4, solid=True) LUIInitialState.init(self, kwargs) # The selectbox has a small border, to correct this we move it self.margin.left = -2 self._bg_layout = LUIHorizontalStretchedLayout(parent=self, prefix="Selectbox", width="100%") self._label_container = LUIObject(self, x=10, y=0) self._label_container.set_size("100%", "100%") self._label_container.clip_bounds = (0,0,0,0) self._label = LUILabel(parent=self._label_container, text=u"Select an option ..") self._label.center_vertical = True self._drop_menu = LUISelectdrop(parent=self, width=width) self._drop_menu.top = self._bg_layout._sprite_right.height - 7 self._drop_menu.topmost = True self._drop_open = False self._drop_menu.hide() self._options = [] self._current_option_id = None if options is not None: self._options = options self._select_option(selected_option)
def __init__(self, text=u"Label", shadow=None, font_size=14, font="label", color=None, wordwrap=False, **kwargs): """ Creates a new label. If shadow is True, a small text shadow will be rendered below the actual text. """ LUIObject.__init__(self) LUIInitialState.init(self, kwargs) self._text = LUIText(self, unicode(text), font, font_size, 0, 0, wordwrap) self._text.z_offset = 1 if color is None: self.color = LUILabel.DEFAULT_COLOR else: self.color = color if shadow is None: shadow = LUILabel.DEFAULT_USE_SHADOW self._have_shadow = shadow if self._have_shadow: self._shadow_text = LUIText(self, unicode(text), font, font_size, 0, 0, wordwrap) self._shadow_text.top = 1 self._shadow_text.color = (0, 0, 0, 0.6)
def __init__(self, **kwargs): """ Creates a new block of text. """ LUIObject.__init__(self) LUIInitialState.init(self, kwargs) self._cursor = LVecBase2i(0) self._last_size = 14 self.labels = []
def __init__(self, parent=None, width=100, height=100, padding=10, **kwargs): LUIObject.__init__(self) self.set_size(width, height) self._content_parent = LUIObject(self) self._content_parent.set_size("100%", "100%") self._content_parent.clip_bounds = (0,0,0,0) self._content_clip = LUIObject(self._content_parent, x=padding, y=padding) self._content_clip.set_size("100%", "100%") self._content_scroller = LUIObject(self._content_clip) self._content_scroller.width = "100%" self._scrollbar = LUIObject(self, x=0, y=0, w=20) self._scrollbar.height = "100%" self._scrollbar.right = -10 self._scrollbar_bg = LUISprite(self._scrollbar, "blank", "skin") self._scrollbar_bg.color = (1,1,1,0.05) self._scrollbar_bg.set_size(3, "100%") self._scrollbar_bg.center_horizontal = True # Handle self._scrollbar_handle = LUIObject(self._scrollbar, x=5, y=0, w=10) self._scroll_handle_top = LUISprite(self._scrollbar_handle, "ScrollbarHandle_Top", "skin") self._scroll_handle_mid = LUISprite(self._scrollbar_handle, "ScrollbarHandle", "skin") self._scroll_handle_bottom = LUISprite(self._scrollbar_handle, "ScrollbarHandle_Bottom", "skin") self._scrollbar_handle.solid = True self._scrollbar.solid = True self._scrollbar_handle.bind("mousedown", self._start_scrolling) self._scrollbar_handle.bind("mouseup", self._stop_scrolling) self._scrollbar.bind("mousedown", self._on_bar_click) self._scrollbar.bind("mouseup", self._stop_scrolling) self._handle_dragging = False self._drag_start_y = 0 self._scroll_top_position = 0 self._content_height = 400 scroll_shadow_width = self.width - 10 # Scroll shadow self._scroll_shadow_top = LUIHorizontalStretchedLayout(parent=self, prefix="ScrollShadowTop", width="100%") self._scroll_shadow_bottom = LUIHorizontalStretchedLayout(parent=self, prefix="ScrollShadowBottom", width="100%") self._scroll_shadow_bottom.bottom = 0 self._handle_height = 100 if parent is not None: self.parent = parent LUIInitialState.init(self, kwargs) self.content_node = self._content_scroller taskMgr.doMethodLater(0.05, lambda task: self._update(), "update_scrollbar")
def __init__(self, image_prefix="", **kwargs): """ Creates a new layout, using the image_prefix as prefix. """ LUIObject.__init__(self, x=0, y=0, w=100, h=100) LUIInitialState.init(self, kwargs) self.prefix = image_prefix self.parts = {} for i in self.modes: self.parts[i] = LUISprite(self, "blank", "skin") self.update_layout()
def __init__(self, template="ButtonDefault", **kwargs): LUIObject.__init__(self, x=0, y=0, solid=True) self._template = template self._button_sprite = LUISprite(self, template, "skin") if 'width' in kwargs: self._button_sprite.width = kwargs['width'] if 'height' in kwargs: self._button_sprite.height = kwargs['height'] LUIInitialState.init(self, kwargs)
def __init__(self, parent=None, width=200, placeholder=u"Enter some text ..", value=u"", **kwargs): """ Constructs a new input field. An input field always needs a width specified """ LUIObject.__init__(self, x=0, y=0, solid=True) self.set_width(width) self._layout = LUIHorizontalStretchedLayout(parent=self, prefix="InputField", width="100%") # Container for the text self._text_content = LUIObject(self) self._text_content.margin = (5, 7, 5, 7) self._text_content.clip_bounds = (0, 0, 0, 0) self._text_content.set_size("100%", "100%") # Scroller for the text, so we can move right and left self._text_scroller = LUIObject(parent=self._text_content) self._text_scroller.center_vertical = True self._text = LUILabel(parent=self._text_scroller, text=u"") # Cursor for the current position self._cursor = LUISprite(self._text_scroller, "blank", "skin", x=0, y=0, w=2, h=15) self._cursor.color = (0.5, 0.5, 0.5) self._cursor.margin.top = 2 self._cursor.z_offset = 20 self._cursor_index = 0 self._cursor.hide() self._value = value # Placeholder text, shown when out of focus and no value exists self._placeholder = LUILabel(parent=self._text_content, text=placeholder, shadow=False, center_vertical=True, alpha=0.2) # Various states self._tickrate = 1.0 self._tickstart = 0.0 self._render_text() if parent is not None: self.parent = parent LUIInitialState.init(self, kwargs)
def __init__(self, checked=False, label=u"Checkbox", **kwargs): """ Constructs a new checkbox with the given label and state. By default, the checkbox is not checked. """ LUIObject.__init__(self, x=0, y=0, solid=True) self._checked = checked self._checkbox_sprite = LUISprite(self, "Checkbox_Default", "skin") self._label = LUILabel(parent=self, text=label, margin=(0, 0, 0, 25), center_vertical=True, alpha=0.4) self._hovered = False LUIInitialState.init(self, kwargs)
def __init__(self, image_prefix="", **kwargs): """ Creates a new layout, using the image_prefix as prefix. """ LUIObject.__init__(self) self.set_size("100%", "100%") self._prefix = image_prefix self._parts = {} for i in self._MODES: self._parts[i] = LUISprite(self, "blank", "skin") self._update_layout() LUIInitialState.init(self, kwargs)
def __init__(self, parent=None, prefix="ButtonDefault", **kwargs): LUIObject.__init__(self) self._layout = LUIHorizontalLayout(self, spacing=0) self._layout.width = "100%" self._sprite_left = LUISprite(self._layout.cell(), "blank", "skin") self._sprite_mid = LUISprite(self._layout.cell('*'), "blank", "skin") self._sprite_right = LUISprite(self._layout.cell(), "blank", "skin") if parent is not None: self.parent = parent self.prefix = prefix LUIInitialState.init(self, kwargs)
def __init__(self, checked=False, label=u"Checkbox", **kwargs): """ Constructs a new checkbox with the given label and state. """ LUIObject.__init__(self, x=0, y=0, w=0, h=0, solid=True) LUIInitialState.init(self, kwargs) self.checkboxSprite = LUISprite(self, "Checkbox_Default", "skin") self.label = LUILabel(parent=self, text=label, shadow=True, left=self.checkboxSprite.width + 6) self.label.top = self.label.height - self.checkboxSprite.height self.label.bind("resized", self._on_label_resized) self.fit_to_children() self.checked = checked self._update_sprite()
def __init__(self, parent=None, filled=True, min_value=0.0, max_value=1.0, width=100.0, value=None, **kwargs): """ Constructs a new slider. If filled is True, the part behind the knob will be solid """ LUIObject.__init__(self, x=0, y=0, solid=True) self.set_width(width) self._knob = LUISprite(self, "SliderKnob", "skin") self._knob.z_offset = 2 self._knob.solid = True # Construct the background self._slider_bg = LUIHorizontalStretchedLayout(parent=self, prefix="SliderBg", center_vertical=True, width="100%", margin=(-1, 0, 0, 0)) self._filled = filled self._min_value = min_value self._max_value = max_value self._side_margin = self._knob.width / 4 self._effective_width = self.width - 2 * self._side_margin if self._filled: self._slider_fill = LUIObject(self) self._fill_left = LUISprite(self._slider_fill, "SliderBgFill_Left", "skin") self._fill_mid = LUISprite(self._slider_fill, "SliderBgFill", "skin") self._fill_mid.left = self._fill_left.width self._slider_fill.z_offset = 1 self._slider_fill.center_vertical = True if parent is not None: self.parent = parent # Handle various events self._knob.bind("mousedown", self._start_drag) self._knob.bind("mousemove", self._update_drag) self._knob.bind("mouseup", self._stop_drag) self._knob.bind("keydown", self._on_keydown) self._knob.bind("blur", self._stop_drag) self._knob.bind("keyrepeat", self._on_keydown) self._drag_start_pos = None self._dragging = False self._drag_start_val = 0 self.current_val = 10 # Set initial value if value is None: self.set_value( (self._min_value + self._max_value) / 2.0 ) else: self.set_value(value) self._update_knob() LUIInitialState.init(self, kwargs)
def __init__(self, text=u"Label", shadow=True, font_size=14, font="label", **kwargs): """ Creates a new label. """ LUIObject.__init__(self) LUIInitialState.init(self, kwargs) self.text = LUIText(self, unicode(text), font, font_size, 0, 0) self.text.color = (1,1,1,0.9) self.text.z_offset = 1 self.have_shadow = shadow if self.have_shadow: self.shadowText = LUIText(self, unicode(text), font, font_size, 0, 0) self.shadowText.top = 1 self.shadowText.color = (0,0,0,0.7) self.fit_to_children()
def __init__(self, template="ButtonDefault", width = 50, height = 50, **kwargs): LUIObject.__init__(self, x=0, y=0, w=0, h=0, solid=True) LUIInitialState.init(self, kwargs) self.margin_left = -1 self.template = template self.fit_to_children() self.button_sprite = LUISprite(self, template, "skin") self.fit_to_children() self.width = width self.height = height self.button_sprite.width = width self.button_sprite.height = height
def __init__(self, group=None, value=None, active=False, label=u"Radiobox", **kwargs): LUIObject.__init__(self, x=0, y=0, w=0, h=0, solid=True) LUIInitialState.init(self, kwargs) self.sprite = LUISprite(self, "Radiobox_Default", "skin") self.label = LUILabel(parent=self, text=label, shadow=True, left=self.sprite.width+6) self.label.top = self.label.height - self.sprite.height self.label.bind("resized", self._on_label_resized) self.fit_to_children() self.group = group self.group.register_box(self) self.active = False self.value = value if active: self.set_active()
def __init__(self, inner_padding=5, scrollable=False, style=FS_raised, **kwargs): """ Creates a new frame with the given options and style. If scrollable is True, the contents of the frame will scroll if they don't fit into the frame height. inner_padding only has effect if scrollable is True. You can call fit_to_children() to make the frame fit automatically to it's contents.""" LUIObject.__init__(self) # Each *style* has a different border size (size of the shadow). The # border size shouldn't get calculated to the actual framesize, so we # are determining it first and then substracting it. # TODO: We could do this automatically, determined by the sprite size # probably? self._border_size = 0 self.padding = 10 self.solid = True prefix = "" if style == LUIFrame.FS_raised: temp = LUISprite(self, "Frame_Left", "skin") self._border_size = temp.width self.remove_child(temp) prefix = "Frame_" elif style == LUIFrame.FS_sunken: self._border_size = 0 prefix = "SunkenFrame_" else: raise Exception("Unkown LUIFrame style: " + style) self._scrollable = scrollable self._layout = LUICornerLayout(parent=self, image_prefix=prefix) self._layout.margin = -(self.padding.top + self._border_size) if self._scrollable: self._content = LUIObject(self) self._content.size = (self.width, self.height) self._content.pos = (self._border_size, self._border_size) self._scroll_content = LUIScrollableRegion( self._content, width=self.width - 2 * self.padding.left, height=self.height - 2 * self.padding.left, padding=inner_padding) self.content_node = self._scroll_content.content_node LUIInitialState.init(self, kwargs)
def __init__(self, width=200, options=None, selectedOption=None, **kwargs): LUIObject.__init__(self, x=0, y=0, w=width+4, h=0, solid=True) LUIInitialState.init(self, kwargs) LUICallback.__init__(self) # The selectbox has a small border, to correct this we move it self.margin_left = -2 self.bgLeft = LUISprite(self, "Selectbox_Left", "skin") self.bgMid = LUISprite(self, "Selectbox", "skin") self.bgRight = LUISprite(self, "Selectbox_Right", "skin") self.bgMid.width = self.width - self.bgLeft.width - self.bgRight.width self.bgMid.left = self.bgLeft.width self.bgRight.left = self.bgMid.width + self.bgMid.left self.bgRight.z_offset = 1 self.labelContainer = LUIObject(self, x=10, y=6, w=width - 20 - self.bgRight.width, h=self.bgMid.height - 6) self.labelContainer.clip_bounds = (0,0,0,0) self.label = LUILabel(parent=self.labelContainer, text=u"Select an option ..", shadow=True) self.bgRight.bind("mouseover", self._knob_mouseover) self.bgRight.bind("mouseout", self._knob_mouseout) self.bgRight.bind("click", self.on_click) self.bgRight.bind("click", self.on_click) self.fit_to_children() self.dropMenu = UISelectdrop(parent=self, width=width) self.dropMenu.top = self.bgMid.height - 7 self.dropMenu.topmost = True self.dropOpen = False self.dropMenu.hide() self.options = [] self.currentOptionId = None if options is not None: self.options = options self._select_option(selectedOption)
def __init__(self, text=u"Button", template="ButtonDefault", **kwargs): """ Constructs a new button. The template controls which sprites to use. If the template is "ButtonDefault" for example, the sprites "ButtonDefault_Left", "ButtonDefault" and "ButtonDefault_Right" will be used. The sprites used when the button is pressed should be named "ButtonDefaultFocus_Left" and so on then. If an explicit width is set on the button, the button will stick to that width, otherwise it will automatically resize to fit the label """ LUIObject.__init__(self, x=0, y=0, solid=True) self._template = template self._layout = LUIHorizontalStretchedLayout( parent=self, prefix=self._template, width="100%") self._label = LUILabel(parent=self, text=text) self._label.z_offset = 1 self._label.center_vertical = True self._label.margin = 0, 20, 0, 20 self.margin.left = -1 LUIInitialState.init(self, kwargs)
def __init__(self, text=u"Button", template="ButtonDefault", **kwargs): """ Constructs a new button. The template controls which sprites to use. If the template is "ButtonDefault" for example, the sprites "ButtonDefault_Left", "ButtonDefault" and "ButtonDefault_Right" will be used. The sprites used when the button is pressed should be named "ButtonDefaultFocus_Left" and so on then. If an explicit width is set on the button, the button will stick to that width, otherwise it will automatically resize to fit the label """ LUIObject.__init__(self, x=0, y=0, solid=True) self._template = template self._layout = LUIHorizontalStretchedLayout(parent=self, prefix=self._template, width="100%") self._label = LUILabel(parent=self, text=text) self._label.z_offset = 1 self._label.center_vertical = True self._label.margin = 0, 20, 0, 20 self.margin.left = -1 LUIInitialState.init(self, kwargs)
def __init__(self, parent=None, width=200, placeholder=u"Enter some text ..", value=u"", **kwargs): """ Constructs a new input field. An input field always needs a width specified """ LUIObject.__init__(self, x=0, y=0, solid=True) self.set_width(width) self._layout = LUIHorizontalStretchedLayout(parent=self, prefix="InputField", width="100%") # Container for the text self._text_content = LUIObject(self) self._text_content.margin = (5, 7, 5, 7) self._text_content.clip_bounds = (0,0,0,0) self._text_content.set_size("100%", "100%") # Scroller for the text, so we can move right and left self._text_scroller = LUIObject(parent=self._text_content) self._text_scroller.center_vertical = True self._text = LUILabel(parent=self._text_scroller, text=u"") # Cursor for the current position self._cursor = LUISprite(self._text_scroller, "blank", "skin", x=0, y=0, w=2, h=15) self._cursor.color = (0.5, 0.5, 0.5) self._cursor.margin.top = 2 self._cursor.z_offset = 20 self._cursor_index = 0 self._cursor.hide() self._value = value # Placeholder text, shown when out of focus and no value exists self._placeholder = LUILabel(parent=self._text_content, text=placeholder, shadow=False, center_vertical=True, alpha=0.2) # Various states self._tickrate = 1.0 self._tickstart = 0.0 self._render_text() if parent is not None: self.parent = parent LUIInitialState.init(self, kwargs)
def __init__(self, innerPadding=5, scrollable=False, style=Raised, **kwargs): """ Creates a new frame with the given options and style. If scrollable is True, the contents of the frame will scroll if they don't fit into the frame height. innerPadding only has effect if scrollable is True. You can call fit_to_children() to make the frame fit automatically to it's contents.""" LUIObject.__init__(self) # Each *style* has a different border size (size of the shadow). The # border size shouldn't get calculated to the actual framesize, so we # are determining it first and then substracting it. # TODO: We could do this automatically, determined by the sprite size # probably? self.borderSize = 0 self.padding = 10 self.solid = True prefix = "" if style == LUIFrame.Raised: self.borderSize = 33 prefix = "Frame_" elif style == LUIFrame.Sunken: self.borderSize = 5 prefix = "SunkenFrame_" else: print "Unkown UIFrame style:", style self.layout = LUICornerLayout(parent=self, image_prefix=prefix) LUIInitialState.init(self, kwargs) self.effectivePadding = self.padding_top + self.borderSize self.scrollable = scrollable self.layout.margin = -self.effectivePadding # TODO: Scrollable # if self.scrollable: self.content = LUIObject(self)
def __init__(self, width=200, options=None, selected_option=None, **kwargs): """ Constructs a new selectbox with a given width """ LUIObject.__init__(self, x=0, y=0, w=width + 4, solid=True) LUIInitialState.init(self, kwargs) # The selectbox has a small border, to correct this we move it self.margin.left = -2 self._bg_layout = LUIHorizontalStretchedLayout(parent=self, prefix="Selectbox", width="100%") self._label_container = LUIObject(self, x=10, y=0) self._label_container.set_size("100%", "100%") self._label_container.clip_bounds = (0, 0, 0, 0) self._label = LUILabel(parent=self._label_container, text=u"Select an option ..") self._label.center_vertical = True self._drop_menu = LUISelectdrop(parent=self, width=width) self._drop_menu.top = self._bg_layout._sprite_right.height - 7 self._drop_menu.topmost = True self._drop_open = False self._drop_menu.hide() self._options = [] self._current_option_id = None if options is not None: self._options = options self._select_option(selected_option)
def __init__(self, parent=None, width=100, height=100, padding=10, **kwargs): LUIObject.__init__(self) self.set_size(width, height) self._content_parent = LUIObject(self) self._content_parent.set_size("100%", "100%") self._content_parent.clip_bounds = (0, 0, 0, 0) self._content_clip = LUIObject(self._content_parent, x=padding, y=padding) self._content_clip.set_size("100%", "100%") self._content_scroller = LUIObject(self._content_clip) self._content_scroller.width = "100%" self._scrollbar = LUIObject(self, x=0, y=0, w=20) self._scrollbar.height = "100%" self._scrollbar.right = -10 self._scrollbar_bg = LUISprite(self._scrollbar, "blank", "skin") self._scrollbar_bg.color = (1, 1, 1, 0.05) self._scrollbar_bg.set_size(3, "100%") self._scrollbar_bg.center_horizontal = True # Handle self._scrollbar_handle = LUIObject(self._scrollbar, x=5, y=0, w=10) self._scroll_handle_top = LUISprite(self._scrollbar_handle, "ScrollbarHandle_Top", "skin") self._scroll_handle_mid = LUISprite(self._scrollbar_handle, "ScrollbarHandle", "skin") self._scroll_handle_bottom = LUISprite(self._scrollbar_handle, "ScrollbarHandle_Bottom", "skin") self._scrollbar_handle.solid = True self._scrollbar.solid = True self._scrollbar_handle.bind("mousedown", self._start_scrolling) self._scrollbar_handle.bind("mouseup", self._stop_scrolling) self._scrollbar.bind("mousedown", self._on_bar_click) self._scrollbar.bind("mouseup", self._stop_scrolling) self._handle_dragging = False self._drag_start_y = 0 self._scroll_top_position = 0 self._content_height = 400 scroll_shadow_width = self.width - 10 # Scroll shadow self._scroll_shadow_top = LUIHorizontalStretchedLayout( parent=self, prefix="ScrollShadowTop", width="100%") self._scroll_shadow_bottom = LUIHorizontalStretchedLayout( parent=self, prefix="ScrollShadowBottom", width="100%") self._scroll_shadow_bottom.bottom = 0 self._handle_height = 100 if parent is not None: self.parent = parent LUIInitialState.init(self, kwargs) self.content_node = self._content_scroller taskMgr.doMethodLater(0.05, lambda task: self._update(), "update_scrollbar")
def __init__(self, **kwargs): """ Creates a new formatted label. """ LUIObject.__init__(self) LUIInitialState.init(self, kwargs) self.currentLeft = 0 self.currentTop = 0
def __init__(self, *args, **kwargs): _LUIObject.__init__(self, *args) LUIInitialState.init(self, kwargs)
def __init__(self, parent=None, filled=True, min_value=0.0, max_value=1.0, width=100.0, value=None, **kwargs): """ Constructs a new slider. If filled is True, the part behind the knob will be solid """ LUIObject.__init__(self, x=0, y=0, solid=True) self.set_width(width) self._knob = LUISprite(self, "SliderKnob", "skin") self._knob.z_offset = 2 self._knob.solid = True # Construct the background self._slider_bg = LUIHorizontalStretchedLayout(parent=self, prefix="SliderBg", center_vertical=True, width="100%", margin=(-1, 0, 0, 0)) self._filled = filled self._min_value = min_value self._max_value = max_value self._side_margin = self._knob.width / 4 self._effective_width = self.width - 2 * self._side_margin if self._filled: self._slider_fill = LUIObject(self) self._fill_left = LUISprite(self._slider_fill, "SliderBgFill_Left", "skin") self._fill_mid = LUISprite(self._slider_fill, "SliderBgFill", "skin") self._fill_mid.left = self._fill_left.width self._slider_fill.z_offset = 1 self._slider_fill.center_vertical = True if parent is not None: self.parent = parent # Handle various events self._knob.bind("mousedown", self._start_drag) self._knob.bind("mousemove", self._update_drag) self._knob.bind("mouseup", self._stop_drag) self._knob.bind("keydown", self._on_keydown) self._knob.bind("blur", self._stop_drag) self._knob.bind("keyrepeat", self._on_keydown) self._drag_start_pos = None self._dragging = False self._drag_start_val = 0 self.current_val = 10 # Set initial value if value is None: self.set_value((self._min_value + self._max_value) / 2.0) else: self.set_value(value) self._update_knob() LUIInitialState.init(self, kwargs)
def __init__(self, parent=None, spacing=0.0, **kwargs): _LUIVerticalLayout.__init__(self, parent, spacing) LUIInitialState.init(self, kwargs)
def __init__(self, *args, **kwargs): _LUISprite.__init__(self, *args) LUIInitialState.init(self, kwargs)
def __init__(self, parent=None, spacing=0.0, **kwargs): _LUIHorizontalLayout.__init__(self, parent, spacing) LUIInitialState.init(self, kwargs)
def __init__(self, **kwargs): """ Creates a new formatted label. """ LUIObject.__init__(self) LUIInitialState.init(self, kwargs) self._cursor = LVecBase2i(0) self._last_size = 14