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.
|
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. | |
UIElement * | GetVisualTreeRoot () |
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_Manager & | getInstance () |
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. | |
Class that is used to handle the drawing and key handling of all UI_Elements.
void UI_Manager::ChangeVisualTreeRoot | ( | UIElement * | visualTreeRoot | ) |
Change the root element of the visual tree.
This changes the _visualTreeRoot variable and recalculates the _focusElement.
visualTreeRoot | UIElement that becomes the new root element of the visual tree. |
|
inlinestatic |
Get the singleton instance of the UI_Manager class.
Usage: UI_Manager UiManager = UI_Manager::getInstance();
UIElement * UI_Manager::GetVisualTreeRoot | ( | ) |
Return the root element of the visual tree.
void UI_Manager::Init | ( | Adafruit_GFX * | gfx | ) |
Initialize the UI_Manager.
This method sets the font and foreground color of the graphic library.
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.
key | Key that should be processed. |
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.
colorBackground | Background color |
colorForeground | UIElement color |
colorForegroundEditMode | 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. |
colorFocusFrame | Color of the focus frame |
void UI_Manager::SetFont | ( | const GFXfont * | font | ) |
Set the Font property and recalculate the FontHeight based on this font.
font | New font to use for all UIElements |
bool UI_Manager::TouchInput | ( | uint16_t | x, |
uint16_t | y, | ||
TouchTypes | touchType ) |
Process a touch input at the given point (x, y)
x | X-Coordinate of the touched point |
y | Y-Coordinate of the touched point |
touchType | Type of the touch |
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.
element | UIElement for which the IsInEditMode property is modified. |
newEditModeState | New Value for the IsInEditMode property. |
|
private |
Last UI_Element that has the IsInEditMode property set.
If no UI_Element is in edit mode, this is NULL.
|
private |
Root element of the visual tree.
This element and all children are drawn to the screen.
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.
bool UI_Manager::CompleteRedrawRequested |
True, if the tree root was currently changed.
This is set to false on the first draw then.
uint16_t UI_Manager::ElementMargin |
uint16_t UI_Manager::ElementPadding |
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.