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

Class for a enum control that is showing a enumeration variable value and offers the possibility to edit the value. More...

#include <EnumControl.h>

Inheritance diagram for EnumControl< T >:
EnumIndicator< T > UIElement

Public Member Functions

 EnumControl (T *valuePointer, const char **enumNames, uint8_t numEnumValues, void *controlContext=NULL, void(*onValueChanged)(void *controlContext)=NULL, uint16_t locX=0, uint16_t locY=0)
 Constructor of the EnumControl.
 
virtual void Draw (bool redraw) override
 Method used for drawing of the EnumControl.
 
virtual bool KeyInput (Keys_t key) override
 Process the given key.
 
virtual bool TouchInput (uint16_t x, uint16_t y, TouchTypes touchType) override
 Process a touch input at the given point (x, y)
 
bool PreviousValue ()
 Set the value of the controlled enumeration variable to the previous enum value.
 
bool NextValue ()
 Set the value of the controlled enumeration variable to the next enum value.
 
void ToggleEditMode ()
 Toggle the control between display and edit mode.
 
- Public Member Functions inherited from EnumIndicator< T >
 EnumIndicator (T *valuePointer, const char **enumNames, uint8_t numEnumValues, uint16_t locX=0, uint16_t locY=0)
 Constructor of the EnumIndicator.
 
virtual void RecalculateDimensions () override
 Recalculate the Height and Width of the UIElement.
 
- 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 void RecalculateLayout ()
 Recalculate the UIElement layout (containers update the X- and Y-Location of all their items, all other items can do other layout update stuff)
 
bool HitTest (uint16_t x, uint16_t y)
 Check if the given point (x, y) is inside this UIElement.
 

Private Attributes

void * _controlContext
 Context pointer that is returned with the _onValueChanged function pointer.
 
void(* _onValueChanged )(void *controlContext)
 Function pointer for _onValueChanged event.
 
bool _lastDrawnEditMode
 The EditMode that was last drawn.
 

Additional Inherited Members

- 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).
 
- Protected Attributes inherited from EnumIndicator< T >
const char ** _enumNames
 Pointer to an array of char pointers containing the display names for all enumeration values.
 
uint8_t _numEnumValues
 Number of enumeration values.
 
T * _valuePointer
 Pointer to the enumeration variable that is shown by this indicator.
 
_lastValueDraw
 Last drawn enum value.
 
- Protected Attributes inherited from UIElement
bool _lastDrawnVisible
 The Visible value that was last drawn.
 

Detailed Description

template<class T>
class EnumControl< T >

Class for a enum control that is showing a enumeration variable value and offers the possibility to edit the value.

Template Parameters
TType of enumeration handled by this control

Constructor & Destructor Documentation

◆ EnumControl()

template<class T>
EnumControl< T >::EnumControl ( T * valuePointer,
const char ** enumNames,
uint8_t numEnumValues,
void * controlContext = NULL,
void(* onValueChanged )(void *controlContext) = NULL,
uint16_t locX = 0,
uint16_t locY = 0 )

Constructor of the EnumControl.

Parameters
valuePointerPointer to the enumeration variable that is shown and manipulated by this control.
enumNamesPointer to an array of char pointers containing the display names for all enumeration values. The number of elements in this array must be at least the number of enum values.
numEnumValuesNumber of enumeration values. This number must match the real number of enum values in T.
controlContextContext pointer that is returned with the _onValueChanged function pointer
onValueChangedFunction pointer for _onValueChanged event. This function is called when the value of the valuePointer is changed.
locXX Location of the upper left corner of the EnumControl
locYY Location of the upper left corner of the EnumControl

Member Function Documentation

◆ Draw()

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

Method used for drawing of the EnumControl.

Reimplemented from EnumIndicator< T >.

◆ KeyInput()

template<class T>
bool EnumControl< T >::KeyInput ( Keys_t key)
overridevirtual

Process the given key.

If this element doesn't support the key type, the key is forwarded to the parent. This is done until the key is processed or the root of the visual tree is reached.

Parameters
keyKey that should be processed. Supported keys are: KEYOK, KEYUP, KEYDOWN
Returns
true if the key was processed; false if not.

Reimplemented from UIElement.

◆ NextValue()

template<class T>
bool EnumControl< T >::NextValue ( )

Set the value of the controlled enumeration variable to the next enum value.

If the current value is the last one, the control selects the first enum value to implement a circular behaviour.

◆ PreviousValue()

template<class T>
bool EnumControl< T >::PreviousValue ( )

Set the value of the controlled enumeration variable to the previous enum value.

If the current value is the first one, the control selects the last enum value to implement a circular behaviour.

◆ ToggleEditMode()

template<class T>
void EnumControl< T >::ToggleEditMode ( )

Toggle the control between display and edit mode.

Some keys are only supported in edit mode.

◆ TouchInput()

template<class T>
bool EnumControl< T >::TouchInput ( uint16_t x,
uint16_t y,
TouchTypes touchType )
overridevirtual

Process a touch input at the given point (x, y)

Parameters
xX-Coordinate of the touched point
yY-Coordinate of the touched point
touchTypeType of the touch
Returns
true if the touch was processed; false if not.

Reimplemented from UIElement.

Member Data Documentation

◆ _lastDrawnEditMode

template<class T>
bool EnumControl< T >::_lastDrawnEditMode
private

The EditMode that was last drawn.

Used to detect changes in the edit mode.

◆ _onValueChanged

template<class T>
void(* EnumControl< T >::_onValueChanged) (void *controlContext)
private

Function pointer for _onValueChanged event.

This function is called when the value of the valuePointer is changed.


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