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.h
Go to the documentation of this file.
1
5
6#ifndef UI_MANAGER_H_
7#define UI_MANAGER_H_
8
9#include "UIElement.h"
10
11#define UI_LIB_DEFAULT_COLOR_BACKGROUND RGB565(0x00, 0x00, 0x00)
12#define UI_LIB_DEFAULT_COLOR_FOREGROUND RGB565(0xFF, 0xFF, 0xFF)
13#define UI_LIB_DEFAULT_COLOR_FOREGROUND_EDIT_MODE UI_LIB_DEFAULT_COLOR_BACKGROUND
14#define UI_LIB_DEFAULT_COLOR_FOCUS_FRAME UI_LIB_DEFAULT_COLOR_FOREGROUND
15#define UI_LIB_DEFAULT_FONT &FreeSans12pt7b
16#define UI_LIB_DEFAULT_ELEMENT_MARGIN 2
17#define UI_LIB_DEFAULT_ELEMENT_PADDING 3
18
23{
24 private:
28
30
34 void setFocusToLeaf();
35
37 UI_Manager();
38
39 public:
40 uint16_t ColorBackground;
41 uint16_t ColorForeground;
43 uint16_t ColorFocusFrame;
44 const GFXfont* Font;
45 uint16_t FontHeight;
46 uint16_t ElementMargin;
47 uint16_t ElementPadding;
49 Adafruit_GFX* Gfx;
51
58 {
59 static UI_Manager instance; // Instantiated on first use.
60 return instance;
61 }
62
67 void Init(Adafruit_GFX* gfx);
68
76 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);
77
82 void SetFont(const GFXfont* font);
83
87 void Draw();
88
94 void ChangeVisualTreeRoot(UIElement* visualTreeRoot);
95
101
109 bool KeyInput(Keys_t key);
110
118 bool TouchInput(uint16_t x, uint16_t y, TouchTypes touchType);
119
127 void UpdateIsInEditModeElement(UIElement* element, bool newEditModeState);
128};
129
130extern UI_Manager UiManager;
131
132#endif /* UI_MANAGER_H_ */
enum Keys Keys_t
Available input keys.
TouchTypes
Available touch types.
Definition TouchTypes.h:13
#define UI_LIB_DEFAULT_COLOR_FOREGROUND
Default UIElement foreground color (white)
Definition UI_Manager.h:12
#define UI_LIB_DEFAULT_COLOR_BACKGROUND
Default Background color (black)
Definition UI_Manager.h:11
UI_Manager UiManager
Access object for the singleton instance of the UI_Manager.
Definition UI_Manager.cpp:7
#define UI_LIB_DEFAULT_COLOR_FOREGROUND_EDIT_MODE
Default UIElement foreground color in edit mode (black).
Definition UI_Manager.h:13
#define UI_LIB_DEFAULT_COLOR_FOCUS_FRAME
Default Focus frame color.
Definition UI_Manager.h:14
Containing the abstract base class for all user interface elements (controls, indicators,...
Class that is used to handle the drawing and key handling of all UI_Elements.
Definition UI_Manager.h:23
uint16_t ElementPadding
Space between the outline of every UIElement and the internal content.
Definition UI_Manager.h:47
UIElement * _lastDrawnFocusElement
Last drawn focus element.
Definition UI_Manager.h:27
uint16_t ColorForegroundEditMode
Default UIElement foreground color in edit mode (black).
Definition UI_Manager.h:42
void Init(Adafruit_GFX *gfx)
Initialize the UI_Manager.
Definition UI_Manager.cpp:22
static UI_Manager & getInstance()
Get the singleton instance of the UI_Manager class.
Definition UI_Manager.h:57
uint16_t FontHeight
Maximum height of the Font (height of the string "Ag").
Definition UI_Manager.h:45
uint16_t ColorForeground
UIElement color (green)
Definition UI_Manager.h:41
const GFXfont * Font
Default font used when no other font is assigned.
Definition UI_Manager.h:44
bool CompleteRedrawRequested
True, if the tree root was currently changed.
Definition UI_Manager.h:48
void Draw()
Draw the complete visual tree (_visualTreeRoot and all of its children).
Definition UI_Manager.cpp:50
UIElement * _focusElement
Element that has the focus (it is highlited and receives all key inputs).
Definition UI_Manager.h:26
uint16_t ColorBackground
Background color (black)
Definition UI_Manager.h:40
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.
Definition UI_Manager.cpp:31
bool TouchInput(uint16_t x, uint16_t y, TouchTypes touchType)
Process a touch input at the given point (x, y)
Definition UI_Manager.cpp:134
void SetFont(const GFXfont *font)
Set the Font property and recalculate the FontHeight based on this font.
Definition UI_Manager.cpp:39
UI_Manager()
Constructor of the UI_Manager.
Definition UI_Manager.cpp:9
bool KeyInput(Keys_t key)
Forward the given key to the _focusElement.
Definition UI_Manager.cpp:118
void ChangeVisualTreeRoot(UIElement *visualTreeRoot)
Change the root element of the visual tree.
Definition UI_Manager.cpp:89
uint16_t ElementMargin
Space without content around every UIElement.
Definition UI_Manager.h:46
void setFocusToLeaf()
Traverse down the visual tree until an element without a child is reached and focus this element.
Definition UI_Manager.cpp:103
uint16_t ColorFocusFrame
Color of the focus frame.
Definition UI_Manager.h:43
void UpdateIsInEditModeElement(UIElement *element, bool newEditModeState)
Update the IsInEditMode property of the given UIElement to the given newEditModeState.
Definition UI_Manager.cpp:149
Adafruit_GFX * Gfx
Graphics object.
Definition UI_Manager.h:49
UIElement * GetVisualTreeRoot()
Return the root element of the visual tree.
Definition UI_Manager.cpp:98
bool AreVirtualKeysShown
True, if the Virtual keys are shown.
Definition UI_Manager.h:50
UIElement * _visualTreeRoot
Root element of the visual tree.
Definition UI_Manager.h:25
UIElement * _lastElementInEditMode
Last UI_Element that has the IsInEditMode property set.
Definition UI_Manager.h:29
Abstract base class for all user interface elements (controls, indicators, containers).
Definition UIElement.h:24