2#ifndef LIBSBX_UI_ELEMENT_HPP_
3#define LIBSBX_UI_ELEMENT_HPP_
9#include <libsbx/math/vector2.hpp>
10#include <libsbx/math/vector3.hpp>
11#include <libsbx/math/matrix4x4.hpp>
14#include <libsbx/graphics/images/image.hpp>
16#include <libsbx/sprites/sprites_module.hpp>
18#include <libsbx/ui/layout.hpp>
33 std::int32_t sort_order{0};
34 bool is_enabled{
true};
35 bool is_interactive{
false};
43 auto add_child(std::unique_ptr<element> child) ->
element&;
45 auto remove_child(
element& child) -> void;
47 [[nodiscard]]
auto children()
const ->
const std::vector<std::unique_ptr<element>>&;
49 [[nodiscard]]
auto children() -> std::vector<std::unique_ptr<element>>&;
51 [[nodiscard]]
auto computed_rectangle()
const ->
const rectangle&;
53 template<
typename Type,
typename... Args>
54 requires (std::is_base_of_v<ui::layout, Type>)
55 auto set_layout(Args&&... args) -> Type& {
56 auto layout = std::make_unique<Type>(std::forward<Args>(args)...);
59 _layout = std::move(
layout);
64 auto clear_layout() -> void;
66 [[nodiscard]]
auto has_layout()
const -> bool;
68 auto resolve_layout(
const rectangle& parent_rectangle) -> void;
70 auto resolve_as_arranged(
const rectangle& arranged_rect) -> void;
74 auto process_input_tree(
const math::vector2& mouse_position,
bool is_down,
bool was_down) -> bool;
78 virtual auto submit(
const math::vector2& screen_size) ->
void { }
80 virtual auto process_input(
const math::vector2& mouse_position,
bool is_down,
bool was_down) ->
bool {
return false; }
82 auto submit_quad(
const math::vector2& screen_size,
const math::vector2& quad_position,
const math::vector2& quad_size,
const math::vector2& quad_pivot,
const math::color& quad_color, std::uint32_t albedo_index, std::int32_t quad_sort_order,
const math::vector2& uv_min,
const math::vector2& uv_max, std::uint32_t flags, std::float_t sdf_px_range = 0.0f) -> void;
86 auto _resolve_self(
const rectangle& parent_rectangle) -> void;
89 std::vector<std::unique_ptr<element>> _children;
91 std::unique_ptr<ui::layout> _layout{};
A vector in two-dimensional space.
Definition: vector2.hpp:28
RGBA color value type.
Definition: color.hpp:48
Definition: element.hpp:22
Definition: layout.hpp:39
RGBA color representation and utilities.
Definition: layout.hpp:15
Definition: layout.hpp:32