initial commit
[ld42_outofspace] / src / goatkit / event.h
1 /*
2 GoatKit - a themable/animated widget toolkit for games
3 Copyright (C) 2014-2018  John Tsiombikas <nuclear@member.fsf.org>
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 */
18 #ifndef GOATKIT_EVENT_H_
19 #define GOATKIT_EVENT_H_
20
21 #include "vec.h"
22
23 namespace goatkit {
24
25 enum EventType {
26         // primary events
27         EV_MOUSE_BUTTON,
28         EV_MOUSE_MOTION,
29         EV_MOUSE_FOCUS,
30         EV_KEY,
31
32         // derived events
33         EV_CLICK,
34         EV_DOUBLE_CLICK,
35         EV_CHANGE,
36
37         NUM_EVENTS
38 };
39
40 enum SpecialKeys {
41         KEY_ESCAPE = 27,
42         KEY_DELETE = 127,
43
44         KEY_F1 = 256, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6,
45         KEY_F7, KEY_F8, KEY_F9, KEY_F10, KEY_F11, KEY_F12,
46         KEY_LEFT, KEY_RIGHT, KEY_UP, KEY_DOWN,
47         KEY_HOME, KEY_END, KEY_PGUP, KEY_PGDOWN,
48         KEY_INSERT
49 };
50
51 struct ButtonEvent {
52         Vec2 pos;
53         int button;
54         bool press;
55 };
56
57 struct MotionEvent {
58         Vec2 pos;
59 };
60
61 struct FocusEvent {
62         bool enter;
63 };
64
65 struct KeyEvent {
66         int key;
67         bool press;
68 };
69
70 struct Event {
71         EventType type;
72
73         ButtonEvent button;
74         MotionEvent motion;
75         FocusEvent focus;
76         KeyEvent key;
77 };
78
79 const char *event_type_name(EventType type);
80
81 }       // namespace goatkit
82
83 #endif  // GOATKIT_EVENT_H_