7#include "abstract_container_widget.hpp"
8#include "grid_layout_widget.hpp"
20 template<
typename Value>
26 ttlet lock = std::scoped_lock(gui_system_mutex);
32 _value_callback = value.subscribe([
this](
auto...) {
33 this->_request_reconstrain =
true;
44 if (has_updated_contraints) {
46 ttlet &child = selected_child();
47 _preferred_base_line = child.preferred_base_line();
48 if (compare_then_assign(_preferred_size, child.preferred_size())) {
54 return has_updated_contraints;
61 need_layout |= std::exchange(_request_relayout,
false);
63 for (
auto &child : _children) {
65 child->set_layout_parameters(_window_rectangle, _window_clipping_rectangle, _window_base_line);
76 draw_child(context, display_time_point, selected_child());
82 ttlet lock = std::scoped_lock(gui_system_mutex);
83 return selected_child().
hitbox_test(window_position);
88 keyboard_focus_group group,
89 keyboard_focus_direction direction)
const noexcept
91 ttlet lock = std::scoped_lock(gui_system_mutex);
98 ttlet lock = std::scoped_lock(gui_system_mutex);
100 auto widget = super::make_widget<WidgetType>(std::forward<Args>(args)...);
106 typename decltype(value)::callback_ptr_type _value_callback;
110 [[nodiscard]]
auto find_child(value_type index)
const noexcept
113 tt_axiom(std::size(_children_keys) == std::size(_children));
116 if (child_key_it != _children_keys.
cend()) {
118 return _children.begin() + child_index;
120 return _children.cend();
124 [[nodiscard]]
auto find_child(value_type index)
noexcept
127 tt_axiom(std::size(_children_keys) == std::size(_children));
130 if (child_key_it != _children_keys.
cend()) {
132 return _children.cbegin() + child_index;
134 return _children.cend();
138 [[nodiscard]]
auto find_selected_child() const noexcept
141 return find_child(*value);
144 [[nodiscard]]
auto find_selected_child() noexcept
147 return find_child(*value);
150 [[nodiscard]]
widget const &selected_child() const noexcept
153 tt_axiom(std::ssize(_children) != 0);
155 auto i = find_selected_child();
156 if (i != _children.cend()) {
159 return *_children.front();
163 [[nodiscard]]
widget &selected_child() noexcept
166 tt_axiom(std::ssize(_children) != 0);
168 auto i = find_selected_child();
169 if (i != _children.cend()) {
172 return *_children.front();
176 void draw_child(draw_context context, hires_utc_clock::time_point displayTimePoint,
widget &child)
noexcept
179 child.draw(child.make_draw_context(context), displayTimePoint);
Draw context for drawing using the TTauri shaders.
Definition draw_context.hpp:33
Definition gui_window.hpp:39
std::atomic< bool > requestResize
When set to true the window will resize to the size of the contained widget.
Definition gui_window.hpp:60
Definition hit_box.hpp:15
Definition observable.hpp:20
int recurse_lock_count() const noexcept
This function should be used in tt_axiom() to check if the lock is held by current thread.
Definition unfair_recursive_mutex.hpp:60
Definition abstract_container_widget.hpp:11
void update_layout(hires_utc_clock::time_point display_time_point, bool need_layout) noexcept
Update the internal layout of the widget.
Definition abstract_container_widget.hpp:111
bool update_constraints(hires_utc_clock::time_point display_time_point, bool need_reconstrain) noexcept
Update the constraints of the widget.
Definition abstract_container_widget.hpp:96
Definition grid_layout_widget.hpp:16
Definition tab_view_widget.hpp:13
std::shared_ptr< widget > find_next_widget(std::shared_ptr< widget > const ¤t_widget, keyboard_focus_group group, keyboard_focus_direction direction) const noexcept
Find the next widget that handles keyboard focus.
Definition tab_view_widget.hpp:86
void draw(draw_context context, hires_utc_clock::time_point display_time_point) noexcept override
Draw the widget.
Definition tab_view_widget.hpp:72
bool update_constraints(hires_utc_clock::time_point display_time_point, bool need_reconstrain) noexcept override
Update the constraints of the widget.
Definition tab_view_widget.hpp:39
hit_box hitbox_test(f32x4 window_position) const noexcept override
Find the widget that is under the mouse cursor.
Definition tab_view_widget.hpp:80
void update_layout(hires_utc_clock::time_point display_time_point, bool need_layout) noexcept override
Update the internal layout of the widget.
Definition tab_view_widget.hpp:57
float draw_layer() const noexcept
The first drawing layer of the widget.
Definition widget.hpp:149
widget(gui_window &window, std::shared_ptr< abstract_container_widget > parent) noexcept
virtual std::shared_ptr< widget > find_next_widget(std::shared_ptr< widget > const ¤t_keyboard_widget, keyboard_focus_group group, keyboard_focus_direction direction) const noexcept
Find the next widget that handles keyboard focus.
virtual hit_box hitbox_test(f32x4 window_position) const noexcept
Find the widget that is under the mouse cursor.
Definition widget.hpp:366
gui_window & window
Convenient reference to the Window.
Definition widget.hpp:100
abstract_container_widget const & parent() const noexcept
Get a reference to the parent.
int semantic_layer() const noexcept
The semantic layer of the widget.
Definition widget.hpp:189