comparison Applications/Generic/GuiAdapter.h @ 861:f0bf971a1e31

Keyboard event routing (handling done in app)
author Benjamin Golinvaux <bgo@osimis.io>
date Mon, 24 Jun 2019 14:57:55 +0200
parents e3c56d4f863f
children 9953f16c304d
comparison
equal deleted inserted replaced
859:6845a05f9526 861:f0bf971a1e31
65 public: 65 public:
66 virtual ~IGuiAdapterWidget() {} 66 virtual ~IGuiAdapterWidget() {}
67 67
68 }; 68 };
69 69
70 enum GuiAdapterMouseEventType 70 enum GuiAdapterHidEventType
71 { 71 {
72 GUIADAPTER_EVENT_MOUSEDOWN = 1973, 72 GUIADAPTER_EVENT_MOUSEDOWN = 1973,
73 GUIADAPTER_EVENT_MOUSEMOVE = 1974, 73 GUIADAPTER_EVENT_MOUSEMOVE = 1974,
74 GUIADAPTER_EVENT_MOUSEUP = 1975, 74 GUIADAPTER_EVENT_MOUSEUP = 1975,
75 GUIADAPTER_EVENT_WHEEL = 1976 75 GUIADAPTER_EVENT_WHEEL = 1976,
76 GUIADAPTER_EVENT_KEYDOWN = 1977,
77 GUIADAPTER_EVENT_KEYUP = 1978,
76 }; 78 };
77 79
78 const unsigned int GUIADAPTER_DELTA_PIXEL = 2973; 80 const unsigned int GUIADAPTER_DELTA_PIXEL = 2973;
79 const unsigned int GUIADAPTER_DELTA_LINE = 2974; 81 const unsigned int GUIADAPTER_DELTA_LINE = 2974;
80 const unsigned int GUIADAPTER_DELTA_PAGE = 2975; 82 const unsigned int GUIADAPTER_DELTA_PAGE = 2975;
114 typedef bool (*OnAnimationFrameFunc)(double time, void* userData); 116 typedef bool (*OnAnimationFrameFunc)(double time, void* userData);
115 typedef bool (*OnWindowResizeFunc)(int eventType, const GuiAdapterUiEvent* uiEvent, void* userData); 117 typedef bool (*OnWindowResizeFunc)(int eventType, const GuiAdapterUiEvent* uiEvent, void* userData);
116 #endif 118 #endif
117 119
118 #endif 120 #endif
119 struct GuiAdapterMouseEvent { 121 struct GuiAdapterMouseEvent
120 GuiAdapterMouseEventType type; 122 {
123 GuiAdapterHidEventType type;
121 //double timestamp; 124 //double timestamp;
122 //long screenX; 125 //long screenX;
123 //long screenY; 126 //long screenY;
124 //long clientX; 127 //long clientX;
125 //long clientY; 128 //long clientY;
150 struct GuiAdapterUiEvent {}; 153 struct GuiAdapterUiEvent {};
151 154
152 // EmscriptenKeyboardEvent 155 // EmscriptenKeyboardEvent
153 struct GuiAdapterKeyboardEvent 156 struct GuiAdapterKeyboardEvent
154 { 157 {
158 GuiAdapterHidEventType type;
159 char sym[32];
155 bool ctrlKey; 160 bool ctrlKey;
156 bool shiftKey; 161 bool shiftKey;
157 bool altKey; 162 bool altKey;
158 }; 163 };
159 164
175 7ms to 15ms 180 7ms to 15ms
176 181
177 FROM: https://codingrepo.com/javascript/2017/05/19/javascript-difference-mousedown-mouseup-click-events/ 182 FROM: https://codingrepo.com/javascript/2017/05/19/javascript-difference-mousedown-mouseup-click-events/
178 */ 183 */
179 #if ORTHANC_ENABLE_WASM == 1 184 #if ORTHANC_ENABLE_WASM == 1
180 void ConvertFromPlatform( 185 void ConvertFromPlatform(GuiAdapterUiEvent& dest, int eventType, const EmscriptenUiEvent& src);
181 GuiAdapterUiEvent& dest, 186
182 int eventType, 187 void ConvertFromPlatform(GuiAdapterMouseEvent& dest, int eventType, const EmscriptenMouseEvent& src);
183 const EmscriptenUiEvent& src);
184
185 void ConvertFromPlatform(
186 GuiAdapterMouseEvent& dest,
187 int eventType,
188 const EmscriptenMouseEvent& src);
189 188
190 void ConvertFromPlatform( 189 void ConvertFromPlatform(GuiAdapterWheelEvent& dest, int eventType, const EmscriptenWheelEvent& src);
191 GuiAdapterWheelEvent& dest, 190
192 int eventType, 191 void ConvertFromPlatform(GuiAdapterKeyboardEvent& dest, const EmscriptenKeyboardEvent& src);
193 const EmscriptenWheelEvent& src);
194
195 void ConvertFromPlatform(
196 GuiAdapterKeyboardEvent& dest,
197 const EmscriptenKeyboardEvent& src);
198
199 #else 192 #else
200 193
201 # if ORTHANC_ENABLE_SDL == 1 194 # if ORTHANC_ENABLE_SDL == 1
202 void ConvertFromPlatform( 195 void ConvertFromPlatform(GuiAdapterMouseEvent& dest, bool ctrlPressed, bool shiftPressed, bool altPressed, const SDL_Event& source);
203 GuiAdapterMouseEvent& dest, 196
204 bool ctrlPressed, bool shiftPressed, bool altPressed, 197 void ConvertFromPlatform(GuiAdapterWheelEvent& dest, bool ctrlPressed, bool shiftPressed, bool altPressed, const SDL_Event& source);
205 const SDL_Event& source); 198
206 199 void ConvertFromPlatform(GuiAdapterKeyboardEvent& dest, const SDL_Event& source);
207 void ConvertFromPlatform(
208 GuiAdapterWheelEvent& dest,
209 bool ctrlPressed, bool shiftPressed, bool altPressed,
210 const SDL_Event& source);
211 200
212 # endif 201 # endif
213 202
214 #endif 203 #endif
215 204
324 std::vector<EventHandlerData<OnWindowResizeFunc> > resizeHandlers_; 313 std::vector<EventHandlerData<OnWindowResizeFunc> > resizeHandlers_;
325 std::vector<EventHandlerData<OnMouseEventFunc > > mouseDownHandlers_; 314 std::vector<EventHandlerData<OnMouseEventFunc > > mouseDownHandlers_;
326 std::vector<EventHandlerData<OnMouseEventFunc > > mouseMoveHandlers_; 315 std::vector<EventHandlerData<OnMouseEventFunc > > mouseMoveHandlers_;
327 std::vector<EventHandlerData<OnMouseEventFunc > > mouseUpHandlers_; 316 std::vector<EventHandlerData<OnMouseEventFunc > > mouseUpHandlers_;
328 std::vector<EventHandlerData<OnMouseWheelFunc > > mouseWheelHandlers_; 317 std::vector<EventHandlerData<OnMouseWheelFunc > > mouseWheelHandlers_;
329 318 std::vector<EventHandlerData<OnKeyDownFunc > > keyDownHandlers_;
319 std::vector<EventHandlerData<OnKeyUpFunc > > keyUpHandlers_;
330 320
331 /** 321 /**
332 This executes all the registered headers if needed (in wasm, the browser 322 This executes all the registered headers if needed (in wasm, the browser
333 deals with this) 323 deals with this)
334 */ 324 */
335 void OnMouseEvent(uint32_t windowID, const GuiAdapterMouseEvent& event); 325 void OnMouseEvent(uint32_t windowID, const GuiAdapterMouseEvent& event);
336 326
327 void OnKeyboardEvent(uint32_t windowID, const GuiAdapterKeyboardEvent& event);
328
337 /** 329 /**
338 Same remark as OnMouseEvent 330 Same remark as OnMouseEvent
339 */ 331 */
340 void OnMouseWheelEvent(uint32_t windowID, const GuiAdapterWheelEvent& event); 332 void OnMouseWheelEvent(uint32_t windowID, const GuiAdapterWheelEvent& event);
341 333