def get_minimum_size(self, data): # Find the sizes for each component item_sizes = [ (datatypes.Point(0, 0) if getattr(self, direction) is None else getattr(self, direction).get_minimum_size(data)) for direction in _box_fields ] # Work out how many margins we'll be using w_margins = 0 if self.right is not None: w_margins += self.margin if self.left is not None: w_margins += self.margin h_margins = 0 if self.top is not None: h_margins += self.margin if self.bottom is not None: h_margins += self.margin # Work out the result min_width = max( item_sizes[0].x, item_sizes[2].x, item_sizes[1].x + item_sizes[4].x + item_sizes[3].x + w_margins) min_height = item_sizes[0].y + item_sizes[2].y + h_margins + max( item_sizes[1].y, item_sizes[4].y, item_sizes[3].y) return datatypes.Point(min_width, min_height)
def get_minimum_size(self, data): """The minimum height is the number of rows multiplied by the tallest row.""" min_width = 0 min_height = 0 for element in self.elements: size = (datatypes.Point(0, 0) if element is None else element.get_minimum_size(data)) min_height = max(min_height, size.y) min_width = max(min_width, size.x) num_elements = len(self.elements) height = min_height * num_elements + self.margin * (num_elements - 1) return datatypes.Point(min_width, height)
def get_minimum_size(self, data): """The minimum width is the number of columns multiplied by the widest element.""" min_width = 0 min_height = 0 for element in self.elements: size = (datatypes.Point(0, 0) if element is None else element.get_minimum_size(data)) min_height = max(min_height, size.y) min_width = max(min_width, size.x) num_elements = len(self.elements) width = min_width * num_elements + self.margin * (num_elements - 1) return datatypes.Point(width, min_height)
def _calculate_ms_from_base(self, size): """Calculates the rotated minimum size from the given base minimum size.""" hw = size.x * 0.5 hh = size.y * 0.5 a = datatypes.Point(hw, hh).get_rotated(self.angle) b = datatypes.Point(-hw, hh).get_rotated(self.angle) c = datatypes.Point(hw, -hh).get_rotated(self.angle) d = datatypes.Point(-hw, -hh).get_rotated(self.angle) minp = a.get_minimum(b).get_minimum(c).get_minimum(d) maxp = a.get_maximum(b).get_maximum(c).get_maximum(d) return maxp - minp
def get_minimum_size(self, data): """Returns the rotated minimum size.""" size = self.element.get_minimum_size(data) if self.angle in (RotateLM.NORMAL, RotateLM.UPSIDE_DOWN): return size else: return datatypes.Point(size.y, size.x)
def get_minimum_size(self): # To calculate this, we simply find its farthest right and # down, ignoring any element that starts to the left or below # zero. max_x, max_y = 0, 0 for item, rect in self.elements: max_x = max(max_x, rect.r) max_y = max(max_y, rect.t) return datatypes.Point(max_x, max_y)
def get_minimum_size(self, data): """Minimum width is the total width + margins, minimum height is the largest height.""" width = 0 min_height = 0 for element in self.elements: size = element.get_minimum_size(data) min_height = max(min_height, size.y) width += size.x width += (len(self.elements) - 1) * self.margin return datatypes.Point(width, min_height)
def get_minimum_size(self, data): # Work out what proportion of the total the child takes up. assert 0 <= top + bottom < 1.0, "Top and bottom margins are invalid." assert 0 <= left + right < 1.0, "Left and right margins are invalid." width_scale = 1.0 - left - right height_scale = 1.0 - top - bottom # We divide the child element's size by these values. size = self.element.get_minimum_size(data) return datatypes.Point(size.x / width_scale, size.y / height_scale)
def _get_smallest_dimensions(self, data): """A utility method to return the minimum size needed to fit all the elements in.""" min_width = 0 min_height = 0 for element in self.elements: if not element: continue size = element.get_minimum_size(data) min_width = max(min_width, size.x) min_height = max(min_height, size.y) return datatypes.Point(min_width, min_height)
def get_minimum_size(self, data): """ Minimum height is the total height + margins, minimum width is the largest width. """ min_width = 0 height = 0 for element in self.elements: size = element.get_minimum_size(data) min_width = max(min_width, size.x) height += size.y height += (len(self.elements) - 1) * self.margin return datatypes.Point(min_width, height)
def get_minimum_size(self, data): return datatypes.Point(self.width, self.height)
def get_minimum_size(self, data): self._do_recursion(data, 'get_minimum_size', datatypes.Point(), data)
def get_minimum_size(self, data): """Returns the minimum size of the managed element, as long as it is larger than any manually set minima.""" size = self.element.get_minimum_size(data) return datatypes.Point(max(size.x, self.min_width), max(size.y, self.min_height))
def get_minimum_size(self, data): size = self.element.get_minimum_size(data) return datatypes.Point(size.x + self.right + self.left, size.y + self.top + self.bottom)
def get_minimum_size(self, data) -> datatypes.Point: """How small can the element be? Should return a Point.""" return datatypes.Point(0, 0)
def get_minimum_size(self, data): child_size = self.element.get_minimum_size(data) return datatypes.Point(child_size.x * self.scale, child_size.y * self.scale)