20 ttlet lock = std::scoped_lock(gui_system_mutex);
33 _request_reconstrain =
true;
41 ttlet lock = std::scoped_lock(gui_system_mutex);
44 _children.push_back(
widget);
45 _request_reconstrain =
true;
50 [[nodiscard]]
widget &front() noexcept
52 return *_children.front();
55 [[nodiscard]]
widget const &front() const noexcept
57 return *_children.front();
60 [[nodiscard]]
widget &back() noexcept
62 return *_children.back();
65 [[nodiscard]]
widget const &back() const noexcept
67 return *_children.back();
82 template<
typename T,
typename... Args>
85 auto tmp = std::make_shared<T>(
86 window, shared_from_this(), std::forward<Args>(args)...);
91 [[nodiscard]]
virtual bool is_toolbar() const noexcept
93 return parent().is_toolbar();
102 for (
auto &&child : _children) {
104 tt_axiom(&child->parent() ==
this);
105 has_constrainted |= child->update_constraints(display_time_point, need_reconstrain);
108 return has_constrainted;
115 need_layout |= std::exchange(_request_relayout,
false);
116 for (
auto &&child : _children) {
118 tt_axiom(&child->parent() ==
this);
119 child->update_layout(display_time_point, need_layout);
129 for (
auto &child : _children) {
131 tt_axiom(&child->parent() ==
this);
132 child->draw(child->make_draw_context(context), display_time_point);
142 auto handled =
false;
143 for (
auto &child : _children) {
145 tt_axiom(&child->parent() ==
this);
146 handled |= child->handle_command_recursive(command, reject_list);
154 ttlet lock = std::scoped_lock(gui_system_mutex);
157 for (ttlet &child : _children) {
159 tt_axiom(&child->parent() ==
this);
160 r =
std::max(r, child->hitbox_test(window_position));
167 for (ttlet child : _children) {
168 if (child->accepts_keyboard_focus(group)) {
177 for (ttlet child :
std::views::
reverse(_children)) {
178 if (child->accepts_keyboard_focus(group)) {
187 keyboard_focus_group group,
188 keyboard_focus_direction direction)
const noexcept
190 ttlet lock = std::scoped_lock(gui_system_mutex);
191 tt_axiom(direction != keyboard_focus_direction::current);
194 auto found = !current_keyboard_widget;
201 ssize_t first = direction == keyboard_focus_direction::forward ? 0 : ssize(_children) - 1;
202 ssize_t last = direction == keyboard_focus_direction::forward ? ssize(_children) : -1;
203 ssize_t step = direction == keyboard_focus_direction::forward ? 1 : -1;
204 for (
ssize_t i = first; i != last; i += step) {
205 auto &&child = _children[i];
210 if (
auto tmp = child->find_next_widget({}, group, direction)) {
215 auto tmp = child->find_next_widget(current_keyboard_widget, group, direction);
216 if (tmp == current_keyboard_widget) {
Draw context for drawing using the TTauri shaders.
Definition draw_context.hpp:33
Definition gui_window.hpp:39
std::atomic< bool > requestLayout
When set to true the widgets will be layed out.
Definition gui_window.hpp:56
Definition hit_box.hpp:15
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
std::shared_ptr< T > make_widget(Args &&...args)
Add a widget directly to this widget.
Definition abstract_container_widget.hpp:83
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
void clear() noexcept
Remove and deallocate all child widgets.
Definition abstract_container_widget.hpp:30
void draw(draw_context context, hires_utc_clock::time_point display_time_point) noexcept
Draw the widget.
Definition abstract_container_widget.hpp:125
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.
Definition abstract_container_widget.hpp:185
hit_box hitbox_test(f32x4 window_position) const noexcept
Find the widget that is under the mouse cursor.
Definition abstract_container_widget.hpp:152
bool handle_command_recursive(command command, std::vector< std::shared_ptr< widget > > const &reject_list) noexcept override
Handle command recursive.
Definition abstract_container_widget.hpp:138
std::shared_ptr< widget > add_widget(std::shared_ptr< widget > widget) noexcept
Add a widget directly to this widget.
Definition abstract_container_widget.hpp:39
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
virtual void update_layout(hires_utc_clock::time_point display_time_point, bool need_layout) noexcept
Update the internal layout of the widget.
virtual bool handle_command_recursive(command command, std::vector< std::shared_ptr< widget > > const &reject_list) noexcept
Handle command recursive.
widget(gui_window &window, std::shared_ptr< abstract_container_widget > parent) noexcept
gui_window & window
Convenient reference to the Window.
Definition widget.hpp:100
virtual void draw(draw_context context, hires_utc_clock::time_point display_time_point) noexcept
Draw the widget.
Definition widget.hpp:460
virtual bool update_constraints(hires_utc_clock::time_point display_time_point, bool need_reconstrain) noexcept
Update the constraints of the widget.
virtual bool accepts_keyboard_focus(keyboard_focus_group group) const noexcept
Check if the widget will accept keyboard focus.
Definition widget.hpp:381
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
T shared_from_this(T... args)