• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 
7 #ifndef SAMPLE_UTIL_EVENT_H
8 #define SAMPLE_UTIL_EVENT_H
9 
10 #include "keyboard.h"
11 #include "mouse.h"
12 
13 class Event
14 {
15   public:
16     struct MoveEvent
17     {
18         int x;
19         int y;
20     };
21 
22     struct SizeEvent
23     {
24         int width;
25         int height;
26     };
27 
28     struct KeyEvent
29     {
30         Key code;
31         bool alt;
32         bool control;
33         bool shift;
34         bool system;
35     };
36 
37     struct MouseMoveEvent
38     {
39         int x;
40         int y;
41     };
42 
43     struct MouseButtonEvent
44     {
45         MouseButton button;
46         int x;
47         int y;
48     };
49 
50     struct MouseWheelEvent
51     {
52         int delta;
53     };
54 
55     enum EventType
56     {
57         EVENT_CLOSED,                // The window requested to be closed
58         EVENT_MOVED,                 // The window has moved
59         EVENT_RESIZED,               // The window was resized
60         EVENT_LOST_FOCUS,            // The window lost the focus
61         EVENT_GAINED_FOCUS,          // The window gained the focus
62         EVENT_TEXT_ENTERED,          // A character was entered
63         EVENT_KEY_PRESSED,           // A key was pressed
64         EVENT_KEY_RELEASED,          // A key was released
65         EVENT_MOUSE_WHEEL_MOVED,     // The mouse wheel was scrolled
66         EVENT_MOUSE_BUTTON_PRESSED,  // A mouse button was pressed
67         EVENT_MOUSE_BUTTON_RELEASED, // A mouse button was released
68         EVENT_MOUSE_MOVED,           // The mouse cursor moved
69         EVENT_MOUSE_ENTERED,         // The mouse cursor entered the area of the window
70         EVENT_MOUSE_LEFT,            // The mouse cursor left the area of the window
71         EVENT_TEST,                  // Event for testing purposes
72     };
73 
74     EventType type;
75 
76     union
77     {
78         MoveEvent               move;               // Move event parameters
79         SizeEvent               size;               // Size event parameters
80         KeyEvent                key;                // Key event parameters
81         MouseMoveEvent          mouseMove;          // Mouse move event parameters
82         MouseButtonEvent        mouseButton;        // Mouse button event parameters
83         MouseWheelEvent         mouseWheel;         // Mouse wheel event parameters
84     };
85 };
86 
87 #endif // SAMPLE_UTIL_EVENT_H
88