SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
SLEventHandler.h
Go to the documentation of this file.
1 /**
2  * \file sl/SLEventHandler.h
3  * \date July 2014
4  * \authors Marcus Hudritsch
5  * \copyright http://opensource.org/licenses/GPL-3.0
6  * \remarks Please use clangformat to format the code. See more code style on
7  * https://github.com/cpvrlab/SLProject4/wiki/SLProject-Coding-Style
8 */
9 
10 #ifndef SLEVENTHANDLER_H
11 #define SLEVENTHANDLER_H
12 
13 #include <SL.h>
14 #include <SLEnums.h>
15 
16 //-----------------------------------------------------------------------------
17 //! Virtual Eventhandler class
18 /*!
19 SLEventHandler provides virtual methods for basic mouse and keyboard events.
20 The SLNode class is derived from the SLEventhandler class and therefore all
21 nodes can act as a eventhandler. For the moment only the camera class handles
22 the events and implements this way the trackball camera.
23 The scene instance has a pointer to the active eventhandler and forwards the
24 events that it gets from the user interface.
25 See also: SLSceneView and SLCamera classes.
26 */
28 {
29 public:
31  {
32  // todo anim
33  _mouseRotationFactor = 0.1f;
34  _keyboardDeltaPos = 0.1f;
35  //_dRot = 15.0f;
36  }
37  virtual ~SLEventHandler() { ; }
38 
39  // Event handlers
40  virtual SLbool onMouseDown(const SLMouseButton button,
41  const SLint x,
42  const SLint y,
43  const SLKey mod)
44  {
45  (void)button;
46  (void)x;
47  (void)y;
48  return false;
49  }
50  virtual SLbool onMouseUp(const SLMouseButton button,
51  const SLint x,
52  const SLint y,
53  const SLKey mod)
54  {
55  (void)button;
56  (void)x;
57  (void)y;
58  (void)mod;
59  return false;
60  }
61  virtual SLbool onMouseMove(const SLMouseButton button,
62  const SLint x,
63  const SLint y,
64  const SLKey mod)
65  {
66  (void)button;
67  (void)x;
68  (void)y;
69  (void)mod;
70  return false;
71  }
72  virtual SLbool onDoubleClick(const SLMouseButton button,
73  const SLint x,
74  const SLint y,
75  const SLKey mod)
76  {
77  (void)button;
78  (void)x;
79  (void)y;
80  return false;
81  }
82  virtual SLbool onMouseWheel(const SLint delta, const SLKey mod)
83  {
84  (void)delta;
85  (void)mod;
86  return false;
87  }
88  virtual SLbool onTouch2Down(const SLint x1,
89  const SLint y1,
90  const SLint x2,
91  const SLint y2)
92  {
93  return false;
94  }
95  virtual SLbool onTouch2Move(const SLint x1,
96  const SLint y1,
97  const SLint x2,
98  const SLint y2)
99  {
100  return false;
101  }
102  virtual SLbool onTouch2Up(const SLint x1,
103  const SLint y1,
104  const SLint x2,
105  const SLint y2)
106  {
107  return false;
108  }
109  virtual SLbool onTouch3Down(const SLint x1,
110  const SLint y1)
111  {
112  return false;
113  }
114  virtual SLbool onTouch3Move(const SLint x1,
115  const SLint y1)
116  {
117  return false;
118  }
119  virtual SLbool onTouch3Up(const SLint x1,
120  const SLint y1)
121  {
122  return false;
123  }
124  virtual SLbool onKeyPress(const SLKey key,
125  const SLKey mod)
126  {
127  (void)key;
128  (void)mod;
129  return false;
130  }
131  virtual SLbool onKeyRelease(const SLKey key,
132  const SLKey mod)
133  {
134  (void)key;
135  (void)mod;
136  return false;
137  }
138  virtual SLbool onRotationPYR(const SLfloat pitchRAD,
139  const SLfloat yawRAD,
140  const SLfloat rollRAD)
141  {
142  return false;
143  }
144 
145  // Setters
147 
148  // Getters
150 
151 protected:
152  SLfloat _mouseRotationFactor; //!< Mouse rotation sensibility
153  SLfloat _keyboardDeltaPos; //!< Delta dist. for keyboard translation
154 };
155 //-----------------------------------------------------------------------------
156 // STL list container of SLEventHandler pointers
157 typedef vector<SLEventHandler*> SLVEventHandler;
158 //-----------------------------------------------------------------------------
159 #endif
float SLfloat
Definition: SL.h:173
bool SLbool
Definition: SL.h:175
int SLint
Definition: SL.h:170
SLMouseButton
Mouse button codes.
Definition: SLEnums.h:98
SLKey
Keyboard key codes enumeration.
Definition: SLEnums.h:16
vector< SLEventHandler * > SLVEventHandler
typedef void(SL_STDCALL *cbOnImGuiBuild)(SLScene *s
Callback function typedef for ImGui build function.
Virtual Eventhandler class.
virtual SLbool onTouch3Move(const SLint x1, const SLint y1)
virtual ~SLEventHandler()
virtual SLbool onKeyRelease(const SLKey key, const SLKey mod)
virtual SLbool onTouch3Up(const SLint x1, const SLint y1)
virtual SLbool onTouch2Up(const SLint x1, const SLint y1, const SLint x2, const SLint y2)
SLfloat _keyboardDeltaPos
Delta dist. for keyboard translation.
virtual SLbool onKeyPress(const SLKey key, const SLKey mod)
SLfloat _mouseRotationFactor
Mouse rotation sensibility.
virtual SLbool onMouseUp(const SLMouseButton button, const SLint x, const SLint y, const SLKey mod)
virtual SLbool onTouch3Down(const SLint x1, const SLint y1)
virtual SLbool onMouseMove(const SLMouseButton button, const SLint x, const SLint y, const SLKey mod)
virtual SLbool onRotationPYR(const SLfloat pitchRAD, const SLfloat yawRAD, const SLfloat rollRAD)
virtual SLbool onMouseDown(const SLMouseButton button, const SLint x, const SLint y, const SLKey mod)
virtual SLbool onDoubleClick(const SLMouseButton button, const SLint x, const SLint y, const SLKey mod)
virtual SLbool onTouch2Move(const SLint x1, const SLint y1, const SLint x2, const SLint y2)
virtual SLbool onTouch2Down(const SLint x1, const SLint y1, const SLint x2, const SLint y2)
virtual SLbool onMouseWheel(const SLint delta, const SLKey mod)
void mouseRotationFactor(SLfloat rf)
SLfloat mouseRotationFactor()
T mod(T a, T b)
Definition: Utils.h:250