def hit_test(self, x, y): if self._content is not None: return Rectangle(self._content.x, self._content.y, self._content.width, self._content.height).is_inside(x, y) else: return False
def __init__(self, content, theme, window=None, batch=None, group=None, anchor=ANCHOR_CENTER, offset=(0, 0)): super(ViewerManager, self).__init__(content, anchor=anchor) assert isinstance(theme, dict) self._theme = theme self._manager = self self._offset = offset if batch is None: self._batch = pyglet.graphics.Batch() self._has_own_batch = True else: self._batch = batch self._has_own_batch = False self._root_group = ViewerManagerGroup(parent=group) self.group = {'panel': pyglet.graphics.OrderedGroup(10, self.root_group), 'background': pyglet.graphics.OrderedGroup(20, self.root_group), 'foreground': pyglet.graphics.OrderedGroup(30, self.root_group), 'highlight': pyglet.graphics.OrderedGroup(40, self.root_group)} self.content.set_manager(self) self.content.parent = self self.screen = Rectangle() self.load() self._window = None self.window = window
def layout(self): self._frame.update(self.x, self.y, self.width, self.height) # we create a rectangle with the interior for using in GetRelativePoint x, y, width, height = self._frame.get_content_region() interior = Rectangle(x, y, width, height) x, y = GetRelativePoint(interior, self.anchor, self.content, self.anchor, self.content_offset) self.content.set_position(x, y)
def window(self, window): if self._window is not None: self._window.remove_handlers(self) self._window = window if self._window is None: self.unload() self.screen = Rectangle() else: width, height = window.get_size() self.screen = Rectangle(width=width, height=height) window.push_handlers(self) # make a top-down reset_size. self.reset_size(reset_parent=False) # and set the new position. self.set_position(*self.get_position())
def layout(self): row_index = 0 placement = Rectangle() placement.y = self.y + self.height for row in self._matrix: col_index = 0 placement.x = self.x placement.height = self._max_heights[row_index] placement.y -= placement.height for item in row: placement.width = self._max_widths[col_index] if item is not None: if item.is_expandable(): item.expand(placement.width, placement.height) item.set_position(*GetRelativePoint(placement, self.anchor, item, self.anchor, self.offset)) placement.x += placement.width col_index += 1 row_index += 1
def layout(self): row_index = 0 placement = Rectangle() placement.y = self.y + self.height for row in self._matrix: col_index = 0 placement.x = self.x placement.height = self._max_heights[row_index] placement.y -= placement.height for item in row: placement.width = self._max_widths[col_index] if item is not None: if item.is_expandable(): item.expand(placement.width, placement.height) item.set_position( *GetRelativePoint(placement, self.anchor, item, self.anchor, self.offset)) placement.x += placement.width col_index += 1 row_index += 1