5#include "core/reflect.h"
13 glm::vec2
pos = {0.0f, 0.0f};
14 glm::vec2 size = {0.0f, 0.0f};
16 glm::vec2 max()
const {
return pos + size; }
18 bool contains(
const glm::vec2& point)
const {
19 return point.x >=
pos.x && point.x <
pos.x + size.x
20 && point.y >=
pos.y && point.y <
pos.y + size.y;
32 const glm::vec2 lo = glm::max(
pos, other.
pos);
33 const glm::vec2 hi = glm::min(max(), other.max());
34 return UIRect{lo, glm::max(hi - lo, glm::vec2(0.0f))};
50 glm::vec2
size = {100.0f, 100.0f};
89 element.
anchor = anchorPivot;
90 element.
pivot = anchorPivot;
The 2D rect of a UI node - the screen-space analogue of Transform.
Definition ui_element.h:44
bool blocksPointer
Whether this element stops a pointer reaching what is behind it.
Definition ui_element.h:67
UIRect screenRect
Resolved rect in screen pixels, written each frame.
Definition ui_element.h:77
glm::vec2 relativeSize
The share of the parent's size this element takes, added to size.
Definition ui_element.h:58
static UIElement at(const glm::vec2 &anchorPivot, const glm::vec2 &position, const glm::vec2 &size)
An element pinned to one normalised point of its parent by the matching point of itself.
Definition ui_element.h:87
glm::vec2 anchor
Parent anchor point, normalised (0,0 = top-left, 1,1 = bottom-right).
Definition ui_element.h:46
glm::vec2 size
Element size, in canvas reference pixels, added to relativeSize's share.
Definition ui_element.h:50
glm::vec2 pivot
Element pivot, normalised; the point placed at the anchor.
Definition ui_element.h:47
glm::vec2 position
Definition ui_element.h:48
bool clipChildren
Whether this element's rect bounds what its descendants may draw.
Definition ui_element.h:75
bool visible
Skip this element and its whole subtree when false.
Definition ui_element.h:60
An axis-aligned screen-space rectangle (top-left origin, pixels).
Definition ui_element.h:12
glm::vec2 pos
Top-left corner.
Definition ui_element.h:13
UIRect intersected(const UIRect &other) const
The overlap of this rect and other, empty when they miss.
Definition ui_element.h:31