SourceClass RectAlign
from egui import RectAlignclass RectAlign:Constants§
BOTTOM: Final[RectAlign]§
BOTTOM_END: Final[RectAlign]§
BOTTOM_START: Final[RectAlign]§
LEFT: Final[RectAlign]§
LEFT_END: Final[RectAlign]§
LEFT_START: Final[RectAlign]§
RIGHT: Final[RectAlign]§
RIGHT_END: Final[RectAlign]§
RIGHT_START: Final[RectAlign]§
TOP: Final[RectAlign]§
TOP_END: Final[RectAlign]§
TOP_START: Final[RectAlign]§
Properties§
Source@property
def child(self, /) -> Align2§
Align in the child rect.
@child.setter
def child(self, /, child: Align2) -> None§
Source@property
def parent(self, /) -> Align2§
Align in the parent rect.
@parent.setter
def parent(self, /, parent: Align2) -> None§
Methods§
Sourcedef align_rect(self, /, parent_rect: Rect, size: Vec2, gap: float) -> Rect§
Calculate the child rect based on a size and some optional gap.
Sourcedef anchor(self, /, parent_rect: Rect, gap: float) -> Pos2§
Calculator the anchor point for the child rect, based on the parent rect and an optional gap.
@staticmethod
def default() -> RectAlign§
Source@staticmethod
def find_best_align(values_to_try: Sequence[RectAlign], content_rect: Rect, parent_rect: Rect, gap: float, expected_size: Vec2) -> RectAlign |None§
Look for the first alternative RectAlign that allows the child rect to fit
inside the content_rect.
If no alternative fits, the first is returned.
If no alternatives are given, None is returned.
See also:
- RectAlign.symmetries to calculate alternatives
- RectAlign.MENU_ALIGNS for the 12 common menu positions
Sourcedef flip(self, /) -> RectAlign§
Flip the alignment on both axes.
Sourcedef flip_x(self, /) -> RectAlign§
Flip the alignment on the x-axis.
Sourcedef flip_y(self, /) -> RectAlign§
Flip the alignment on the y-axis.
Source@staticmethod
def from_align2(align: Align2) -> RectAlign§
Sourcedef gap_vector(self, /) -> Vec2§
Returns a sign vector (-1, 0 or 1 in each direction) that can be used as an offset to the child rect, creating a gap between the rects while keeping the edges aligned.
def name(self, /) -> str§
Source@staticmethod
def outside(align: Align2) -> RectAlign§
Position the child rect outside the parent rect.
Source@staticmethod
def over_corner(align: Align2) -> RectAlign§
The center of the child rect will be aligned to a corner of the parent rect.
Sourcedef pivot_pos(self, /, parent_rect: Rect, gap: float) -> tuple[Align2, Pos2]§
Sourcedef symmetries(self, /) -> list[RectAlign]§
Returns the 3 alternative RectAligns that are flipped in various ways, for use
with RectAlign.find_best_align.