lecui 1.0.0-alpha.20
lecui C++ user interface library
rectangle.h
1//
2// rectangle.h - rectangle 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 rectangle : public widget, public badge_widget {
25 float _border = .5f;
26 color _color_border;
27 color _color_border_hot;
28 float _corner_radius_x = .0f;
29 float _corner_radius_y = .0f;
30
31 public:
34 _rect.size({ 200.f, 200.f });
35 }
36
41 bool operator==(const rectangle& param);
42
47 bool operator!=(const rectangle& param);
48
49 // generic widget
50
53 std::string& text() override;
54
58 rectangle& text(const std::string& text);
59
62 std::string& tooltip() override;
63
67 rectangle& tooltip(const std::string& tooltip);
68
71 badge_specs& badge() override;
72
76 rectangle& badge(const badge_specs& badge);
77
81 lecui::rect& rect() override;
82
87
91
95 rectangle& on_resize(const resize_params& on_resize);
96
99 cursor_type& cursor() override;
100
105
108 std::string& font() override;
109
113 rectangle& font(const std::string& font);
114
117 float& font_size() override;
118
122 rectangle& font_size(const float& font_size);
123
126 color& color_text() override;
127
131 rectangle& color_text(const color& color_text);
132
135 color& color_fill() override;
136
140 rectangle& color_fill(const color& color_fill);
141
144 color& color_hot() override;
145
149 rectangle& color_hot(const color& color_hot);
150
154
158 rectangle& color_selected(const color& color_selected);
159
163
167 rectangle& color_disabled(const color& color_disabled);
168
169 // widget specific widget
170
173 float& border();
174
178 rectangle& border(const float& border);
179
183
187 rectangle& color_border(const color& color_border);
188
192
196 rectangle& color_border_hot(const color& color_border_hot);
197
201
205 rectangle& corner_radius_x(const float& corner_radius_x);
206
210
214 rectangle& corner_radius_y(const float& corner_radius_y);
215
216 public:
223 [[nodiscard]]
224 static rectangle& add(containers::page& page, const std::string& alias = std::string());
225
232 [[nodiscard]]
233 static rectangle& get(form& fm, const std::string& path);
234 };
235 }
236 }
237}
238
239#if defined(lecui_helper)
241#define get_rectangle(path) liblec::lecui::widgets::rectangle::get(*this, path)
242#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
Rectangle widget. To instantiate and add to a container use the add static method.
Definition: rectangle.h:24
rectangle & color_hot(const color &color_hot)
Set the widget's color when the mouse is hovered over it.
float & border()
Get or set the thickness of the border.
rectangle & text(const std::string &text)
Set the widget's text.
rectangle()
Constructor.
Definition: rectangle.h:33
rectangle & color_border(const color &color_border)
Set the color of the border.
rectangle & color_disabled(const color &color_disabled)
Set the widget's color when it is disabled.
resize_params & on_resize() override
Get or set the behaviour of the widget when its container is resized.
color & color_border_hot()
Get or set the color of the border when the mouse is over the widget.
bool operator!=(const rectangle &param)
Check whether widget specs are NOT equal. Only those properties that require the widget resources to ...
rectangle & color_selected(const color &color_selected)
Set the widget's color when selected.
static rectangle & add(containers::page &page, const std::string &alias=std::string())
Add a rectangle to a container.
rectangle & corner_radius_x(const float &corner_radius_x)
Set the horizontal radius of the corners.
rectangle & on_resize(const resize_params &on_resize)
Set the behaviour of the widget when its container is resized.
rectangle & color_fill(const color &color_fill)
Set the fill color of the widget.
rectangle & color_border_hot(const color &color_border_hot)
Set the color of the border when the mouse is over the widget.
float & corner_radius_y()
Get or set the vertical radius of the corners.
rectangle & tooltip(const std::string &tooltip)
Set the tooltip text.
static rectangle & get(form &fm, const std::string &path)
Get the specifications of a rectangle.
std::string & text() override
Get or set the widget text.
std::string & tooltip() override
Get or set the widget's tooltip text.
rectangle & cursor(const cursor_type cursor)
Set the mouse cursor to use when over the widget.
float & corner_radius_x()
Get or set the horizontal radius of the corners.
rectangle & rect(const lecui::rect &rect)
Set the position and dimensions of the widget.
color & color_hot() override
Get or set the widget's color when the mouse is hovered over it.
color & color_disabled() override
Get or set the widget's color when it is disabled.
color & color_fill() override
Get or set the fill color of the widget.
bool operator==(const rectangle &param)
Check whether widget specs are equal. Only those properties that require the widget resources to be r...
lecui::rect & rect() override
Get or set the position and dimensions of the widget.
rectangle & corner_radius_y(const float &corner_radius_y)
Set the vertical radius of the corners.
color & color_border()
Get or set the color of the border.
rectangle & border(const float &border)
Set the thickness of the border.
rectangle & color_text(const color &color_text)
Set the color of the widget's text.
rectangle & badge(const badge_specs &badge)
Set the badge specs.
rectangle & font_size(const float &font_size)
Set the widget's font size.
color & color_selected() override
Get or set the widget's color when selected.
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.
rectangle & font(const std::string &font)
Set the default widget font.
color & color_text() override
Get or set the color of the widget's text.
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".
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