HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
menu_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
31public:
33 using delegate_type = typename super::delegate_type;
34
47 button_widget_attribute auto&&...attributes) noexcept :
49 {
50 alignment = alignment::middle_left();
51 set_attributes<0>(hi_forward(attributes)...);
52 }
53
66 template<
67 different_from<std::shared_ptr<delegate_type>> Value,
68 forward_of<observer<observer_decay_t<Value>>> OnValue,
69 button_widget_attribute... Attributes>
70 menu_button_widget(widget *parent, Value&& value, OnValue&& on_value, Attributes&&...attributes) noexcept
71 requires requires
72 {
74 } :
76 parent,
78 hi_forward(attributes)...)
79 {
80 }
81
83 widget_constraints const& set_constraints(set_constraints_context const& context) noexcept override;
84 void set_layout(widget_layout const& context) noexcept override;
85 void draw(draw_context const& context) noexcept override;
86 [[nodiscard]] bool accepts_keyboard_focus(keyboard_focus_group group) const noexcept override;
87 bool handle_event(gui_event const& event) noexcept override;
89private:
90 glyph_ids _check_glyph;
91 extent2 _check_size;
92 aarectangle _check_rectangle;
93 aarectangle _check_glyph_rectangle;
94 extent2 _short_cut_size;
95 aarectangle _short_cut_rectangle;
96
97 void draw_menu_button(draw_context const& context) noexcept;
98 void draw_check_mark(draw_context const& context) noexcept;
99};
100
101}} // namespace hi::v1
#define hi_forward(x)
Forward a value, based on the decltype of the value.
Definition utility.hpp:29
Defines abstract_button_widget.
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:15
The HikoGUI namespace.
Definition ascii.hpp:19
A user interface event.
Definition gui_event.hpp:76
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 button that is part of a menu.
Definition menu_button_widget.hpp:30
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:44
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:70
Definition set_constraints_context.hpp:15
An interactive graphical object as part of the user-interface.
Definition widget.hpp:45
widget * parent
Pointer to the parent widget.
Definition widget.hpp:50
The constraints of a widget.
Definition widget_constraints.hpp:26
The layout of a widget.
Definition widget_layout.hpp:40
Definition abstract_button_widget.hpp:26
T move(T... args)