HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
checkbox_widget.hpp
1// Copyright Take Vos 2021.
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
5#pragma once
6
7#include "abstract_button_widget.hpp"
8#include "default_button_delegate.hpp"
9
10namespace hi::inline v1 {
11
39public:
41 using delegate_type = typename super::delegate_type;
42
49 checkbox_widget(gui_window &window, widget *parent, std::weak_ptr<delegate_type> delegate) noexcept;
50
60 template<typename Value, typename... Args>
61 checkbox_widget(gui_window &window, widget *parent, Value &&value, Args &&...args) noexcept
62 requires(not std::is_convertible_v<Value, weak_or_unique_ptr<delegate_type>>) :
64 window,
65 parent,
66 make_unique_default_button_delegate<button_type::toggle>(std::forward<Value>(value), std::forward<Args>(args)...))
67 {
68 }
69
71 widget_constraints const &set_constraints() noexcept override;
72 void set_layout(widget_layout const &layout) noexcept override;
73 void draw(draw_context const &context) noexcept override;
75private:
76 extent2 _button_size;
77 aarectangle _button_rectangle;
78 glyph_ids _check_glyph;
79 aarectangle _check_glyph_rectangle;
80 glyph_ids _minus_glyph;
81 aarectangle _minus_glyph_rectangle;
82
83 checkbox_widget(gui_window &window, widget *parent, weak_or_unique_ptr<delegate_type> delegate) noexcept;
84
85 void draw_check_box(draw_context const &context) noexcept;
86 void draw_check_mark(draw_context const &context) noexcept;
87};
88
89} // namespace hi::inline v1
button_type
The type of button.
Definition button_type.hpp:13
@ toggle
A toggle button.
STL namespace.
Class which represents an axis-aligned rectangle.
Definition axis_aligned_rectangle.hpp:20
Draw context for drawing using the HikoGUI shaders.
Definition draw_context.hpp:51
Definition gui_window.hpp:40
A set of glyph-ids of a font which composites into a single glyph.
Definition glyph_ids.hpp:127
Class that hold either a weak_ptr or a unique_ptr This class is to hold a weak_ptr,...
Definition weak_or_unique_ptr.hpp:25
Definition abstract_button_widget.hpp:23
Definition button_delegate.hpp:14
A GUI widget that permits the user to make a binary choice.
Definition checkbox_widget.hpp:38
checkbox_widget(gui_window &window, widget *parent, std::weak_ptr< delegate_type > delegate) noexcept
Construct a checkbox widget.
checkbox_widget(gui_window &window, widget *parent, Value &&value, Args &&...args) noexcept
Construct a checkbox widget with a default button delegate.
Definition checkbox_widget.hpp:61
An interactive graphical object as part of the user-interface.
Definition widget.hpp:40
Definition widget_constraints.hpp:12
Definition widget_layout.hpp:17