lecui 1.0.0-alpha.20
lecui C++ user interface library
progress_indicator.h
1//
2// progress_indicator.h - progress indicator 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_indicator : public widget {
25 color _color_empty;
26 float _line_thickness_empty = .5f;
27 float _line_thickness_fill = 1.5f;
28 float _percentage = 0.f;
29 int _precision = 0;
30
31 public:
34 _rect.size({ 50.f, 50.f });
35 }
36
41 bool operator==(const progress_indicator& param);
42
47 bool operator!=(const progress_indicator& param);
48
49 // generic widget
50
53 std::string& text() override;
54
58 progress_indicator& text(const std::string& text);
59
62 std::string& tooltip() override;
63
67 progress_indicator& tooltip(const std::string& tooltip);
68
72 lecui::rect& rect() override;
73
78
82
87
90 cursor_type& cursor() override;
91
96
99 std::string& font() override;
100
104 progress_indicator& font(const std::string& font);
105
108 float& font_size() override;
109
113 progress_indicator& font_size(const float& font_size);
114
117 color& color_text() override;
118
123
126 color& color_fill() override;
127
132
135 color& color_hot() override;
136
141
145
149 progress_indicator& color_selected(const color& color_selected);
150
154
158 progress_indicator& color_disabled(const color& color_disabled);
159
160 // widget specific widget
161
165
170
174
178 progress_indicator& line_thickness_empty(const float& line_thickness_empty);
179
183
187 progress_indicator& line_thickness_fill(const float& line_thickness_fill);
188
191 float& percentage();
192
196 progress_indicator& percentage(const float& percentage);
197
200 int& precision();
201
205 progress_indicator& precision(const int& precision);
206
207 public:
214 [[nodiscard]]
215 static progress_indicator& add(containers::page& page, const std::string& alias = std::string());
216
223 [[nodiscard]]
224 static progress_indicator& get(form& fm, const std::string& path);
225 };
226 }
227 }
228}
229
230#if defined(lecui_helper)
232#define get_progress_indicator(path) liblec::lecui::widgets::progress_indicator::get(*this, path)
233#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 indicator widget. To instantiate and add to a container use the add static method.
Definition: progress_indicator.h:24
float & line_thickness_fill()
Get or set the line thickness of the filled portion of the indicator.
static progress_indicator & get(form &fm, const std::string &path)
Get the specifications of a progress indicator.
progress_indicator & cursor(const cursor_type cursor)
Set the mouse cursor to use when over the widget.
bool operator==(const progress_indicator &param)
Check whether widget specs are equal. Only those properties that require the widget resources to be r...
progress_indicator & precision(const int &precision)
Set the precision to use for displaying the percentage.
progress_indicator & color_disabled(const color &color_disabled)
Set the widget's color when it is disabled.
progress_indicator & line_thickness_empty(const float &line_thickness_empty)
Set the line thickness of the empty portion of the indicator.
int & precision()
Get or set the precision to use for displaying the percentage.
progress_indicator & color_fill(const color &color_fill)
Set the fill color of the widget.
color & color_empty()
Get or set the color to use for the empty portion of the indicator.
bool operator!=(const progress_indicator &param)
Check whether widget specs are NOT equal. Only those properties that require the widget resources to ...
std::string & text() override
Get or set the widget text.
color & color_hot() override
Get or set the widget's color when the mouse is hovered over it.
float & line_thickness_empty()
Get or set the line thickness of the empty portion of the indicator.
std::string & font() override
Get or set the default widget font, e.g. "Georgia".
resize_params & on_resize() override
Get or set the behaviour of the widget when its container is resized.
lecui::rect & rect() override
Get or set the position and dimensions of the widget.
float & font_size() override
Get or set the default widget font size in points, e.g. 9.0f.
progress_indicator & line_thickness_fill(const float &line_thickness_fill)
Set the line thickness of the filled portion of the indicator.
progress_indicator & color_empty(const color &color_empty)
Set the color to use for the empty portion of the indicator
progress_indicator & percentage(const float &percentage)
Set the percentage of the progress indicator (0.f - 100.f).
progress_indicator & color_selected(const color &color_selected)
Set the widget's color when selected.
progress_indicator & 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.
progress_indicator()
Constructor.
Definition: progress_indicator.h:33
progress_indicator & font(const std::string &font)
Set the default widget font.
progress_indicator & tooltip(const std::string &tooltip)
Set the tooltip text.
color & color_disabled() override
Get or set the widget's color when it is disabled.
static progress_indicator & add(containers::page &page, const std::string &alias=std::string())
Add a progress indicator to a container.
color & color_selected() override
Get or set the widget's color when selected.
color & color_text() override
Get or set the color of the widget's text.
progress_indicator & rect(const lecui::rect &rect)
Set the position and dimensions of the widget.
progress_indicator & text(const std::string &text)
Set the widget's text.
cursor_type & cursor() override
Get or set the mouse cursor to use then over the widget.
progress_indicator & font_size(const float &font_size)
Set the widget's font size.
progress_indicator & color_text(const color &color_text)
Set the color of the widget's text.
progress_indicator & color_hot(const color &color_hot)
Set the widget's color when the mouse is hovered over it.
float & percentage()
Get or set the percentage of the progress indicator (0.f - 100.f).
std::string & tooltip() override
Get or set the widget's 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