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< T > Class Template Reference

Class for a progress bar indicator that is showing a horizontal progress bar. More...

#include <ProgressBar.h>

Inheritance diagram for ProgressBar< T >:
UIElement

Public Member Functions

 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.
 
virtual void Draw (bool redraw) override
 Method used for drawing of the ProgressBar.
 
virtual void RecalculateDimensions () override
 Recalculate the Height and Width of the UIElement.
 
virtual void RecalculateLayout () override
 Recalculate the UIElement layout (containers update the X- and Y-Location of all their items, all other items can do other layout update stuff)
 
- Public Member Functions inherited from UIElement
 UIElement (UIElementType type)
 Constructor of the UIElement.
 
 UIElement (uint16_t locX, uint16_t locY, UIElementType type)
 Constructor of the UIElement.
 
virtual bool KeyInput (Keys_t key)
 Process the given key.
 
virtual bool TouchInput (uint16_t x, uint16_t y, TouchTypes touchType)
 Process a touch input at the given point (x, y)
 
bool HitTest (uint16_t x, uint16_t y)
 Check if the given point (x, y) is inside this UIElement.
 

Public Attributes

uint16_t ProgressbarWidth
 Drawing width of the ProgressBar (without min and max texts and tick markers)
 
uint16_t ProgressbarHeight
 Drawing height of the ProgressBar (without min and max texts and tick markers)
 
- Public Attributes inherited from UIElement
UIElementType Type
 Element type (control, indicator, container)
 
uint16_t LocX
 X Location of the upper left corner of the UIElement.
 
uint16_t LocY
 Y Location of the upper left corner of the UIElement.
 
uint16_t Width
 Drawing width of the UIElement.
 
uint16_t Height
 Drawing height of the UIElement.
 
bool Visible
 The UIElement is only drawn if the visibility is set to true.
 
bool IsInEditMode
 Is the UIElement in edit mode?
 
UIElementParent
 Parent UIElement that this UIElement belongs to.
 
UIElementActiveChild
 Child element that is currently active (receiving all key inputs).
 

Private Member Functions

uint16_t xCoordinateFromValue (T value)
 Calculate the X coordinate of the value on the progress bar.
 

Private Attributes

T * _valuePointer
 Pointer to the numeric variable that is used to draw this indicator.
 
_lastValueDraw
 This variable is updated from the _valuePointer when the value changed.
 
_minValue
 Minimum value that can be shown by the progress bar.
 
_maxValue
 Maximum value that can be shown by the progress bar.
 
ProgressBarOrigin_t _origin
 Origin position of this progress bar.
 
_tickIncrement
 Distance between tick lines drawn above the progress bar.
 
uint16_t _originXCoord
 X coordinate of the origin calculated on layout reconstruction.
 
uint16_t _minValueTextWidth
 Text width of the minimum value text.
 
uint16_t _maxValueTextWidth
 Text width of the maximum value text.
 

Additional Inherited Members

- Protected Attributes inherited from UIElement
bool _lastDrawnVisible
 The Visible value that was last drawn.
 

Detailed Description

template<class T>
class ProgressBar< T >

Class for a progress bar indicator that is showing a horizontal progress bar.

Template Parameters
TType of numeric variable used by this indicator for drawing. This can be e.g. float or int.

Constructor & Destructor Documentation

◆ ProgressBar()

template<class T>
ProgressBar< T >::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.

Parameters
valuePointerPointer to the numeric variable that is used by this indicator.
minValueMinimum value that can be shown by the progress bar. It is used to calculate the filled area.
maxValueMaximum value that can be shown by the progress bar. It is used to calculate the filled area.
originOrigin position of this progress bar. See the ProgressBarOrigin enumeration for more details on the different options.
tickIncrementDistance between tick lines drawn above the progress bar. Set this to 0 (or negative) to disable ticks.
progressbarWidthDrawing width of the ProgressBar (without min and max texts and tick markers)
progressbarHeightDrawing height of the ProgressBar (without min and max texts and tick markers)
locXX Location of the upper left corner of the ProgressBar
locYY Location of the upper left corner of the ProgressBar

Member Function Documentation

◆ Draw()

template<class T>
void ProgressBar< T >::Draw ( bool redraw)
overridevirtual

Method used for drawing of the ProgressBar.

Implements UIElement.

◆ RecalculateDimensions()

template<class T>
void ProgressBar< T >::RecalculateDimensions ( )
overridevirtual

Recalculate the Height and Width of the UIElement.

Implements UIElement.

◆ RecalculateLayout()

template<class T>
void ProgressBar< T >::RecalculateLayout ( )
overridevirtual

Recalculate the UIElement layout (containers update the X- and Y-Location of all their items, all other items can do other layout update stuff)

Reimplemented from UIElement.

◆ xCoordinateFromValue()

template<class T>
uint16_t ProgressBar< T >::xCoordinateFromValue ( T value)
private

Calculate the X coordinate of the value on the progress bar.

This takes the _minValue, _maxValue and ProgressbarWidth into account.

Parameters
valuevalue for which the X coordinate should be calculated.
Returns
Calculated X coordinate. This is inside the progressbar region.

Member Data Documentation

◆ _maxValue

template<class T>
T ProgressBar< T >::_maxValue
private

Maximum value that can be shown by the progress bar.

It is used to calculate the filled area.

◆ _minValue

template<class T>
T ProgressBar< T >::_minValue
private

Minimum value that can be shown by the progress bar.

It is used to calculate the filled area.

◆ _origin

template<class T>
ProgressBarOrigin_t ProgressBar< T >::_origin
private

Origin position of this progress bar.

See the ProgressBarOrigin enumeration for more details on the different options.

◆ _tickIncrement

template<class T>
T ProgressBar< T >::_tickIncrement
private

Distance between tick lines drawn above the progress bar.

Set this to 0 (or negative) to disable ticks.


The documentation for this class was generated from the following files: