-
Notifications
You must be signed in to change notification settings - Fork 1
/
gui.h
92 lines (76 loc) · 2.35 KB
/
gui.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
#ifndef GUI_H
#define GUI_H
#include <hidboot.h>
class CDesktopLauncher;
class CWidget;
class CWindow;
enum
{
CHAR_BACKGROUND=0,
CHAR_TRANSPARENT,
CHAR_WINDOW_TOP_INACTIVE,
CHAR_WINDOW_TOP_ACTIVE,
CHAR_WINDOW_VERT_LEFT=128, // Start after fonts
CHAR_WINDOW_VERT_RIGHT,
CHAR_WINDOW_HORIZ_TOP,
CHAR_WINDOW_HORIZ_BOTTOM,
CHAR_WINDOW_CORNER_BOTTOM_LEFT,
CHAR_WINDOW_CORNER_BOTTOM_RIGHT,
CHAR_WINDOW_CLOSE,
CHAR_BUTTON_VERT_LEFT,
CHAR_BUTTON_VERT_RIGHT,
CHAR_BUTTON_HORIZ_TOP,
CHAR_BUTTON_HORIZ_BOTTOM,
CHAR_BUTTON_VERT_LEFT_HL,
CHAR_BUTTON_VERT_RIGHT_HL,
CHAR_BUTTON_HORIZ_TOP_HL,
CHAR_BUTTON_HORIZ_BOTTOM_HL,
CHAR_APP_ICON_START
};
#define FRAMEBUFFER 0x6FFF
enum EMouseButton { BUTTON_LEFT=0, BUTTON_RIGHT, BUTTON_MIDDLE, BUTTON_MAX };
enum EMouseButtonState { BUTTON_DOWN, BUTTON_UP };
class CUSBMouseParser : public MouseReportParser
{
protected:
virtual void OnMouseMove(MOUSEINFO *mi);
virtual void OnLeftButtonUp(MOUSEINFO *mi);
virtual void OnLeftButtonDown(MOUSEINFO *mi);
virtual void OnRightButtonUp(MOUSEINFO *mi);
virtual void OnRightButtonDown(MOUSEINFO *mi);
virtual void OnMiddleButtonUp(MOUSEINFO *mi);
virtual void OnMiddleButtonDown(MOUSEINFO *mi);
};
class CGUI
{
uint32_t updateDelay;
CUSBMouseParser mouseParser;
uint16_t mouseX, mouseY;
EMouseButtonState mouseButtonStates[BUTTON_MAX];
CWindow *bottomWindow, *topWindow;
CDesktopLauncher *firstDesktopLauncher;
CWidget *clickedWidget;
uint8_t dragXOffset, dragYOffset;
bool canDrag, dragged;
void initGD(void);
void drawWindows(void);
void redrawTopBar(void);
void updateCharScreen(void);
void drawMouse(void);
void removeWindow(CWindow *w);
public:
CGUI(void) : updateDelay(0), mouseX(200), mouseY(150), bottomWindow(0), topWindow(0),
firstDesktopLauncher(0), clickedWidget(0), canDrag(false) { }
void init(void);
void update(void);
void redrawDesktop(void);
void openWindow(CWindow *w);
void closeWindow(CWindow *w);
void addDesktopLauncher(CDesktopLauncher *l);
void moveMouse(int8_t dx, int8_t dy);
void setMouseButton(EMouseButton button, EMouseButtonState state);
uint16_t getMouseX(void) const { return mouseX; }
uint16_t getMouseY(void) const { return mouseY; }
};
extern CGUI GUI;
#endif // GUI_H