-
Notifications
You must be signed in to change notification settings - Fork 1
/
LayoutItem.h
166 lines (128 loc) · 4.24 KB
/
LayoutItem.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#pragma once
#include <memory>
#include <list>
#include <functional>
#include <M5EPD.h>
#include "Utility.h"
class DisplayManager;
class LayoutItemAction
{
public:
virtual ~LayoutItemAction() = default;
virtual bool hasAction() { return true; };
virtual void doAction() = 0;
};
class LayoutItemAction_None : public LayoutItemAction
{
public:
virtual bool hasAction() { return false; };
virtual void doAction() {};
};
class LayoutItemAction_StdFunction : public LayoutItemAction
{
public:
LayoutItemAction_StdFunction( std::function<void(void)> func ) : Func(func) {};
std::function<void(void)> Func;
virtual bool hasAction() { return !!Func; };
virtual void doAction() { Func(); };
};
class LayoutItem
{
public:
using tdAction = std::shared_ptr<LayoutItemAction>;
LayoutItem( Rect<uint16_t> rect, tdAction action = nullptr );
virtual ~LayoutItem() = default;
Rect<uint16_t> Location;
tdAction Action;
virtual void draw( DisplayManager& ) = 0;
virtual bool hitTest( const Point<uint16_t>& );
};
class LayoutItemWithFont : public LayoutItem
{
public:
using tdAction = std::shared_ptr<LayoutItemAction>;
LayoutItemWithFont( Rect<uint16_t> rect, const GFXfont* font = nullptr, uint8_t align = TL_DATUM, tdAction action = nullptr );
virtual ~LayoutItemWithFont() = default;
const GFXfont* Font = nullptr;
uint8_t TextAlign = TL_DATUM;
virtual void drawString( DisplayManager&, String str );
};
class LayoutItem_ButtonIcon : public LayoutItem
{
public:
LayoutItem_ButtonIcon( Rect<uint16_t> rect, const unsigned char* data, size_t size, tdAction action = nullptr );
const unsigned char* Data = nullptr;
size_t DataSize = 0;
virtual void draw( DisplayManager& ) override;
};
class LayoutItem_ButtonIconWithHighlight : public LayoutItem_ButtonIcon
{
public:
using tdHighlightFunc = std::function<bool(void)>;
LayoutItem_ButtonIconWithHighlight( Rect<uint16_t> rect, const unsigned char* data, size_t size, tdHighlightFunc func = nullptr, tdAction action = nullptr );
tdHighlightFunc HighlightFunc;
virtual void draw( DisplayManager& ) override;
};
class LayoutItem_Rectangle : public LayoutItem
{
using LayoutItem::LayoutItem;
virtual void draw( DisplayManager& ) override;
};
class LayoutItem_StaticText : public LayoutItemWithFont
{
public:
LayoutItem_StaticText( Rect<uint16_t> rect, const GFXfont* font, uint8_t align, String text, tdAction action = nullptr );
String Text;
virtual void draw( DisplayManager& ) override;
};
class LayoutItem_DynamicText : public LayoutItemWithFont
{
public:
using tdStringFunc = std::function<String(void)>;
using tdOutlineFunc = std::function<bool(void)>;
LayoutItem_DynamicText( Rect<uint16_t> rect, const GFXfont* font, uint8_t align, tdStringFunc textFunc, tdOutlineFunc outlineFunc = [](){return false;}, tdAction action = nullptr );
tdStringFunc TextFunc;
tdOutlineFunc OutlineFunc;
virtual void draw( DisplayManager& ) override;
};
class LayoutItemAction_SudokuSquare : public LayoutItemAction
{
public:
LayoutItemAction_SudokuSquare( uint8_t x, uint8_t y );
Point<uint8_t> WhichSquare;
virtual void doAction() override;
};
class LayoutItem_SudokuSquare : public LayoutItem
{
public:
LayoutItem_SudokuSquare( Rect<uint16_t> rect, uint8_t x, uint8_t y );
Point<uint8_t> WhichSquare;
virtual void draw( DisplayManager& ) override;
};
class LayoutItemAction_SudokuSubSquare : public LayoutItemAction
{
public:
LayoutItemAction_SudokuSubSquare( uint8_t val );
uint8_t WhichValue;
virtual void doAction() override;
};
class LayoutItem_SudokuSubSquare : public LayoutItem
{
public:
LayoutItem_SudokuSubSquare( Rect<uint16_t> rect, uint8_t val );
uint8_t WhichValue;
virtual void draw( DisplayManager& ) override;
};
class LayoutItem_SudokuMainBackground : public LayoutItem
{
public:
LayoutItem_SudokuMainBackground( Rect<uint16_t> rect );
virtual void draw( DisplayManager& ) override;
};
class LayoutItem_SudokuGrid : public LayoutItem
{
public:
LayoutItem_SudokuGrid( Rect<uint16_t> rect, bool bSub = false );
bool SubGrid = false;
virtual void draw( DisplayManager& ) override;
};