GA::kit v0.3
G&A's in-house C++ application framework
Loading...
Searching...
No Matches
events.h
Go to the documentation of this file.
1#pragma once
2#include "ga/math.h"
3#include "ga/timer.h"
4
5namespace ga {
6
7struct Event
8{
10 : time( ga::Clock::now() )
11 , captured( false )
12 {
13 }
14
15 TimePoint time; // time when event occured
16 bool captured; // flag to stop event propagation
17};
18
19struct KeyEvent : public Event
20{
21 enum class Type
22 {
23 PRESS,
25 };
27 int key;
28};
29
30struct MouseEvent : public Event
31{
32 enum class Type
33 {
34 MOVE,
35 PRESS,
36 DRAG,
37 RELEASE,
38 SCROLL_UP, // wheel
40 };
43 int button; // LEFT = 0, RIGHT = 1, CENTER = 2, ...
44};
45
46struct TouchEvent : public Event
47{
48 enum class Type
49 {
50 PRESS,
51 DRAG,
52 RELEASE,
53 CANCEL
54 };
55
57 ga::vec2 position; // window space
58 ga::vec2 size;
59 float angle; // degrees 0-359
60 float pressure; // 0-1024
61
62 /*
63 ofTouchEventArgs:
64 -----------------
65 int id;
66 int time;
67 int numTouches;
68 float minoraxis, majoraxis;
69 float xspeed, yspeed;
70 float xaccel, yaccel;
71 */
72};
73
74} // namespace ga
Definition: color.h:9
std::chrono::time_point< Clock > TimePoint
Definition: timer.h:14
std::chrono::steady_clock Clock
Definition: timer.h:13
Definition: events.h:8
TimePoint time
Definition: events.h:15
Event()
Definition: events.h:9
bool captured
Definition: events.h:16
Definition: events.h:20
Type type
Definition: events.h:26
Type
Definition: events.h:22
int key
Definition: events.h:27
Definition: events.h:31
int button
Definition: events.h:43
vec2 position
Definition: events.h:42
Type type
Definition: events.h:41
Type
Definition: events.h:33
Definition: events.h:47
float angle
Definition: events.h:59
ga::vec2 size
Definition: events.h:58
Type
Definition: events.h:49
Type type
Definition: events.h:56
float pressure
Definition: events.h:60
ga::vec2 position
Definition: events.h:57