14#include "../macros.hpp"
16namespace hi {
inline namespace v1 {
46 hi_assert_not_null(delegate);
47 delegate->deinit(*
this);
57 hi_axiom(loop::main().on_thread());
58 hi_assert_not_null(
parent);
63 hi_assert_not_null(this->delegate);
64 _delegate_cbt = this->delegate->subscribe([&] {
65 ++global_counter<
"tab_widget:delegate:constrain">;
69 this->delegate->init(*
this);
95 hi_axiom(loop::main().on_thread());
97 auto tmp = std::make_unique<WidgetType>(
this, std::forward<Args>(args)...);
100 hi_assert_not_null(delegate);
101 delegate->add_tab(*
this,
static_cast<std::size_t>(key), size(_children));
103 ++global_counter<
"tab_widget:make_widget:constrain">;
111 for (hilet& child : _children) {
124 hi_log_info(
"tab_widget::update_constraints() selected tab changed");
128 for (hilet& child : _children) {
134 void set_layout(widget_layout
const&
context)
noexcept override
138 for (hilet& child : _children) {
144 void draw(draw_context
const&
context)
noexcept override
147 for (hilet& child : _children) {
152 [[
nodiscard]] hitbox hitbox_test(point2 position)
const noexcept override
154 hi_axiom(loop::main().on_thread());
158 for (hilet& child : _children) {
159 r = child->hitbox_test_from_parent(position, r);
166 [[
nodiscard]] widget_id find_next_widget(
168 keyboard_focus_group group,
169 keyboard_focus_direction direction)
const noexcept override
171 hi_axiom(loop::main().on_thread());
176 widget const *_previous_selected_child =
nullptr;
178 notifier<>::callback_token _delegate_cbt;
180 using const_iterator =
decltype(_children)::const_iterator;
184 hi_axiom(loop::main().on_thread());
185 hi_assert_not_null(delegate);
187 auto index = delegate->index(
const_cast<tab_widget&
>(*
this));
188 if (index >= 0
and index <
ssize(_children)) {
189 return _children.
begin() + index;
192 return _children.
end();
196 hi_axiom(loop::main().on_thread());
199 auto i = find_selected_child();
200 if (i != _children.
cend()) {
203 return *_children.
front();
Defines delegate_delegate and some default tab delegates.
@ window_reconstrain
Request that widget get constraint on the next frame.
@ window_resize
Request that the window resizes to desired constraints on the next frame.
std::shared_ptr< tab_delegate > make_default_tab_delegate(auto &&value) noexcept
Create a shared pointer to a default tab delegate.
Definition tab_delegate.hpp:103
@ partial
A widget is partially enabled.
@ invisible
The widget is invisible.
@ enabled
The widget is fully enabled.
DOXYGEN BUG.
Definition algorithm.hpp:16
geometry/margins.hpp
Definition lookahead_iterator.hpp:5
constexpr Out narrow_cast(In const &rhs) noexcept
Cast numeric values without loss of precision.
Definition cast.hpp:377
widget_intf * parent
Pointer to the parent widget.
Definition widget_intf.hpp:28
A delegate that controls the state of a tab_widget.
Definition tab_delegate.hpp:22
A graphical element that shows only one of a predefined set of mutually exclusive child widgets.
Definition tab_widget.hpp:37
tab_widget(widget *parent, different_from< std::shared_ptr< delegate_type > > auto &&value) noexcept
Construct a tab widget with an observer value.
Definition tab_widget.hpp:78
WidgetType & make_widget(Key const &key, Args &&...args)
Make and add a child widget.
Definition tab_widget.hpp:93
tab_widget(widget *parent, std::shared_ptr< delegate_type > delegate) noexcept
Construct a tab widget with a delegate.
Definition tab_widget.hpp:55
An interactive graphical object as part of the user-interface.
Definition widget.hpp:37
int semantic_layer
The draw layer of the widget.
Definition widget.hpp:66
virtual widget_id find_next_widget(widget_id current_keyboard_widget, keyboard_focus_group group, keyboard_focus_direction direction) const noexcept override
Find the next widget that handles keyboard focus.
Definition widget.hpp:288
widget(widget *parent) noexcept
Definition widget.hpp:87
bool process_event(gui_event const &event) const noexcept override
Send a event to the window.
Definition widget.hpp:178
observer< widget_mode > mode
The widget mode.
Definition widget.hpp:42
Definition concepts.hpp:54