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
UIElement.h
Go to the documentation of this file.
1
5
6#ifndef UIELEMENT_H_
7#define UIELEMENT_H_
8
9#include "UIElementType.h"
10#include "TouchTypes.h"
11#include "Keys.h"
12#include <stdint.h>
13#include <Adafruit_GFX.h>
14
15#include "Fonts/FreeSans12pt7b.h"
16
17// https://forum.arduino.cc/t/solved-rgb-in-rgb565-umwandeln-und-mit-0x-in-eine-variable-schreiben/1146991/2
18#define RGB565(r, g, b) ((((r)& 0xF8) << 8) | (((g) & 0xFC) << 3) | (((b) & 0xF8) >> 3))
19
24{
25 protected:
27
28 public:
30 uint16_t LocX;
31 uint16_t LocY;
32 uint16_t Width;
33 uint16_t Height;
34 bool Visible;
38
44 {
45 Visible = true;
46 IsInEditMode = false;
47 Type = type;
48 ActiveChild = NULL;
49 }
50
57 UIElement(uint16_t locX, uint16_t locY, UIElementType type)
58 {
59 LocX = locX;
60 LocY = locY;
61 Visible = true;
62 IsInEditMode = false;
63 Type = type;
64 ActiveChild = NULL;
65 }
66
72 virtual void Draw(bool redraw) = 0;
73
82 virtual bool KeyInput(Keys_t key) { return false; }
83
91 virtual bool TouchInput(uint16_t x, uint16_t y, TouchTypes touchType) { return false; }
92
96 virtual void RecalculateDimensions() = 0;
97
101 virtual void RecalculateLayout() { }
102
109 bool HitTest(uint16_t x, uint16_t y)
110 {
111 return (x >= LocX) && (x <= (LocX + Width)) && (y >= LocY) && (y <= (LocY + Height)) && Visible;
112 }
113};
114
115#endif /* UIELEMENT_H_ */
Containing definitions for all available keys.
enum Keys Keys_t
Available input keys.
Containing the definition for all touch types.
TouchTypes
Available touch types.
Definition TouchTypes.h:13
Containing the definition for all user interface element types (controls, indicators,...
UIElementType
Available user interface element types.
Definition UIElementType.h:14
bool _lastDrawnVisible
The Visible value that was last drawn.
Definition UIElement.h:26
bool IsInEditMode
Is the UIElement in edit mode?
Definition UIElement.h:35
UIElement * Parent
Parent UIElement that this UIElement belongs to.
Definition UIElement.h:36
virtual void RecalculateDimensions()=0
Recalculate the Height and Width of the UIElement.
virtual bool KeyInput(Keys_t key)
Process the given key.
Definition UIElement.h:82
virtual void RecalculateLayout()
Recalculate the UIElement layout (containers update the X- and Y-Location of all their items,...
Definition UIElement.h:101
UIElement * ActiveChild
Child element that is currently active (receiving all key inputs).
Definition UIElement.h:37
UIElement(uint16_t locX, uint16_t locY, UIElementType type)
Constructor of the UIElement.
Definition UIElement.h:57
UIElementType Type
Element type (control, indicator, container)
Definition UIElement.h:29
bool HitTest(uint16_t x, uint16_t y)
Check if the given point (x, y) is inside this UIElement.
Definition UIElement.h:109
uint16_t Height
Drawing height of the UIElement.
Definition UIElement.h:33
uint16_t LocY
Y Location of the upper left corner of the UIElement.
Definition UIElement.h:31
bool Visible
The UIElement is only drawn if the visibility is set to true.
Definition UIElement.h:34
virtual bool TouchInput(uint16_t x, uint16_t y, TouchTypes touchType)
Process a touch input at the given point (x, y)
Definition UIElement.h:91
uint16_t Width
Drawing width of the UIElement.
Definition UIElement.h:32
virtual void Draw(bool redraw)=0
Virtual method used for drawing of the UIElement.
UIElement(UIElementType type)
Constructor of the UIElement.
Definition UIElement.h:43
uint16_t LocX
X Location of the upper left corner of the UIElement.
Definition UIElement.h:30