UI_Lib  a1366e08a59cc549a65fa26081e6409aa12f26d5
This is a user interface library for graphical LCDs. It offers many different controls and indicators that can be nested depending on the element types.
Loading...
Searching...
No Matches
ProgressBar.h
Go to the documentation of this file.
1
5
6#ifndef PROGRESSBAR_H_
7#define PROGRESSBAR_H_
8
9#include "../Core/UIElement.h"
10
20
21#define PROGRESSBAR_LONG_TICK_LENGTH 6
22#define PROGRESSBAR_MIDDLE_TICK_LENGTH 4
23#define PROGRESSBAR_SHORT_TICK_LENGTH 2
24
29template <class T>
30class ProgressBar : public UIElement
31{
32 private:
39 uint16_t _originXCoord;
40
43
50 uint16_t xCoordinateFromValue(T value);
51
52 public:
55
68 ProgressBar(T* valuePointer, T minValue, T maxValue, ProgressBarOrigin_t origin, T tickIncrement, uint16_t progressbarWidth = 80, uint16_t progressbarHeight = 10, uint16_t locX = 0, uint16_t locY = 0);
69
73 virtual void Draw(bool redraw) override;
74
78 virtual void RecalculateDimensions() override;
79
83 virtual void RecalculateLayout() override;
84};
85
86
87#endif /* PROGRESSBAR_H_ */
ProgressBarOrigin
Available progress bar origin positions.
Definition ProgressBar.h:15
@ PROGRESSBAR_ORIGIN_ZERO
Origin is at the zero point.
Definition ProgressBar.h:17
@ PROGRESSBAR_ORIGIN_RIGHT
Origin is on the right.
Definition ProgressBar.h:18
@ PROGRESSBAR_ORIGIN_LEFT
Origin is on the left.
Definition ProgressBar.h:16
enum ProgressBarOrigin ProgressBarOrigin_t
Available progress bar origin positions.
Containing the abstract base class for all user interface elements (controls, indicators,...
uint16_t xCoordinateFromValue(T value)
Calculate the X coordinate of the value on the progress bar.
Definition ProgressBar.cpp:10
T _lastValueDraw
This variable is updated from the _valuePointer when the value changed.
Definition ProgressBar.h:34
uint16_t ProgressbarWidth
Drawing width of the ProgressBar (without min and max texts and tick markers)
Definition ProgressBar.h:53
T _tickIncrement
Distance between tick lines drawn above the progress bar.
Definition ProgressBar.h:38
T * _valuePointer
Pointer to the numeric variable that is used to draw this indicator.
Definition ProgressBar.h:33
uint16_t _maxValueTextWidth
Text width of the maximum value text.
Definition ProgressBar.h:42
uint16_t _originXCoord
X coordinate of the origin calculated on layout reconstruction.
Definition ProgressBar.h:39
uint16_t ProgressbarHeight
Drawing height of the ProgressBar (without min and max texts and tick markers)
Definition ProgressBar.h:54
ProgressBar(T *valuePointer, T minValue, T maxValue, ProgressBarOrigin_t origin, T tickIncrement, uint16_t progressbarWidth=80, uint16_t progressbarHeight=10, uint16_t locX=0, uint16_t locY=0)
Constructor of the ProgressBar.
Definition ProgressBar.cpp:18
T _minValue
Minimum value that can be shown by the progress bar.
Definition ProgressBar.h:35
uint16_t _minValueTextWidth
Text width of the minimum value text.
Definition ProgressBar.h:41
virtual void RecalculateDimensions() override
Recalculate the Height and Width of the UIElement.
Definition ProgressBar.cpp:78
virtual void RecalculateLayout() override
Recalculate the UIElement layout (containers update the X- and Y-Location of all their items,...
Definition ProgressBar.cpp:91
virtual void Draw(bool redraw) override
Method used for drawing of the ProgressBar.
Definition ProgressBar.cpp:30
ProgressBarOrigin_t _origin
Origin position of this progress bar.
Definition ProgressBar.h:37
T _maxValue
Maximum value that can be shown by the progress bar.
Definition ProgressBar.h:36
UIElement(UIElementType type)
Constructor of the UIElement.
Definition UIElement.h:43