ui::Rect¶
Header: winui/core/Geometry.hpp.
Axis-aligned rectangle: (x, y) is the top-left, extents are width/height.
All values are DIPs. The layout rect handed to Element::arrange() is a Rect; a rect with a non-positive extent is empty().
Example:
const ui::Rect bounds{0, 0, 200, 32};
const ui::Rect content = bounds.inset(ui::Edges{.left = 12, .top = 5, .right = 12, .bottom = 6});
const ui::Rect focus = bounds.inflate(3.0f); // focus visual outside the border
const ui::Rect visible = ui::intersection(content, ui::Rect{0, 0, 100, 100}); // {12, 5, 88, 21}
x¶
Left edge, DIPs.
y¶
Top edge, DIPs.
width¶
Horizontal extent, DIPs.
height¶
Vertical extent, DIPs.
Rect¶
The empty rect at the origin.
Rect¶
From top-left corner and extents.
Rect¶
From top-left corner and a Size.
left¶
Same as x.
top¶
Same as y.
right¶
x + width: the first x coordinate outside the rect.
bottom¶
y + height: the first y coordinate outside the rect.
origin¶
The top-left corner.
size¶
The extents as a Size.
center¶
The midpoint of the rect.
empty¶
True if either extent is zero or negative.
contains¶
Point-in-rect test. Left/top edges are inclusive, right/bottom exclusive.
intersects¶
True if the two rects share some area. Rects that only share an edge do not overlap, and an empty rect overlaps nothing.
inset¶
Shrink inward by a thickness (padding). Never produces negative extents.
inflate¶
Grow outward uniformly by amount on every edge. A negative amount shrinks, unclamped.