-
Notifications
You must be signed in to change notification settings - Fork 2
/
gui.h
123 lines (99 loc) · 1.54 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
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
#pragma once
#include "config.h"
#include "SDL.h"
#include "vmath.h"
typedef struct Rectangle Rectangle;
typedef struct Component Component;
typedef struct Container Container;
typedef struct Button Button;
typedef struct Slot Slot;
typedef struct Label Label;
typedef struct Icon Icon;
typedef struct ScrollBar ScrollBar;
typedef struct Window Window;
typedef struct Event Event;
typedef enum
{
NONE,
KEY_DOWN,
KEY_UP,
MOUSE_MOTION,
MOUSE_UP,
MOUSE_DOWN,
}EventType;
struct Event
{
EventType type;
Vec2f mouse;
int button;
int keyCode;
int buttonState;
int keyState;
};
struct Rectangle
{
Vec2f pos;
Vec2f size;
};
typedef enum
{
CONTAINER,
BUTTON,
SLOT,
LABEL,
ICON,
SCROLL_BAR,
CANVAS,
}ComponentType;
struct Component
{
ComponentType type;
Vec2f pos;
Vec2f size;
int nextChild;
};
struct Container
{
Component;
int firstChild;
};
struct Button
{
Component;
bool enabled;
const char* text;
};
struct Slot
{
Component;
bool enabled;
void* data;
};
struct Label
{
Component;
const char* text;
};
struct Icon
{
Component;
uint texture;
Rectangle scrollRect;
};
struct Window
{
Container;
bool background;
Component* focus;
union
{
Component;
Container container;
Button button;
Slot slot;
Label label;
Icon icon;
}component[];
};
public void windowDraw(Window* window);
public bool windowEvent(Window* client,Event* event);