Example #1
0
    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)
Example #2
0
    def get_position(self):
        # Calculate our position relative to our containing window,
        # making sure that we fit completely on the window.  If our offset
        # would send us off the screen, constrain it.
        x, y = GetRelativePoint(self.screen, self.anchor, self, None, (0, 0))
        max_offset_x = self.screen.width - self.width - x
        max_offset_y = self.screen.height - self.height - y
        offset_x, offset_y = self._offset
        offset_x = max(min(offset_x, max_offset_x), -x)
        offset_y = max(min(offset_y, max_offset_y), -y)
        self._offset = (offset_x, offset_y)
        x += offset_x
        y += offset_y

        return x, y
 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):
     x, y = GetRelativePoint(self, self.anchor, self.content, self.anchor,
                             self.content_offset)
     self.content.set_position(x, y)