11#include "../macros.hpp"
14namespace hi {
inline namespace v1 {
86 _label_constraints = super::update_constraints();
89 _check_size = {theme().size(), theme().size()};
90 _short_cut_size = {theme().size(), theme().size()};
94 theme().margin<
float>() * 4.0f + _check_size.
width() + _short_cut_size.
width(), theme().margin<
float>() * 2.0f};
96 auto constraints = _label_constraints +
extra_size;
97 constraints.margins = 0;
101 void set_layout(widget_layout
const&
context)
noexcept override
106 if (os_settings::left_to_right()) {
110 point2{_check_rectangle.right() + theme().margin<
float>(), 0.0f},
111 point2{_short_cut_rectangle.left() - theme().margin<
float>(),
context.height()}};
112 _on_label_shape = _off_label_shape = _other_label_shape =
113 box_shape{_label_constraints,
label_rectangle, theme().baseline_adjustment()};
119 point2{_short_cut_rectangle.right() + theme().margin<
float>(), 0.0f},
120 point2{_check_rectangle.left() - theme().margin<
float>(),
context.height()}};
121 _on_label_shape = _off_label_shape = _other_label_shape =
122 box_shape{_label_constraints,
label_rectangle, theme().baseline_adjustment()};
126 hilet
check_glyph_bb = _check_glyph.get_metrics().bounding_rectangle * theme().icon_size();
127 _check_glyph_rectangle =
align(_check_rectangle,
check_glyph_bb, alignment::middle_center());
133 void draw(draw_context
const&
context)
noexcept override
142 [[
nodiscard]]
bool accepts_keyboard_focus(keyboard_focus_group group)
const noexcept override
147 bool handle_event(gui_event
const&
event)
noexcept override
151 switch (
event.type()) {
155 nullptr, keyboard_focus_group::menu, keyboard_focus_direction::forward));
163 nullptr, keyboard_focus_group::menu, keyboard_focus_direction::backward));
172 nullptr, keyboard_focus_group::normal, keyboard_focus_direction::forward));
174 nullptr, keyboard_focus_group::normal, keyboard_focus_direction::backward));
182 return super::handle_event(
event);
186 box_constraints _label_constraints;
188 font_book::font_glyph_type _check_glyph;
190 aarectangle _check_rectangle;
191 aarectangle _check_glyph_rectangle;
192 extent2 _short_cut_size;
193 aarectangle _short_cut_rectangle;
195 void draw_menu_button(draw_context
const&
context)
noexcept
201 void draw_check_mark(draw_context
const&
context)
noexcept
206 if (
state_ == hi::button_state::on) {
207 context.draw_glyph(
layout(), translate_z(0.1f) * _check_glyph_rectangle, _check_glyph, accent_color());
Defines abstract_button_widget.
gui_event_type
GUI event type.
Definition gui_event_type.hpp:24
@ rectangle
The gui_event has rectangle data.
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
@ partial
A widget is partially enabled.
@ invisible
The widget is invisible.
DOXYGEN BUG.
Definition algorithm.hpp:16
hi_export auto find_glyph(font const &font, grapheme grapheme) noexcept
Find a glyph using the given code-point.
Definition font_book.hpp:437
geometry/margins.hpp
Definition lookahead_iterator.hpp:5
@ inside
The border is drawn inside the edge of a quad.
bool compare_store(T &lhs, U &&rhs) noexcept
Compare then store if there was a change.
Definition misc.hpp:56
constexpr Out narrow_cast(In const &rhs) noexcept
Cast numeric values without loss of precision.
Definition cast.hpp:377
Horizontal/Vertical alignment combination.
Definition alignment.hpp:242
constexpr float & width() noexcept
Access the x-as-width element from the extent.
Definition extent2.hpp:104
widget_intf * parent
Pointer to the parent widget.
Definition widget_intf.hpp:28
2D constraints.
Definition box_constraints.hpp:25
Base class for implementing button widgets.
Definition abstract_button_widget.hpp:33
std::shared_ptr< delegate_type > delegate
The delegate that controls the button widget.
Definition abstract_button_widget.hpp:40
button_state state() const noexcept
Get the current state of the button.
Definition abstract_button_widget.hpp:88
A button delegate controls the state of a button widget.
Definition button_delegate.hpp:45
A button that is part of a menu.
Definition menu_button_widget.hpp:31
menu_button_widget(widget *parent, std::shared_ptr< delegate_type > delegate, button_widget_attribute auto &&...attributes) noexcept
Construct a menu button widget.
Definition menu_button_widget.hpp:45
menu_button_widget(widget *parent, Value &&value, OnValue &&on_value, Attributes &&...attributes) noexcept
Construct a menu button widget with a default button delegate.
Definition menu_button_widget.hpp:71
An interactive graphical object as part of the user-interface.
Definition widget.hpp:37
widget_layout const & layout() const noexcept override
Get the current layout for this widget.
Definition widget.hpp:169
bool is_first(keyboard_focus_group group) const noexcept
Is this widget the first widget in the parent container.
Definition widget.hpp:376
bool is_last(keyboard_focus_group group) const noexcept
Is this widget the last widget in the parent container.
Definition widget.hpp:384
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
observer< bool > focus
The widget has keyboard focus.
Definition widget.hpp:50
Definition concepts.hpp:54
True if T is a forwarded type of Forward.
Definition concepts.hpp:131
Definition abstract_button_widget.hpp:27