lecui 1.0.0-alpha.20
lecui C++ user interface library
progress_bar.h
1//
2// progress_bar.h - progress 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 progress_bar : public widget {
25 float _border = 1.f;
26 color _color_border;
27 color _color_empty;
28 float _percentage = 0.f;
29
30 public:
33 _rect.size({ 200.f, 12.f });
34 }
35
40 bool operator==(const progress_bar& param);
41
46 bool operator!=(const progress_bar& param);
47
48 // generic widget
49
52 std::string& text() override;
53
57 progress_bar& text(const std::string& text);
58
61 std::string& tooltip() override;
62
66 progress_bar& tooltip(const std::string& tooltip);
67
71 lecui::rect& rect() override;
72
77
81
86
89 cursor_type& cursor() override;
90
95
98 std::string& font() override;
99
103 progress_bar& font(const std::string& font);
104
107 float& font_size() override;
108
112 progress_bar& font_size(const float& font_size);
113
116 color& color_text() override;
117
121 progress_bar& color_text(const color& color_text);
122
125 color& color_fill() override;
126
130 progress_bar& color_fill(const color& color_fill);
131
134 color& color_hot() override;
135
139 progress_bar& color_hot(const color& color_hot);
140
144
148 progress_bar& color_selected(const color& color_selected);
149
153
157 progress_bar& color_disabled(const color& color_disabled);
158
159 // widget specific widget
160
163 float& border();
164
168 progress_bar& border(const float& border);
169
173
177 progress_bar& color_border(const color& color_border);
178
182
186 progress_bar& color_empty(const color& color_empty);
187
190 float& percentage();
191
195 progress_bar& percentage(const float& percentage);
196
197 public:
204 [[nodiscard]]
205 static progress_bar& add(containers::page& page, const std::string& alias = std::string());
206
213 [[nodiscard]]
214 static progress_bar& get(form& fm, const std::string& path);
215 };
216 }
217 }
218}
219
220#if defined(lecui_helper)
222#define get_progress_bar(path) liblec::lecui::widgets::progress_bar::get(*this, path)
223#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
Progress bar widget. To instantiate and add to a container use the add static method.
Definition: progress_bar.h:24
progress_bar & font_size(const float &font_size)
Set the widget's font size.
std::string & text() override
Get or set the widget text.
progress_bar & color_disabled(const color &color_disabled)
Set the widget's color when it is disabled.
progress_bar & color_border(const color &color_border)
Set the color of the border.
cursor_type & cursor() override
Get or set the mouse cursor to use then over the widget.
progress_bar & text(const std::string &text)
Set the widget's text.
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.
color & color_selected() override
Get or set the widget's color when selected.
progress_bar & on_resize(const resize_params &on_resize)
Set the behaviour of the widget when its container is resized.
static progress_bar & get(form &fm, const std::string &path)
Get the specifications of a progress bar.
color & color_empty()
Get or set the color to use for the empty portion of the indicator.
progress_bar & font(const std::string &font)
Set the default widget font.
static progress_bar & add(containers::page &page, const std::string &alias=std::string())
Add a progress bar to a container.
bool operator==(const progress_bar &param)
Check whether widget specs are equal. Only those properties that require the widget resources to be r...
bool operator!=(const progress_bar &param)
Check whether widget specs are NOT equal. Only those properties that require the widget resources to ...
progress_bar & color_fill(const color &color_fill)
Set the fill color of the widget.
progress_bar()
Constructor.
Definition: progress_bar.h:32
float & font_size() override
Get or set the default widget font size in points, e.g. 9.0f.
progress_bar & cursor(const cursor_type cursor)
Set the mouse cursor to use when over the widget.
progress_bar & color_text(const color &color_text)
Set the color of the widget's text.
progress_bar & percentage(const float &percentage)
Set the percentage of the progress bar (0.f - 100.f).
progress_bar & rect(const lecui::rect &rect)
Set the position and dimensions of the widget.
progress_bar & color_hot(const color &color_hot)
Set the widget's color when the mouse is hovered over it.
progress_bar & border(const float &border)
Set the thickness of the border.
color & color_border()
Get or set the color of the border.
resize_params & on_resize() override
Get or set the behaviour of the widget when its container is resized.
progress_bar & tooltip(const std::string &tooltip)
Set the tooltip text.
color & color_fill() override
Get or set the fill color of the widget.
color & color_hot() override
Get or set the widget's color when the mouse is hovered over it.
float & percentage()
Get or set the percentage of the progress bar (0.f - 100.f).
color & color_disabled() override
Get or set the widget's color when it is disabled.
std::string & font() override
Get or set the default widget font, e.g. "Georgia".
progress_bar & color_selected(const color &color_selected)
Set the widget's color when selected.
color & color_text() override
Get or set the color of the widget's text.
progress_bar & color_empty(const color &color_empty)
Set the color to use for the empty portion of the indicator
float & border()
Get or set the thickness of the border.
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