def __init__(self, frame, items): """items: list of views; str(item) used for selection display""" assert len(items) > 0 view.View.__init__(self, pygame.Rect(frame.topleft, (1, 1))) self.on_selection_changed = callback.Signal() self.on_list_opened = callback.Signal() self.top_label = label.Label(pygame.Rect(0, 0, 1, 1), '') self.top_label.halign = label.LEFT self.top_label._enabled = True self.top_label.on_mouse_down.connect(self.show_list) self.add_child(self.top_label) self.list_view = listview.ListView(pygame.Rect(0, 0, 1, 1), items) self.list_view.on_selected.connect(self.item_selected) self.list_view.on_deselected.connect(self.item_deselected) self.scroll_view = scroll.ScrollView(pygame.Rect(0, 0, 1, 1), self.list_view) self.scroll_view.hidden = True self.add_child(self.scroll_view) self.disclosure = button.Button(pygame.Rect(0, 0, 1, 1), caption='') self.disclosure.on_clicked.connect(self._toggle_show_list) self.add_child(self.disclosure)
def __init__(self, frame, items): """items: list of views""" frame.size = self._find_size_to_contain(items) view.View.__init__(self, frame) self.items = items self.selected_index = None self.on_selected = callback.Signal() self.on_deselected = callback.Signal()
def __init__(self, rect): self.rect = rect self.background_color = None self.select_background_color = None self.border_widths = 1 self.border_color = None self.stylise() self.selected = False self.enabled = True self.dirty = True self.surface = pygame.Surface((self.rect.w, self.rect.h)).convert() self.on_mouse_up = callback.Signal() self.on_mouse_down = callback.Signal()
def __init__(self, frame, text): view.View.__init__(self, frame) self.checked = False check_frame = pygame.Rect(0, 0, 1, 1) self.check_label = label.Label(check_frame, ' ') self.add_child(self.check_label) self.label = label.Label(pygame.Rect(0, 0, 1, 1), text) self.add_child(self.label) self.on_checked = callback.Signal() self.on_unchecked = callback.Signal()
def __init__(self, rect, text): ''' Constructor ''' label.Label.__init__(self, rect, text) self.enabled = True self.on_clicked = callback.Signal()
def __init__(self, rect, img, img_rect=None): if rect is None: rect = pygame.Rect((0, 0), img.get_size()) elif rect.w == 0 and rect.h == 0: rect.size = img.get_size() if img_rect is None: img_rect = pygame.Rect((0, 0), rect.size) elif img_rect.w == 0 and img_rect.h == 0: img_rect.size = img.get_size() object_rectangle.ObjectRectangle.__init__(self, rect) self.on_clicked = callback.Signal() self.image_view = imageview.ImageView( pygame.Rect(self.rect.w / 2 - img_rect.w / 2, self.rect.h / 2 - img_rect.h / 2, img_rect.w, img_rect.h), img) self.image_surface = pygame.Surface( (self.rect.w, self.rect.h)).convert() self.select_over_surface = pygame.Surface( (self.rect.w, self.rect.h)).convert() self.select_over_surface.fill(self.select_background_color) self.select_over_surface.set_alpha(100)
def __init__(self, frame, text='', placeholder=''): view.View.__init__(self, frame) self.text = text or '' self.placeholder = placeholder self.label = label.Label(pygame.Rect((0, 0), frame.size), text or placeholder) self.label.halign = label.LEFT self.add_child(self.label) self.enabled = True self.max_len = None self.secure = False self.on_return = callback.Signal() self.on_text_change = callback.Signal()
def __init__(self, rect, items): self.list_view = StringListView(Rect((0, 0), rect.size), items) scroll.ScrollView.__init__(self, rect, self.list_view) list_view_rect = Rect((0, 0), self.content_frame.rect.size) self.list_view.minimize = list_view_rect.size self.content_view = self.list_view self.on_selected = callback.Signal() self.list_view.on_selected = self.on_selected
def __init__(self, frame, image): if frame is None: frame = pygame.Rect((0, 0), image.get_size()) elif frame.w == 0 or frame.h == 0: frame.size = image.get_size() view.View.__init__(self, frame) self.on_clicked = callback.Signal() self.image_view = imageview.ImageView(pygame.Rect(0, 0, 0, 0), image) self.image_view._enabled = False self.add_child(self.image_view)
def __init__(self, frame, direction, low, high, show_thumb=True): view.View.__init__(self, frame) self.on_value_changed = callback.Signal() self.direction = direction self.low = min(low, high) self.high = max(low, high) self.thumb = scroll.ScrollbarThumbView(self.direction) self.thumb.hidden = (not show_thumb) self._add_track(show_thumb) self.add_child(self.thumb) self._value = None self.value = (low + high) / 2.0
def __init__(self, frame, content_view): width = frame.size[0] + SCROLLBAR_SIZE height = frame.size[1] + SCROLLBAR_SIZE rect = pygame.Rect(frame.topleft, (width, height)) view.View.__init__(self, rect) self.on_scrolled = callback.Signal() self.content_view = content_view self._content_offset = (0, 0) self.add_child(self.content_view) self.hscrollbar = ScrollbarView(self, HORIZONTAL) self.vscrollbar = ScrollbarView(self, VERTICAL) self.add_child(self.hscrollbar) self.add_child(self.vscrollbar)
def __init__(self, rect, items, row_num=0, minimize=(0, 0)): ''' Constructor ''' object_rectangle.ObjectRectangle.__init__(self, rect) self.row_num = row_num if minimize == (0, 0): minimize = rect.size self.minimize = minimize self.items = [] self._items_font = None self.string_items = items self.selected_index = None self.on_selected = callback.Signal() self.items_surface = pygame.Surface( (self.rect.w - self.border_widths * 2, self.rect.h - self.border_widths * 2)).convert()
def __init__(self, frame=None): self.frame = frame self.parent = None self.children = [] # back->front self._state = 'normal' self._enabled = True self.hidden = False self.draggable = False self.shadow_image = None self.on_focused = callback.Signal() self.on_blurred = callback.Signal() self.on_selected = callback.Signal() self.on_enabled = callback.Signal() self.on_disabled = callback.Signal() self.on_state_changed = callback.Signal() self.on_mouse_up = callback.Signal() self.on_mouse_down = callback.Signal() self.on_mouse_motion = callback.Signal() self.on_mouse_drag = callback.Signal() self.on_key_down = callback.Signal() self.on_key_up = callback.Signal() self.on_parented = callback.Signal() self.on_orphaned = callback.Signal()
def __init__(self, frame, caption): if frame.h == 0: frame.h = theme.current.button_height label.Label.__init__(self, frame, caption) self._enabled = True self.on_clicked = callback.Signal()