lecui 1.0.0-alpha.20
lecui C++ user interface library
strength_bar.h
1//
2// strength_bar.h - strength bar 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 strength_bar : public widget {
25 public:
29 float level = 0.f;
30
33
37 bool operator==(const strength_level& param);
38
42 bool operator!=(const strength_level& param);
43 };
44
45 private:
46 float _border = 1.f;
47 color _color_border;
48 float _percentage = 0.f;
49 std::vector<strength_level> _levels;
50
51 public:
54 _rect.size({ 200.f, 12.f });
55 }
56
57 // not using const here because of the need to compare the _levels vector
58
64
70
71 // generic widget
72
75 std::string& text() override;
76
80 strength_bar& text(const std::string& text);
81
84 std::string& tooltip() override;
85
89 strength_bar& tooltip(const std::string& tooltip);
90
94 lecui::rect& rect() override;
95
100
104
109
112 cursor_type& cursor() override;
113
118
121 std::string& font() override;
122
126 strength_bar& font(const std::string& font);
127
130 float& font_size() override;
131
135 strength_bar& font_size(const float& font_size);
136
139 color& color_text() override;
140
144 strength_bar& color_text(const color& color_text);
145
148 color& color_fill() override;
149
153 strength_bar& color_fill(const color& color_fill);
154
157 color& color_hot() override;
158
162 strength_bar& color_hot(const color& color_hot);
163
167
171 strength_bar& color_selected(const color& color_selected);
172
176
180 strength_bar& color_disabled(const color& color_disabled);
181
182 // widget specific widget
183
186 float& border();
187
191 strength_bar& border(const float& border);
192
196
200 strength_bar& color_border(const color& color_border);
201
204 float& percentage();
205
209 strength_bar& percentage(const float& percentage);
210
213 std::vector<strength_level>& levels();
214
218 strength_bar& levels(const std::vector<strength_level>& levels);
219
220 public:
227 [[nodiscard]]
228 static strength_bar& add(containers::page& page, const std::string& alias = std::string());
229
236 [[nodiscard]]
237 static strength_bar& get(form& fm, const std::string& path);
238 };
239 }
240 }
241}
242
243#if defined(lecui_helper)
245#define get_strength_bar(path) liblec::lecui::widgets::strength_bar::get(*this, path)
246#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
Strength bar widget. To instantiate and add to a container use the add static method.
Definition: strength_bar.h:24
color & color_fill() override
Get or set the fill color of the widget.
strength_bar & color_hot(const color &color_hot)
Set the widget's color when the mouse is hovered over it.
strength_bar & rect(const lecui::rect &rect)
Set the position and dimensions of the widget.
color & color_text() override
Get or set the color of the widget's text.
strength_bar & percentage(const float &percentage)
Set the percentage of the strength bar (0.f - 100.f).
strength_bar & text(const std::string &text)
Set the widget's text.
strength_bar & on_resize(const resize_params &on_resize)
Set the behaviour of the widget when its container is resized.
strength_bar & color_fill(const color &color_fill)
Set the fill color of the widget.
strength_bar & levels(const std::vector< strength_level > &levels)
Set the strength levels.
strength_bar & border(const float &border)
Set the thickness of the border.
strength_bar & tooltip(const std::string &tooltip)
Set the tooltip text.
std::string & text() override
Get or set the widget text.
std::string & font() override
Get or set the default widget font, e.g. "Georgia".
float & border()
Get or set the thickness of the border.
strength_bar & cursor(const cursor_type cursor)
Set the mouse cursor to use when over the widget.
strength_bar & color_text(const color &color_text)
Set the color of the widget's text.
bool operator==(strength_bar &param)
Check whether widget specs are equal. Only those properties that require the widget resources to be r...
color & color_selected() override
Get or set the widget's color when selected.
bool operator!=(strength_bar &param)
Check whether widget specs are NOT equal. Only those properties that require the widget resources to ...
std::vector< strength_level > & levels()
Get or set the strength levels.
strength_bar & color_border(const color &color_border)
Set the color of the border.
static strength_bar & add(containers::page &page, const std::string &alias=std::string())
Add a strength bar to a container.
color & color_hot() override
Get or set the widget's color when the mouse is hovered over it.
resize_params & on_resize() override
Get or set the behaviour of the widget when its container is resized.
color & color_border()
Get or set the color of the border.
color & color_disabled() override
Get or set the widget's color when it is disabled.
static strength_bar & get(form &fm, const std::string &path)
Get the specifications of a strength bar.
strength_bar()
Constructor.
Definition: strength_bar.h:53
float & percentage()
Get or set the percentage of the strength bar (0.f - 100.f).
strength_bar & font_size(const float &font_size)
Set the widget's font size.
cursor_type & cursor() override
Get or set the mouse cursor to use then over the widget.
float & font_size() override
Get or set the default widget font size in points, e.g. 9.0f.
strength_bar & color_disabled(const color &color_disabled)
Set the widget's color when it is disabled.
strength_bar & color_selected(const color &color_selected)
Set the widget's color when selected.
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.
strength_bar & font(const std::string &font)
Set the default widget font.
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
Strength level as a percentage.
Definition: strength_bar.h:27
lecui::color color
The color to use for the level.
Definition: strength_bar.h:32
bool operator==(const strength_level &param)
Check whether strength levels are equal. All properties are considered.
bool operator!=(const strength_level &param)
Check whether strength levels are NOT equal. All properties are considered.