HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
radio_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
43public:
45 using delegate_type = typename super::delegate_type;
46
58 gui_window& window,
61 button_widget_attribute auto&&...attributes) noexcept :
63 {
64 alignment = alignment::top_left();
65 set_attributes<0>(hi_forward(attributes)...);
66 }
67
81 template<
82 different_from<std::shared_ptr<delegate_type>> Value,
83 forward_of<observer<observer_decay_t<Value>>> OnValue,
84 button_widget_attribute... Attributes>
85 radio_button_widget(gui_window& window, widget *parent, Value&& value, OnValue&& on_value, Attributes&&...attributes) noexcept
86 requires requires
87 {
89 } :
91 window,
92 parent,
94 hi_forward(attributes)...)
95 {
96 }
97
99 widget_constraints const& set_constraints() noexcept override;
100 void set_layout(widget_layout const& layout) noexcept override;
101 void draw(draw_context const& context) noexcept override;
103private:
104 static constexpr std::chrono::nanoseconds _animation_duration = std::chrono::milliseconds(150);
105
106 extent2 _button_size;
107 aarectangle _button_rectangle;
108 animator<float> _animated_value = _animation_duration;
109 aarectangle _pip_rectangle;
110
111 void draw_radio_button(draw_context const& context) noexcept;
112 void draw_radio_pip(draw_context const& context) noexcept;
113};
114
115}} // 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
STL namespace.
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 graphical control element that allows the user to choose only one of a predefined set of mutually e...
Definition radio_button_widget.hpp:42
radio_button_widget(gui_window &window, widget *parent, std::shared_ptr< delegate_type > delegate, button_widget_attribute auto &&...attributes) noexcept
Construct a radio button widget.
Definition radio_button_widget.hpp:57
radio_button_widget(gui_window &window, widget *parent, Value &&value, OnValue &&on_value, Attributes &&...attributes) noexcept
Construct a radio button widget with a default button delegate.
Definition radio_button_widget.hpp:85
An interactive graphical object as part of the user-interface.
Definition widget.hpp:44
widget_layout const & layout() const noexcept
Get the current layout for this widget.
Definition widget.hpp:198
widget *const parent
Pointer to the parent widget.
Definition widget.hpp:53
gui_window & window
Convenient reference to the Window.
Definition widget.hpp:48
The constraints of a widget.
Definition widget_constraints.hpp:26
The layout of a widget.
Definition widget_layout.hpp:37
Definition abstract_button_widget.hpp:26
T move(T... args)