HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
checkbox_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#include "../log.hpp"
13
14namespace hi { inline namespace v1 {
15
43public:
45 using delegate_type = typename super::delegate_type;
46
59 button_widget_attribute auto&&...attributes) noexcept :
61 {
62 alignment = alignment::top_left();
63 set_attributes<0>(hi_forward(attributes)...);
64 }
65
78 different_from<std::shared_ptr<delegate_type>> auto&& value,
79 button_widget_attribute auto&&...attributes) noexcept requires requires
80 {
83
95 template<
96 different_from<std::shared_ptr<delegate_type>> Value,
97 forward_of<observer<observer_decay_t<Value>>> OnValue,
98 button_widget_attribute... Attributes>
99 checkbox_widget(widget *parent, Value&& value, OnValue&& on_value, Attributes&&...attributes) noexcept
100 requires requires
101 {
103 } :
105 parent,
107 hi_forward(attributes)...)
108 {
109 }
110
123 template<
124 different_from<std::shared_ptr<delegate_type>> Value,
125 forward_of<observer<observer_decay_t<Value>>> OnValue,
126 forward_of<observer<observer_decay_t<Value>>> OffValue,
127 button_widget_attribute... Attributes>
129 widget *parent,
130 Value&& value,
131 OnValue&& on_value,
132 OffValue&& off_value,
133 Attributes&&...attributes) noexcept requires requires
134 {
136 } :
138 parent,
140 hi_forward(attributes)...)
141 {
142 }
143
145 widget_constraints const& set_constraints(set_constraints_context const& context) noexcept override;
146 void set_layout(widget_layout const& context) noexcept override;
147 void draw(draw_context const& context) noexcept override;
149private:
150 extent2 _button_size;
151 aarectangle _button_rectangle;
152 glyph_ids _check_glyph;
153 aarectangle _check_glyph_rectangle;
154 glyph_ids _minus_glyph;
155 aarectangle _minus_glyph_rectangle;
156
157 void draw_check_box(draw_context const& context) noexcept;
158 void draw_check_mark(draw_context const& context) noexcept;
159};
160
161}} // 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_toggle_button_delegate(auto &&value, auto &&...args) noexcept
Make a shared pointer to a toggle-button delegate.
Definition button_delegate.hpp:245
DOXYGEN BUG.
Definition algorithm.hpp:15
The HikoGUI namespace.
Definition ascii.hpp:19
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 GUI widget that permits the user to make a binary choice.
Definition checkbox_widget.hpp:42
checkbox_widget(widget *parent, std::shared_ptr< delegate_type > delegate, button_widget_attribute auto &&...attributes) noexcept
Construct a checkbox widget.
Definition checkbox_widget.hpp:56
checkbox_widget(widget *parent, Value &&value, OnValue &&on_value, Attributes &&...attributes) noexcept
Construct a checkbox widget with a default button delegate.
Definition checkbox_widget.hpp:99
checkbox_widget(widget *parent, Value &&value, OnValue &&on_value, OffValue &&off_value, Attributes &&...attributes) noexcept
Construct a checkbox widget with a default button delegate.
Definition checkbox_widget.hpp:128
checkbox_widget(widget *parent, different_from< std::shared_ptr< delegate_type > > auto &&value, button_widget_attribute auto &&...attributes) noexcept
Construct a checkbox widget with a default button delegate.
Definition checkbox_widget.hpp:76
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)