lecui 1.0.0-alpha.20
lecui C++ user interface library
button.h
1//
2// button.h - button widget interface
3//
4// lecui user interface library, part of the liblec library
5// Copyright (c) 2019 Alec Musasa (alecmus at live dot com)
6//
7// Released under the MIT license. For full details see the
8// file LICENSE.txt
9//
10
11#pragma once
12
13#if defined(LECUI_EXPORTS)
14#include "widget.h"
15#else
16#include <liblec/lecui/widgets/widget.h>
17#endif
18
19namespace liblec {
20 namespace lecui {
21 namespace widgets {
24 class lecui_api button : public widget, public badge_widget {
25 float _border = .5f;
26 color _color_border;
27 float _corner_radius_x = 5.f;
28 float _corner_radius_y = 5.f;
29
30 public:
33 _rect.size({ 80.f, 25.f });
34 }
35
40 bool operator==(const button& param);
41
46 bool operator!=(const button& param);
47
48 // generic widget
49
52 std::string& text() override;
53
57 button& text(const std::string& text);
58
61 std::string& tooltip() override;
62
66 button& tooltip(const std::string& tooltip);
67
70 badge_specs& badge() override;
71
75 button& badge(const badge_specs& badge);
76
80 lecui::rect& rect() override;
81
86
90
94 button& on_resize(const resize_params& on_resize);
95
98 cursor_type& cursor() override;
99
103 button& cursor(const cursor_type cursor);
104
107 std::string& font() override;
108
112 button& font(const std::string& font);
113
116 float& font_size() override;
117
121 button& font_size(const float& font_size);
122
125 color& color_text() override;
126
130 button& color_text(const color& color_text);
131
134 color& color_fill() override;
135
139 button& color_fill(const color& color_fill);
140
143 color& color_hot() override;
144
148 button& color_hot(const color& color_hot);
149
153
157 button& color_selected(const color& color_selected);
158
162
166 button& color_disabled(const color& color_disabled);
167
168 // widget specific widget
169
172 float& border();
173
177 button& border(const float& border);
178
182
186 button& color_border(const color& color_border);
187
191
195 button& corner_radius_x(const float& corner_radius_x);
196
200
204 button& corner_radius_y(const float& corner_radius_y);
205
206 public:
213 [[nodiscard]]
214 static button& add(containers::page& page, const std::string& alias = std::string());
215
222 [[nodiscard]]
223 static button& get(form& fm, const std::string& path);
224 };
225 }
226 }
227}
228
229#if defined(lecui_helper)
231#define get_button(path) liblec::lecui::widgets::button::get(*this, path)
232#endif
RGBA color on a standard 0 to 255 scale. For the alpha channel 0 is transparent and 255 is opaque.
Definition: lecui.h:583
Page container.
Definition: page.h:32
Form base class. The user must inherit from this class and call one of the two constructors from its ...
Definition: form.h:122
Rectangle class.
Definition: lecui.h:158
Resize parameters.
Definition: lecui.h:363
Badge specifications.
Definition: widget.h:177
Base class for all widgets with badges.
Definition: widget.h:292
Button widget. To instantiate and add to a container use the add static method.
Definition: button.h:24
color & color_hot() override
Get or set the widget's color when the mouse is hovered over it.
button & color_hot(const color &color_hot)
Set the widget's color when the mouse is hovered over it.
button & color_fill(const color &color_fill)
Set the fill color of the widget.
button()
Constructor.
Definition: button.h:32
float & font_size() override
Get or set the default widget font size in points, e.g. 9.0f.
badge_specs & badge() override
Get or set the badge specs.
button & color_text(const color &color_text)
Set the color of the widget's text.
button & badge(const badge_specs &badge)
Set the badge specs.
std::string & text() override
Get or set the widget text.
resize_params & on_resize() override
Get or set the behaviour of the widget when its container is resized.
button & on_resize(const resize_params &on_resize)
Set the behaviour of the widget when its container is resized.
button & corner_radius_x(const float &corner_radius_x)
Set the horizontal radius of the corners.
button & color_disabled(const color &color_disabled)
Set the widget's color when it is disabled.
lecui::rect & rect() override
Get or set the position and dimensions of the widget.
float & corner_radius_x()
Get or set the horizontal radius of the corners.
button & rect(const lecui::rect &rect)
Set the position and dimensions of the widget.
button & border(const float &border)
Set the thickness of the border.
float & corner_radius_y()
Get or set the vertical radius of the corners.
color & color_border()
Get or set the color of the border.
bool operator==(const button &param)
Check whether widget specs are equal. Only those properties that require the widget resources to be r...
std::string & tooltip() override
Get or set the widget's tooltip text.
color & color_selected() override
Get or set the widget's color when selected.
bool operator!=(const button &param)
Check whether widget specs are NOT equal. Only those properties that require the widget resources to ...
cursor_type & cursor() override
Get or set the mouse cursor to use then over the widget.
std::string & font() override
Get or set the default widget font, e.g. "Georgia".
color & color_text() override
Get or set the color of the widget's text.
button & font(const std::string &font)
Set the default widget font.
button & color_border(const color &color_border)
Set the color of the border.
button & text(const std::string &text)
Set the widget's text.
color & color_disabled() override
Get or set the widget's color when it is disabled.
button & font_size(const float &font_size)
Set the widget's font size.
button & cursor(const cursor_type cursor)
Set the mouse cursor to use when over the widget.
color & color_fill() override
Get or set the fill color of the widget.
float & border()
Get or set the thickness of the border.
static button & add(containers::page &page, const std::string &alias=std::string())
Add a button to a container.
button & color_selected(const color &color_selected)
Set the widget's color when selected.
button & corner_radius_y(const float &corner_radius_y)
Set the vertical radius of the corners.
static button & get(form &fm, const std::string &path)
Get the specifications of a button.
button & tooltip(const std::string &tooltip)
Set the tooltip text.
Base class for all widgets.
Definition: widget.h:24
cursor_type
Mouse cursor type.
Definition: widget.h:27
Top level namespace for the liblec libraries.
Definition: appearance.h:19