aboutsummaryrefslogtreecommitdiff
path: root/include/mglpp/window/Event.hpp
blob: c0732513c08444c1a5ad4829d87071b41e7df6de (plain)
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
#ifndef MGLPP_EVENT_HPP
#define MGLPP_EVENT_HPP

#include "Keyboard.hpp"
#include "Mouse.hpp"
#include <stdint.h>

/* These have to match the same structures in mgl event */

namespace mgl {
    class Event {
    public:
        struct SizeEvent {
            int width;
            int height;
        };

        struct KeyEvent {
            Keyboard::Key code;
            bool alt;
            bool control;
            bool shift;
            bool system;
        };

        struct MouseMoveEvent {
            int x; /* relative to left of the window */
            int y; /* relative to the top of the window */
        };

        struct MouseButtonEvent {
            Mouse::Button button;
            int x; /* relative to left of the window */
            int y; /* relative to top of the window */
        };

        enum Type : int {
            Unknown,
            Resized,
            KeyPressed,
            KeyReleased,
            MouseButtonPressed,
            MouseButtonReleased,
            MouseMoved
        };

        Type type;

        union {
            SizeEvent size;
            KeyEvent key;
            MouseButtonEvent mouse_button;
            MouseMoveEvent mouse_move;
        };
    };
}

#endif /* MGLPP_EVENT_HPP */