UiTransformSystem Class
Computes screen positions for UI elements based on layout configuration. More...
Declaration
Base class
| class | System |
|
Abstract base class for game systems. More... | |
Public Member Functions Index
| void | update (helios::engine::runtime::world::UpdateContext &updateContext) noexcept override |
|
Computes and applies screen positions for all UI elements. More... | |
Private Member Functions Index
| helios::math::vec3f | anchor (const helios::math::vec3f unanchored, helios::math::vec3f size, const helios::engine::modules::ui::layout::Anchor pivot) |
|
Adjusts position based on pivot point and element size. More... | |
Description
Computes screen positions for UI elements based on layout configuration.
This system processes entities with UiTransformComponent and computes their final screen positions. The positioning algorithm considers:
- **Anchor:** Where the element attaches to its parent (Center, TopLeft, etc.)
- **Pivot:** The element's own reference point for positioning
- **Offsets:** Margins from the anchor point (top, right, bottom, left)
- **Viewport:** Current viewport dimensions for root-level elements
- **Parent bounds:** For nested UI elements via HierarchyComponent
## Hierarchy Support
For elements with a HierarchyComponent, the system uses the parent entity's AABB and transform to compute relative positioning. Root elements (those attached to the scene root) use viewport dimensions as their parent bounds.
## Required Components
| Component | Purpose | |-----------|---------| | `UiTransformComponent` | Layout configuration (anchor, pivot, offsets) | | `TranslationStateComponent` | Receives computed position | | `ComposeTransformComponent` | Transform composition | | `ModelAabbComponent` | Element bounds for size calculations | | `SceneNodeComponent` | Scene graph integration | | `Active` | Lifecycle tag |
- See Also
UiTransformComponent
- See Also
Anchor
- See Also
HierarchyComponent
Definition at line 68 of file UiTransformSystem.ixx.
Public Member Functions
update()
| inline noexcept virtual |
Computes and applies screen positions for all UI elements.
Iterates over all entities with UI layout components and computes their final screen positions. For each entity:
1. Finds the matching viewport snapshot by viewportId 2. Determines parent bounds (viewport for root, parent AABB otherwise) 3. Computes anchor position based on anchor type and offsets 4. Adjusts for pivot point 5. Updates TranslationStateComponent with final position
- Parameters
-
updateContext The current frame's update context.
Definition at line 123 of file UiTransformSystem.ixx.
References helios::engine::modules::ui::layout::BottomLeft, helios::engine::modules::ui::layout::Center, helios::engine::ecs::System::gameWorld_, helios::engine::modules::ui::layout::TopLeft and helios::engine::modules::ui::layout::TopRight.
Private Member Functions
anchor()
| inline |
Adjusts position based on pivot point and element size.
Transforms a position from anchor-relative to pivot-relative coordinates. The pivot determines which point of the element is placed at the anchor position.
- Parameters
-
unanchored The position before pivot adjustment.
size The size of the element.
pivot The pivot point to apply.
- Returns
The adjusted position accounting for pivot offset.
Definition at line 83 of file UiTransformSystem.ixx.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.