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>(
window, shared_from_this(), std::forward<Args>(args)...);
90 [[nodiscard]]
virtual bool is_toolbar() const noexcept
92 return parent().is_toolbar();
101 for (
auto &&child : _children) {
103 tt_axiom(&child->parent() ==
this);
104 has_constrainted |= child->update_constraints(display_time_point, need_reconstrain);
107 return has_constrainted;
114 need_layout |= std::exchange(_request_relayout,
false);
115 for (
auto &&child : _children) {
117 tt_axiom(&child->parent() ==
this);
118 child->update_layout(display_time_point, need_layout);
128 for (
auto &child : _children) {
130 tt_axiom(&child->parent() ==
this);
133 context.make_child_context(child->parent_to_local(), child->local_to_window(), child->clipping_rectangle());
134 child->draw(child_context, display_time_point);
144 auto handled =
false;
145 for (
auto &child : _children) {
147 tt_axiom(&child->parent() ==
this);
148 handled |= child->handle_command_recursive(command, reject_list);
159 for (ttlet &child : _children) {
161 tt_axiom(&child->parent() ==
this);
162 r =
std::max(r, child->hitbox_test(
point2{child->parent_to_local() * position}));
169 for (ttlet child : _children) {
170 if (child->accepts_keyboard_focus(group)) {
179 for (ttlet child :
std::views::
reverse(_children)) {
180 if (child->accepts_keyboard_focus(group)) {
189 keyboard_focus_group group,
190 keyboard_focus_direction direction)
const noexcept
192 ttlet lock = std::scoped_lock(gui_system_mutex);
193 tt_axiom(direction != keyboard_focus_direction::current);
196 auto found = !current_keyboard_widget;
203 ssize_t first = direction == keyboard_focus_direction::forward ? 0 : ssize(_children) - 1;
204 ssize_t last = direction == keyboard_focus_direction::forward ? ssize(_children) : -1;
205 ssize_t step = direction == keyboard_focus_direction::forward ? 1 : -1;
206 for (
ssize_t i = first; i != last; i += step) {
207 auto &&child = _children[i];
212 if (
auto tmp = child->find_next_widget({}, group, direction)) {
217 auto tmp = child->find_next_widget(current_keyboard_widget, group, direction);
218 if (tmp == current_keyboard_widget) {
Draw context for drawing using the TTauri shaders.
Definition draw_context.hpp:33
Definition gui_window.hpp:37
std::atomic< bool > requestLayout
When set to true the widgets will be layed out.
Definition gui_window.hpp:54
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:110
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:124
hit_box hitbox_test(point2 position) const noexcept override
Find the widget that is under the mouse cursor.
Definition abstract_container_widget.hpp:154
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:187
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:140
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:95
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:101
virtual void draw(draw_context context, hires_utc_clock::time_point display_time_point) noexcept
Draw the widget.
Definition widget.hpp:462
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:386
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)