lecui 1.0.0-alpha.20
lecui C++ user interface library
group.h
1//
2// group.h - group container 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 "../widgets/widget.h"
15#else
16#include <liblec/lecui/widgets/widget.h>
17#endif
18
19namespace liblec {
20 namespace lecui {
21 namespace containers {
28 class lecui_api group : public widgets::widget {
29 float _border = .5f;
30 color _color_border;
31 float _corner_radius_x = 5.f;
32 float _corner_radius_y = 5.f;
33 float _margin = 5.f;
34 std::vector<std::string> _widgets;
35
36 public:
37
40 // rect is ignored. The group dynamically surrounds the widgets associated
41 // with it as they change location and size.
42 _rect = { 0.f, 0.f, 0.f, 0.f };
43 }
44
49 bool operator==(const group& param);
50
55 bool operator!=(const group& param);
56
57 // generic widget
58
62 std::string& text() override;
63
68 group& text(const std::string& text);
69
73 std::string& tooltip() override;
74
79 group& tooltip(const std::string& tooltip);
80
84 lecui::rect& rect() override;
85
90
94
98 group& on_resize(const resize_params& on_resize);
99
103 cursor_type& cursor() override;
104
109 group& cursor(const cursor_type cursor);
110
114 std::string& font() override;
115
120 group& font(const std::string& font);
121
125 float& font_size() override;
126
131 group& font_size(const float& font_size);
132
136 color& color_text() override;
137
142 group& color_text(const color& color_text);
143
146 color& color_fill() override;
147
151 group& color_fill(const color& color_fill);
152
156 color& color_hot() override;
157
162 group& color_hot(const color& color_hot);
163
168
173 group& color_selected(const color& color_selected);
174
178
182 group& color_disabled(const color& color_disabled);
183
184 // widget specific widget
185
188 float& border();
189
193 group& border(const float& border);
194
198
202 group& color_border(const color& color_border);
203
207
211 group& corner_radius_x(const float& corner_radius_x);
212
216
220 group& corner_radius_y(const float& corner_radius_y);
221
224 float& margin();
225
229 group& margin(const float& margin);
230
234 std::vector<std::string>& widgets();
235
240 group& widgets(const std::vector<std::string>& widgets);
241
242 public:
249 [[nodiscard]]
250 static group& add(containers::page& page, const std::string& alias = std::string());
251
258 [[nodiscard]]
259 static group& get(form& fm, const std::string& path);
260 };
261 }
262 }
263}
264
265#if defined(lecui_helper)
267#define get_group(path) liblec::lecui::containers::group::get(*this, path)
268#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
Group container. To instantiate and add to a container use the add static method.
Definition: group.h:28
group & widgets(const std::vector< std::string > &widgets)
Set the list of the aliases for the widgets to be added to the group. e.g. { "username_text_field",...
float & corner_radius_y()
Get or set the vertical radius of the corners.
float & corner_radius_x()
Get or set the horizontal radius of the corners.
std::string & text() override
Get or set the widget text.
group & on_resize(const resize_params &on_resize)
Set the behaviour of the widget when its container is resized.
color & color_fill() override
Get or set the fill color of the widget.
bool operator!=(const group &param)
Check whether widget specs are NOT equal. Only those properties that require the widget resources to ...
float & border()
Get or set the thickness of the border.
group & font(const std::string &font)
Set the default widget font.
group & color_fill(const color &color_fill)
Set the fill color of the widget.
group & border(const float &border)
Set the thickness of the border.
group()
Class constructor.
Definition: group.h:39
float & font_size() override
Get or set the default widget font size in points, e.g. 9.0f.
group & cursor(const cursor_type cursor)
Set the mouse cursor to use when over the widget.
std::vector< std::string > & widgets()
Get or set the list of the aliases for the widgets to be added to the group. e.g. { "username_text_fi...
color & color_hot() override
Get or set the widget's color when the mouse is hovered over it.
bool operator==(const group &param)
Check whether widget specs are equal. Only those properties that require the widget resources to be r...
color & color_text() override
Get or set the color of the widget's text.
group & rect(const lecui::rect &rect)
Set the position and dimensions of the widget.
std::string & tooltip() override
Get or set the widget's tooltip text.
lecui::rect & rect() override
Get or set the position and dimensions of the widget.
group & color_text(const color &color_text)
Set the color of the widget's text.
group & text(const std::string &text)
Set the widget's text.
static group & get(form &fm, const std::string &path)
Get the specifications of a group.
float & margin()
Get or set the group's margin. Defines how far we extend outside the collective group rectangles.
cursor_type & cursor() override
Get or set the mouse cursor to use then over the widget.
color & color_disabled() override
Get or set the widget's color when it is disabled.
group & color_hot(const color &color_hot)
Set the widget's color when the mouse is hovered over it.
std::string & font() override
Get or set the default widget font, e.g. "Georgia".
group & tooltip(const std::string &tooltip)
Set the tooltip text.
static group & add(containers::page &page, const std::string &alias=std::string())
Create a group.
resize_params & on_resize() override
Get or set the behaviour of the widget when its container is resized.
group & color_selected(const color &color_selected)
Set the widget's color when selected.
group & margin(const float &margin)
Set the group's margin. Defines how far we extend outside the collective group rectangles.
color & color_border()
Get or set the color of the border.
group & color_border(const color &color_border)
Set the color of the border.
color & color_selected() override
Get or set the widget's color when selected.
group & corner_radius_y(const float &corner_radius_y)
Set the vertical radius of the corners.
group & color_disabled(const color &color_disabled)
Set the widget's color when it is disabled.
group & corner_radius_x(const float &corner_radius_x)
Set the horizontal radius of the corners.
group & font_size(const float &font_size)
Set the widget's font size.
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
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