/
definitions.hh
325 lines (283 loc) · 6.72 KB
/
definitions.hh
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
/* *
* fgui - an extensive oop gui framework *
* */
#pragma once
// includes
#include <string>
#include <vector>
#ifdef _WIN32
#define NOMINMAX
#include <windows.h>
#endif
namespace fgui {
// handlers
typedef int key;
typedef int delta;
typedef bool state;
typedef unsigned long font;
// you are not supposed to edit the contents of this namespace. but if you know what you are doing, go ahead.
namespace detail {
enum struct element_type : int {
BUTTON = 1,
CHECKBOX,
COLORPICKER,
COMBOBOX,
KEYBINDER,
LABEL,
LISTBOX,
MULTIBOX,
SLIDER,
TEXTBOX,
COLORLIST,
CONTAINER,
TAB,
SPINNER
};
enum struct element_flags : int {
DRAWABLE = (1 << 0),
CLICKABLE = (1 << 1),
FOCUSABLE = (1 << 2),
SAVABLE = (1 << 3)
};
struct item_info {
item_info() { item = ""; checked = false; value = 0; };
item_info(const std::string_view _item, int _value) : item(_item), value(_value) {}
item_info(const std::string_view _item, bool _state) : item(_item), checked(_state) {}
item_info(const std::string_view _item) : item(_item) {}
item_info(const std::vector<std::string> &_items) : items(_items) {}
int value = 0;
bool checked = false;
std::string item = "";
std::vector<std::string> items;
};
}
// everything inside this namespace usually depends of an external library to work.
namespace external {
// this will only work if you are using IInputSystem (Source Engine)
enum key_code {
KEY_0 = 0x1,
KEY_1 = 0x2,
KEY_2 = 0x3,
KEY_3 = 0x4,
KEY_4 = 0x5,
KEY_5 = 0x6,
KEY_6 = 0x7,
KEY_7 = 0x8,
KEY_8 = 0x9,
KEY_9 = 0xA,
KEY_A = 0xB,
KEY_B = 0xC,
KEY_C = 0xD,
KEY_D = 0xE,
KEY_E = 0xF,
KEY_F = 0x10,
KEY_G = 0x11,
KEY_H = 0x12,
KEY_I = 0x13,
KEY_J = 0x14,
KEY_K = 0x15,
KEY_L = 0x16,
KEY_M = 0x17,
KEY_N = 0x18,
KEY_O = 0x19,
KEY_P = 0x1A,
KEY_Q = 0x1B,
KEY_R = 0x1C,
KEY_S = 0x1D,
KEY_T = 0x1E,
KEY_U = 0x1F,
KEY_V = 0x20,
KEY_W = 0x21,
KEY_X = 0x22,
KEY_Y = 0x23,
KEY_Z = 0x24,
KEY_PAD_0 = 0x25,
KEY_PAD_1 = 0x26,
KEY_PAD_2 = 0x27,
KEY_PAD_3 = 0x28,
KEY_PAD_4 = 0x29,
KEY_PAD_5 = 0x2A,
KEY_PAD_6 = 0x2B,
KEY_PAD_7 = 0x2C,
KEY_PAD_8 = 0x2D,
KEY_PAD_9 = 0x2E,
KEY_PAD_DIVIDE = 0x2F,
KEY_PAD_MULTIPLY = 0x30,
KEY_PAD_MINUS = 0x31,
KEY_PAD_PLUS = 0x32,
KEY_PAD_ENTER = 0x33,
KEY_PAD_DECIMAL = 0x34,
KEY_LBRACKET = 0x35,
KEY_RBRACKET = 0x36,
KEY_SEMICOLON = 0x37,
KEY_APOSTROPHE = 0x38,
KEY_BACKQUOTE = 0x39,
KEY_COMMA = 0x3A,
KEY_PERIOD = 0x3B,
KEY_SLASH = 0x3C,
KEY_BACKSLASH = 0x3D,
KEY_MINUS = 0x3E,
KEY_EQUAL = 0x3F,
KEY_ENTER = 0x40,
KEY_SPACE = 0x41,
KEY_BACKSPACE = 0x42,
KEY_TAB = 0x43,
KEY_CAPSLOCK = 0x44,
KEY_NUMLOCK = 0x45,
KEY_ESCAPE = 0x46,
KEY_SCROLLLOCK = 0x47,
KEY_INSERT = 0x48,
KEY_DELETE = 0x49,
KEY_HOME = 0x4A,
KEY_END = 0x4B,
KEY_PAGEUP = 0x4C,
KEY_PAGEDOWN = 0x4D,
KEY_BREAK = 0x4E,
KEY_LSHIFT = 0x4F,
KEY_RSHIFT = 0x50,
KEY_LALT = 0x51,
KEY_RALT = 0x52,
KEY_LCONTROL = 0x53,
KEY_RCONTROL = 0x54,
KEY_LWIN = 0x55,
KEY_RWIN = 0x56,
KEY_APP = 0x57,
KEY_UP = 0x58,
KEY_LEFT = 0x59,
KEY_DOWN = 0x5A,
KEY_RIGHT = 0x5B,
KEY_F1 = 0x5C,
KEY_F2 = 0x5D,
KEY_F3 = 0x5E,
KEY_F4 = 0x5F,
KEY_F5 = 0x60,
KEY_F6 = 0x61,
KEY_F7 = 0x62,
KEY_F8 = 0x63,
KEY_F9 = 0x64,
KEY_F10 = 0x65,
KEY_F11 = 0x66,
KEY_F12 = 0x67,
KEY_CAPSLOCKTOGGLE = 0x68,
KEY_NUMLOCKTOGGLE = 0x69,
KEY_SCROLLLOCKTOGGLE = 0x6A,
MOUSE_LEFT = 0x6B,
MOUSE_RIGHT = 0x6C,
MOUSE_MIDDLE = 0x6D,
MOUSE_4 = 0x6E,
MOUSE_5 = 0x6F,
};
// this will only work if you're using ISurface (Source Engine)
enum font_flags {
ITALIC = 0x001,
UNDERLINE = 0x002,
STRIKEOUT = 0x004,
SYMBOL = 0x008,
ANTIALIAS = 0x010,
GAUSSIANBLUR = 0x020,
ROTARY = 0x040,
SHADOW = 0x080,
ADDITIVE = 0x100,
OUTLINE = 0x200,
CUSTOM = 0x400,
BITMAP = 0x800,
};
}
// public enums
enum struct cursor_type : int {
NONE = 0,
ARROW,
IBEAM,
HAND,
PIPETTE,
RESIZE,
MOVE
};
enum struct input_state : int {
LOCKED = 1,
UNLOCKED,
};
enum struct label_type : int {
TEXT = 1,
LINK,
BANNER,
SEPARATOR,
COLORED,
};
enum struct text_flags : int {
SECRET = (1 << 0),
UPPERCASE = (1 << 1),
NORMAL = (1 << 2)
};
enum struct animation_type : int {
LINEAR = 1,
FADE
};
// public structs
typedef struct element_area {
int left;
int top;
int right;
int bottom;
} rect;
typedef struct element_dimension {
int width;
int height;
} dimension;
typedef struct point_2d {
int x = 0;
int y = 0;
point_2d() = default;
point_2d(int _x, int _y) : x(_x), y(_y) {}
// operators
point_2d operator+(const point_2d& rhs) {
return point_2d(x + rhs.x, y + rhs.y);
}
point_2d operator-(const point_2d& rhs) {
return point_2d(x - rhs.x, y - rhs.y);
}
point_2d operator/(const int& rhs) {
return point_2d(x / rhs, y / rhs);
}
point_2d operator*(const int& rhs) {
return point_2d(x * rhs, y * rhs);
}
int& operator[](std::size_t index) {
return *reinterpret_cast<int*>(this + index);
}
} point;
typedef struct precision_point_2d {
float x = 0.f;
float y = 0.f;
precision_point_2d() = default;
precision_point_2d(float _x, float _y) : x(_x), y(_y) {}
// operators
precision_point_2d operator+(const point_2d& rhs) {
return precision_point_2d(x + rhs.x, y + rhs.y);
}
precision_point_2d operator-(const point_2d& rhs) {
return precision_point_2d(x - rhs.x, y - rhs.y);
}
precision_point_2d operator/(const int& rhs) {
return precision_point_2d(x / rhs, y / rhs);
}
precision_point_2d operator*(const int& rhs) {
return precision_point_2d(x * rhs, y * rhs);
}
float& operator[](std::size_t index) {
return *reinterpret_cast<float*>(this + index);
}
} precision_point;
typedef struct vertex_2d {
fgui::precision_point position = { 0.f, 0.f };
fgui::precision_point text_coord = { 0.f, 0.f };
vertex_2d() = default;
vertex_2d(const fgui::precision_point& _position, const fgui::precision_point& _text_coord = { 0.f, 0.f }) : position(_position), text_coord(_text_coord) {}
} vertex;
typedef struct element_font_info {
std::string_view family;
int size;
int flags;
bool bold;
} element_font;
}