Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
UIVisual.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
7#include "../../math/Math.hpp"
9
10namespace esengine::ecs {
11
23ES_ENUM(stability=beta)
32
40ES_ENUM(stability=beta)
48
49ES_ENUM(stability=beta)
56
65ES_ENUM(stability=beta)
71
83ES_COMPONENT(renderable=enabled, stability=beta)
84struct UIVisual {
87
88 ES_PROPERTY(asset = texture)
90
91 ES_PROPERTY(animatable)
92 glm::vec4 color{1.0f, 1.0f, 1.0f, 1.0f};
93
94 // How the texture fills the box. Ignored by NineSlice and Tiled, whose
95 // whole point is to adapt to the box rather than preserve a ratio.
96 ES_PROPERTY(tooltip="How the image fits its box: Fill stretches, Contain letterboxes it whole, Cover fills and crops.")
98
99 // Base sub-region (identity = whole texture); Tiled/Filled build on it.
101 glm::vec2 uvOffset{0.0f, 0.0f};
103 glm::vec2 uvScale{1.0f, 1.0f};
104
105 // NineSlice border override (texture metadata wins when present).
107 glm::vec4 sliceBorder{0.0f};
108
109 // Tiled: texture repeats every tileSize px of the box.
111 glm::vec2 tileSize{32.0f, 32.0f};
112
113 // Filled: crop to fillAmount [0,1] along method/origin.
118 ES_PROPERTY(animatable)
120
121 ES_PROPERTY(asset = material)
123
125 bool enabled{true};
126
127 // Render order assigned by UIRenderOrderSystem (not serialized).
129
130 // Mask bit of the owning Canvas' layer, for Camera.cullingMask. Assigned by the
131 // same walk as uiOrder (not serialized), because a UI draw's `layer` is order.
133
134 UIVisual() = default;
135};
136
137} // namespace esengine::ecs
Type-safe resource handle system.
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
UIVisualFit
How the texture is fitted into the node's box — CSS object-fit. Fill stretches to the box (the defaul...
Definition UIVisual.hpp:66
UIVisualType
How a UIVisual fills its UINode box. Replaces the old UIRenderer visualType + Image imageType pair: a...
Definition UIVisual.hpp:24
UIFillMethod
Fill mode for a Filled UIVisual. Horizontal/Vertical are linear crops along the axis; the Radial mode...
Definition UIVisual.hpp:41
std::int32_t i32
Signed 32-bit integer.
Definition Types.hpp:54
std::uint32_t u32
Unsigned 32-bit integer.
Definition Types.hpp:45
std::uint8_t u8
Unsigned 8-bit integer.
Definition Types.hpp:41
float f32
32-bit floating point
Definition Types.hpp:59
UIVisualType visualType
Definition UIVisual.hpp:86
UIFillMethod fillMethod
Definition UIVisual.hpp:115
resource::TextureHandle texture
Definition UIVisual.hpp:89
UIFillOrigin fillOrigin
Definition UIVisual.hpp:117