HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
toolbar_tab_button_widget.hpp
Go to the documentation of this file.
1// Copyright Take Vos 2021-2022.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
9#pragma once
10
12
13namespace hi { inline namespace v1 {
14
47public:
49 using delegate_type = typename super::delegate_type;
50
63 button_widget_attribute auto&&...attributes) noexcept :
65 {
66 alignment = alignment::top_center();
67 set_attributes<0>(hi_forward(attributes)...);
68 }
69
82 template<
83 different_from<std::shared_ptr<delegate_type>> Value,
84 forward_of<observer<observer_decay_t<Value>>> OnValue,
85 button_widget_attribute... Attributes>
88 Value&& value,
89 OnValue&& on_value,
90 Attributes&&...attributes) noexcept
91 requires requires { make_default_radio_button_delegate(hi_forward(value), hi_forward(on_value)); }
92 :
94 parent,
96 hi_forward(attributes)...)
97 {
98 }
99
100 void request_redraw() const noexcept override
101 {
102 // A toolbar tab button draws a focus line across the whole toolbar
103 // which is beyond it's own clipping rectangle. The parent is the toolbar
104 // so it will include everything that needs to be redrawn.
105 if (parent != nullptr) {
107 } else {
109 }
110 }
111
113 [[nodiscard]] box_constraints update_constraints() noexcept override;
114 void set_layout(widget_layout const& context) noexcept override;
115 void draw(draw_context const& context) noexcept override;
116 [[nodiscard]] bool accepts_keyboard_focus(keyboard_focus_group group) const noexcept override;
117 // @endprivatesection
118private:
119 box_constraints _label_constraints;
120
121 void draw_toolbar_tab_button(draw_context const& context) noexcept;
122};
123
124}} // namespace hi::v1
Defines abstract_button_widget.
#define hi_forward(x)
Forward a value, based on the decltype of the value.
Definition utility.hpp:29
std::shared_ptr< button_delegate > make_default_radio_button_delegate(auto &&value, auto &&on_value) noexcept
Make a shared pointer to a radio-button delegate.
Definition button_delegate.hpp:227
DOXYGEN BUG.
Definition algorithm.hpp:13
geometry/margins.hpp
Definition cache.hpp:11
Draw context for drawing using the HikoGUI shaders.
Definition draw_context.hpp:211
2D constraints.
Definition box_constraints.hpp:22
Base class for implementing button widgets.
Definition abstract_button_widget.hpp:32
std::shared_ptr< delegate_type > delegate
The delegate that controls the button widget.
Definition abstract_button_widget.hpp:39
observer< alignment > alignment
The alignment of the button and on/off/other label.
Definition abstract_button_widget.hpp:55
A button delegate controls the state of a button widget.
Definition button_delegate.hpp:45
A graphical control element that allows the user to choose only one of a predefined set of mutually e...
Definition toolbar_tab_button_widget.hpp:46
toolbar_tab_button_widget(widget *parent, Value &&value, OnValue &&on_value, Attributes &&...attributes) noexcept
Construct a toolbar tab button widget with a default button delegate.
Definition toolbar_tab_button_widget.hpp:86
void request_redraw() const noexcept override
Request the widget to be redrawn on the next frame.
Definition toolbar_tab_button_widget.hpp:100
toolbar_tab_button_widget(widget *parent, std::shared_ptr< delegate_type > delegate, button_widget_attribute auto &&...attributes) noexcept
Construct a toolbar tab button widget.
Definition toolbar_tab_button_widget.hpp:60
An interactive graphical object as part of the user-interface.
Definition widget.hpp:46
virtual void request_redraw() const noexcept
Request the widget to be redrawn on the next frame.
Definition widget.hpp:240
widget * parent
Pointer to the parent widget.
Definition widget.hpp:51
The layout of a widget.
Definition widget_layout.hpp:38
Definition abstract_button_widget.hpp:26
T move(T... args)