cgv
Loading...
Searching...
No Matches
event.h
1#pragma once
2
3#include <string>
4#include <iostream>
5
6#include "lib_begin.h"
7
9namespace cgv {
11 namespace gui {
12
27
30{
31 EF_NONE = 0,
33 EF_DND = 2,
34 EF_PAD = 4,
35 EF_VR = 8,
36 EF_NUI = 16,
37};
38
41{
43 EM_ALT = 2,
44 EM_CTRL = 4,
45 EM_META = 8
46};
47
55
58class CGV_API event
59{
60protected:
62 unsigned char kind;
64 unsigned char flags;
66 unsigned char modifiers;
68 unsigned char toggle_keys;
70 double time;
71public:
73 event(unsigned int _kind = EID_NONE, unsigned char _modifiers = 0, unsigned char _toggle_keys = 0, double _time = 0);
75 virtual ~event();
77 virtual void stream_out(std::ostream& os) const;
79 virtual void stream_in(std::istream& is);
81 virtual void* get_device_id() const;
83 void set_kind(unsigned char _kind);
85 unsigned get_kind() const;
88 void set_flags(unsigned char _flags);
90 unsigned get_flags() const;
92 void set_modifiers(unsigned char _modifiers);
94 unsigned char get_modifiers() const;
96 void set_toggle_keys(unsigned char _toggle_keys);
98 unsigned char get_toggle_keys() const;
100 void set_time(const double& _time);
102 double get_time() const;
103};
104
106extern CGV_API std::string get_modifier_string(EventModifier modifiers);
107
109extern CGV_API std::string get_toggle_keys_string(EventToggleKeys toggle_keys);
110
112extern CGV_API unsigned char stream_in_modifiers(std::istream& is);
113
115extern CGV_API void stream_in_toggle_keys(std::istream& is, unsigned char& toggle_keys);
116
118extern CGV_API unsigned char& ref_current_modifiers();
119
120 }
121}
122
123#include <cgv/config/lib_end.h>
unsigned char kind
store which kind of event we have
Definition event.h:62
unsigned char toggle_keys
store the active toggle keys
Definition event.h:68
unsigned char modifiers
store the active modifiers
Definition event.h:66
double time
store the time of the event in seconds
Definition event.h:70
unsigned char flags
store event flags
Definition event.h:64
unsigned char stream_in_modifiers(std::istream &is)
read modifiers in string format from a stream and set the passed reference to EventModifier s ored to...
Definition event.cxx:126
std::string get_modifier_string(EventModifier modifiers)
convert a modifier combination into a readable string ending on a '+' sign if not empty,...
Definition event.cxx:37
unsigned char & ref_current_modifiers()
read out the current modifiers
Definition event.cxx:252
EventToggleKeys
define constants for toggle keys
Definition event.h:50
@ ETK_NUM_LOCK
num lock
Definition event.h:52
@ ETK_SCROLL_LOCK
scroll lock
Definition event.h:53
@ ETK_CAPS_LOCK
caps lock
Definition event.h:51
EventModifier
define constants for event modifiers
Definition event.h:41
@ EM_SHIFT
shift modifier
Definition event.h:42
@ EM_ALT
alt modifier
Definition event.h:43
@ EM_META
meta modifier (windows or mac key)
Definition event.h:45
@ EM_CTRL
ctrl modifier
Definition event.h:44
EventId
define the ids of the most common events
Definition event.h:15
@ EID_NONE
undefined event id
Definition event.h:16
@ EID_POSE
id for a 6D pose change events
Definition event.h:21
@ EID_STICK
id of a stick event describing a two axis controller that optionally can be touched and pressed
Definition event.h:20
@ EID_KEY
id for key event
Definition event.h:17
@ EID_LIFETIME
id for nui life time
Definition event.h:25
@ EID_MOUSE
id for mouse event
Definition event.h:18
@ EID_ACTION
id for nui action events
Definition event.h:24
@ EID_CHOICE
id for focus or selection change events
Definition event.h:22
@ EID_THROTTLE
id of throttle event describing a one axis controller
Definition event.h:19
@ EID_APPROACH
id for nui approach events
Definition event.h:23
std::string get_toggle_keys_string(EventToggleKeys toggle_keys)
convert a toggle key combination into a readable string separated by '+' signs, i....
Definition event.cxx:47
EventFlags
flags
Definition event.h:30
@ EF_DND
whether mouse has a drag and drop target attached
Definition event.h:33
@ EF_MULTI
whether event is tagged with id of the device that generated the event
Definition event.h:32
@ EF_NUI
whether event is nature user interface event
Definition event.h:36
@ EF_VR
whether event is from VR kit
Definition event.h:35
@ EF_PAD
whether event is from gamepad
Definition event.h:34
the cgv namespace
Definition print.h:11