Iridescence 1.00
Embedded Graphic Framework
Loading...
Searching...
No Matches
ds_event.h
1/* Copyright (C) 2017 - 2024, Thornwave Labs Inc - All Rights Reserved.
2 * Unauthorized copying of this file, via any medium is strictly prohibited.
3 * Proprietary and confidential.
4 * Written by Razvan Turiac <razvan.turiac@thornwave.com>
5*/
6
7#ifndef _DS_EVENT_H
8#define _DS_EVENT_H
9
10
11#include <ds_types.h>
12#include <ds_geometry.h>
13
14
16{
17 DsRect region;
18};
19
20
25{
29 enum class Mode
30 {
31 ON,
32 OFF,
33 CONTACT,
34 ENTER,
35 EXIT
36 };
37
40 uint32_t timestamp;
41};
42
43
44struct DsEvent
45{
46 enum class Type
47 {
48 EXIT = 0,
49
50 PAINT = 1,
51 UPDATE = 2,
52 VSYNC = 3,
53
54 TOUCH = 4,
55 KEYBOARD = 5,
56
57 LAMBDA = 6,
58 };
59
60 union Params
61 {
62 Params(): cb()
63 {
64 }
65
66 ~Params()
67 {
68 }
69
70 DsPaintEvent paint;
71 DsTouchEvent touch;
72 int32_t key;
73
74 lambda<void(void), 64> cb;
75 };
76
77 Type type;
78 Params params;
79
80 DsEvent()
81 {
82 }
83
84 DsEvent(const DsEvent &rhs): type(rhs.type)
85 {
86 switch(type)
87 {
88 case Type::PAINT: params.paint = rhs.params.paint; break;
89 case Type::TOUCH: params.touch = rhs.params.touch; break;
90 case Type::KEYBOARD: params.key = rhs.params.key; break;
91 case Type::LAMBDA: params.cb = rhs.params.cb; break;
92
93 default: break;
94 }
95 }
96
97 DsEvent& operator=(const DsEvent &rhs)
98 {
99 type = rhs.type;
100
101 switch(type)
102 {
103 case Type::PAINT: params.paint = rhs.params.paint; break;
104 case Type::TOUCH: params.touch = rhs.params.touch; break;
105 case Type::KEYBOARD: params.key = rhs.params.key; break;
106 case Type::LAMBDA: params.cb = rhs.params.cb; break;
107
108 default: break;
109 }
110
111 return *this;
112 }
113};
114
115
116#endif
DsPoint is a class that represents the X and Y 2D coordinates of a point as integer numbers.
Definition ds_geometry.h:24
DsRect is a class that represents a 2D rectangle (X, Y, W, H)
Definition ds_geometry.h:1507
Definition ds_types_lambda.h:24
Definition ds_event.h:45
Definition ds_event.h:16
This structure implements a touch event.
Definition ds_event.h:25
uint32_t timestamp
Timestamp in ms.
Definition ds_event.h:40
Mode
Enumeration defining all touch modes.
Definition ds_event.h:30
@ ENTER
The user is dragging - touch point entered the view.
@ OFF
The user lifted it's finger from the screen.
@ ON
The user just touched the screen.
@ EXIT
The user is dragging - touch point exited the view.
@ CONTACT
The user is holding the finger on the screen (dragging)
Mode mode
Touch mode.
Definition ds_event.h:38
DsPoint pos
Position in the current view coodrinates.
Definition ds_event.h:39
Definition ds_event.h:61