Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
UINode.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
3#pragma once
4
6#include "../../ui/UITypes.hpp" // Dimension
8#include "../../math/Math.hpp" // glm::vec2 (computed output)
9
10namespace esengine::ecs {
11
17ES_ENUM()
25
33ES_ENUM()
38
45ES_ENUM()
46enum class UIDisplay : u8 {
49};
50
57ES_ENUM()
63
79struct UINode {
80 // Positioning: Relative = in flex flow; Absolute = placed by `inset`.
83
84 ES_PROPERTY(tooltip="None removes this node and its whole subtree from layout, rendering and input.")
86
94 ES_PROPERTY(min=0, max=1, tooltip="Subtree opacity, multiplied down the tree. Fades this node and everything under it.")
95 f32 opacity{1.0f};
96
97 ES_PROPERTY(tooltip="None makes this node and its subtree transparent to the pointer — hits pass through to what is behind.")
99
100 // Box size; auto = content-/flex-driven.
102 Dimension width{0.0f, 2};
113
114 // Flex item behaviour.
123
124 // Outer margin (px by default).
133
134 // Inset (offset from the parent's edges) for Absolute positioning;
135 // auto = that edge is unconstrained (size/flow decides). Mirrors CSS
136 // left/top/right/bottom.
145
146 // Layout output (not serialized): resolved px size written by the Yoga pass.
147 glm::vec2 computed_size_{0.0f};
148
149 // Computed (not serialized): true when this node or any ancestor has
150 // display None. Written by the layout pass; read by rendering, text and
151 // hit-testing so the whole subtree disappears from all three.
152 bool hidden_in_tree_{false};
153
154 // Computed (not serialized), same pass and same contract as hidden_in_tree_:
155 // the product of this node's `opacity` and every ancestor's, and whether any
156 // ancestor (or this node) turned pointer events off. Rendering multiplies the
157 // first in; hit-testing skips on the second. Consumers stay tree-unaware.
160
161 // Set by the tween system for Transform fields it drives, so the layout pass
162 // leaves those fields alone this frame (cleared each frame).
164 static constexpr u8 ANIM_POS_X = 1;
165 static constexpr u8 ANIM_POS_Y = 2;
166 static constexpr u8 ANIM_ROT_Z = 4;
167 static constexpr u8 ANIM_SCALE_X = 8;
168 static constexpr u8 ANIM_SCALE_Y = 16;
169
170 UINode() = default;
171};
172
173} // namespace esengine::ecs
Math utilities and GLM configuration for ESEngine.
Reflection and metadata system for automatic binding generation.
#define ES_COMPONENT(...)
Mark a struct/class as a component that should be exposed to scripts.
#define ES_ENUM(...)
Mark an enum that should be exposed to scripts.
#define ES_PROPERTY(...)
Mark a field as a property that should be exposed to scripts.
Core type definitions and utilities for ESEngine.
@ None
Masks reaching this sprite are ignored.
Definition Sprite.hpp:72
UIPositionType
Box positioning scheme. Absolute takes the node out of flex flow and places it by inset against the p...
Definition UINode.hpp:34
AlignSelf
Per-item cross-axis alignment override (CSS align-self). Lives on UINode since UINode carries the fle...
Definition UINode.hpp:18
UIDisplay
CSS display. None removes the node AND its whole subtree from layout, rendering, and hit-testing — th...
Definition UINode.hpp:46
UIPointerEvents
CSS pointer-events. None makes the node AND its subtree transparent to the pointer (drawn,...
Definition UINode.hpp:58
std::uint8_t u8
Unsigned 8-bit integer.
Definition Types.hpp:41
float f32
32-bit floating point
Definition Types.hpp:59
A CSS-style length: value interpreted per unit.
Definition UITypes.hpp:26
static constexpr u8 ANIM_SCALE_X
Definition UINode.hpp:167
Dimension marginRight
Definition UINode.hpp:130
Dimension insetBottom
Definition UINode.hpp:144
static constexpr u8 ANIM_ROT_Z
Definition UINode.hpp:166
UIPointerEvents pointerEvents
Definition UINode.hpp:98
glm::vec2 computed_size_
Definition UINode.hpp:147
UIPositionType position
Definition UINode.hpp:82
static constexpr u8 ANIM_POS_X
Definition UINode.hpp:164
Dimension marginBottom
Definition UINode.hpp:132
static constexpr u8 ANIM_POS_Y
Definition UINode.hpp:165
static constexpr u8 ANIM_SCALE_Y
Definition UINode.hpp:168