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
UI_Manager Class Reference

Class that is used to handle the drawing and key handling of all UI_Elements. More...

#include <UI_Manager.h>

Public Member Functions

void Init (Adafruit_GFX *gfx)
 Initialize the UI_Manager.
 
void SetColors (uint16_t colorBackground=UI_LIB_DEFAULT_COLOR_BACKGROUND, uint16_t colorForeground=UI_LIB_DEFAULT_COLOR_FOREGROUND, uint16_t colorForegroundEditMode=UI_LIB_DEFAULT_COLOR_FOREGROUND_EDIT_MODE, uint16_t colorFocusFrame=UI_LIB_DEFAULT_COLOR_FOCUS_FRAME)
 Set all colors.
 
void SetFont (const GFXfont *font)
 Set the Font property and recalculate the FontHeight based on this font.
 
void Draw ()
 Draw the complete visual tree (_visualTreeRoot and all of its children).
 
void ChangeVisualTreeRoot (UIElement *visualTreeRoot)
 Change the root element of the visual tree.
 
UIElementGetVisualTreeRoot ()
 Return the root element of the visual tree.
 
bool KeyInput (Keys_t key)
 Forward the given key to the _focusElement.
 
bool TouchInput (uint16_t x, uint16_t y, TouchTypes touchType)
 Process a touch input at the given point (x, y)
 
void UpdateIsInEditModeElement (UIElement *element, bool newEditModeState)
 Update the IsInEditMode property of the given UIElement to the given newEditModeState.
 

Static Public Member Functions

static UI_ManagergetInstance ()
 Get the singleton instance of the UI_Manager class.
 

Public Attributes

uint16_t ColorBackground
 Background color (black)
 
uint16_t ColorForeground
 UIElement color (green)
 
uint16_t ColorForegroundEditMode
 Default UIElement foreground color in edit mode (black).
 
uint16_t ColorFocusFrame
 Color of the focus frame.
 
const GFXfont * Font
 Default font used when no other font is assigned.
 
uint16_t FontHeight
 Maximum height of the Font (height of the string "Ag").
 
uint16_t ElementMargin
 Space without content around every UIElement.
 
uint16_t ElementPadding
 Space between the outline of every UIElement and the internal content.
 
bool CompleteRedrawRequested
 True, if the tree root was currently changed.
 
Adafruit_GFX * Gfx
 Graphics object.
 
bool AreVirtualKeysShown
 True, if the Virtual keys are shown.
 

Private Member Functions

void setFocusToLeaf ()
 Traverse down the visual tree until an element without a child is reached and focus this element.
 
 UI_Manager ()
 Constructor of the UI_Manager.
 

Private Attributes

UIElement_visualTreeRoot
 Root element of the visual tree.
 
UIElement_focusElement
 Element that has the focus (it is highlited and receives all key inputs).
 
UIElement_lastDrawnFocusElement
 Last drawn focus element.
 
UIElement_lastElementInEditMode = NULL
 Last UI_Element that has the IsInEditMode property set.
 

Detailed Description

Class that is used to handle the drawing and key handling of all UI_Elements.

Member Function Documentation

◆ ChangeVisualTreeRoot()

void UI_Manager::ChangeVisualTreeRoot ( UIElement * visualTreeRoot)

Change the root element of the visual tree.

This changes the _visualTreeRoot variable and recalculates the _focusElement.

Parameters
visualTreeRootUIElement that becomes the new root element of the visual tree.

◆ getInstance()

static UI_Manager & UI_Manager::getInstance ( )
inlinestatic

Get the singleton instance of the UI_Manager class.

Usage: UI_Manager UiManager = UI_Manager::getInstance();

◆ GetVisualTreeRoot()

UIElement * UI_Manager::GetVisualTreeRoot ( )

Return the root element of the visual tree.

Returns
Visual tree root element.

◆ Init()

void UI_Manager::Init ( Adafruit_GFX * gfx)

Initialize the UI_Manager.

This method sets the font and foreground color of the graphic library.

◆ KeyInput()

bool UI_Manager::KeyInput ( Keys_t key)

Forward the given key to the _focusElement.

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

Parameters
keyKey that should be processed.
Returns
true if the key was processed; false if no control in the visual tree has processed the key.

◆ SetColors()

void UI_Manager::SetColors ( uint16_t colorBackground = UI_LIB_DEFAULT_COLOR_BACKGROUND,
uint16_t colorForeground = UI_LIB_DEFAULT_COLOR_FOREGROUND,
uint16_t colorForegroundEditMode = UI_LIB_DEFAULT_COLOR_FOREGROUND_EDIT_MODE,
uint16_t colorFocusFrame = UI_LIB_DEFAULT_COLOR_FOCUS_FRAME )

Set all colors.

Parameters
colorBackgroundBackground color
colorForegroundUIElement color
colorForegroundEditModeUIElement foreground color in edit mode (black). When some controls are in edit mode, the background is drawn in the foreground color and the text is drawn with this color.
colorFocusFrameColor of the focus frame

◆ SetFont()

void UI_Manager::SetFont ( const GFXfont * font)

Set the Font property and recalculate the FontHeight based on this font.

Parameters
fontNew font to use for all UIElements

◆ TouchInput()

bool UI_Manager::TouchInput ( uint16_t x,
uint16_t y,
TouchTypes touchType )

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.

◆ UpdateIsInEditModeElement()

void UI_Manager::UpdateIsInEditModeElement ( UIElement * element,
bool newEditModeState )

Update the IsInEditMode property of the given UIElement to the given newEditModeState.

This method makes sure that the IsInEditMode property of the UIElement that was previously modified using this method is deactivated. So only one UIElement can have the IsInEditMode property active at a time.

Parameters
elementUIElement for which the IsInEditMode property is modified.
newEditModeStateNew Value for the IsInEditMode property.

Member Data Documentation

◆ _lastElementInEditMode

UIElement* UI_Manager::_lastElementInEditMode = NULL
private

Last UI_Element that has the IsInEditMode property set.

If no UI_Element is in edit mode, this is NULL.

◆ _visualTreeRoot

UIElement* UI_Manager::_visualTreeRoot
private

Root element of the visual tree.

This element and all children are drawn to the screen.

◆ ColorForegroundEditMode

uint16_t UI_Manager::ColorForegroundEditMode

Default UIElement foreground color in edit mode (black).

When some controls are in edit mode, the background is drawn in the foreground color and the text is drawn with this color.

◆ CompleteRedrawRequested

bool UI_Manager::CompleteRedrawRequested

True, if the tree root was currently changed.

This is set to false on the first draw then.

◆ ElementMargin

uint16_t UI_Manager::ElementMargin

Space without content around every UIElement.

This is part of the UIElement size.

◆ ElementPadding

uint16_t UI_Manager::ElementPadding

Space between the outline of every UIElement and the internal content.

This is part of the UIElement size.

◆ FontHeight

uint16_t UI_Manager::FontHeight

Maximum height of the Font (height of the string "Ag").

This parameter is recalculated when the SetFont() method is used.


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