comparison Applications/Generic/GuiAdapter.h @ 880:9953f16c304d am-dev

Merge
author Alain Mazy <alain@mazy.be>
date Fri, 05 Jul 2019 15:33:02 +0200
parents 12b591d5d63c f0bf971a1e31
children 401808e7ff2e
comparison
equal deleted inserted replaced
879:12b591d5d63c 880:9953f16c304d
73 GUIADAPTER_MOUSEBUTTON_MIDDLE = 1, 73 GUIADAPTER_MOUSEBUTTON_MIDDLE = 1,
74 GUIADAPTER_MOUSEBUTTON_RIGHT = 2 74 GUIADAPTER_MOUSEBUTTON_RIGHT = 2
75 }; 75 };
76 76
77 77
78 enum GuiAdapterMouseEventType 78 enum GuiAdapterHidEventType
79 { 79 {
80 GUIADAPTER_EVENT_MOUSEDOWN = 1973, 80 GUIADAPTER_EVENT_MOUSEDOWN = 1973,
81 GUIADAPTER_EVENT_MOUSEMOVE = 1974, 81 GUIADAPTER_EVENT_MOUSEMOVE = 1974,
82 GUIADAPTER_EVENT_MOUSEUP = 1975, 82 GUIADAPTER_EVENT_MOUSEUP = 1975,
83 GUIADAPTER_EVENT_WHEEL = 1976 83 GUIADAPTER_EVENT_WHEEL = 1976,
84 GUIADAPTER_EVENT_KEYDOWN = 1977,
85 GUIADAPTER_EVENT_KEYUP = 1978,
84 }; 86 };
85 87
86 const unsigned int GUIADAPTER_DELTA_PIXEL = 2973; 88 const unsigned int GUIADAPTER_DELTA_PIXEL = 2973;
87 const unsigned int GUIADAPTER_DELTA_LINE = 2974; 89 const unsigned int GUIADAPTER_DELTA_LINE = 2974;
88 const unsigned int GUIADAPTER_DELTA_PAGE = 2975; 90 const unsigned int GUIADAPTER_DELTA_PAGE = 2975;
122 typedef bool (*OnAnimationFrameFunc)(double time, void* userData); 124 typedef bool (*OnAnimationFrameFunc)(double time, void* userData);
123 typedef bool (*OnWindowResizeFunc)(int eventType, const GuiAdapterUiEvent* uiEvent, void* userData); 125 typedef bool (*OnWindowResizeFunc)(int eventType, const GuiAdapterUiEvent* uiEvent, void* userData);
124 #endif 126 #endif
125 127
126 #endif 128 #endif
127 struct GuiAdapterMouseEvent { 129 struct GuiAdapterMouseEvent
128 GuiAdapterMouseEventType type; 130 {
131 GuiAdapterHidEventType type;
129 //double timestamp; 132 //double timestamp;
130 //long screenX; 133 //long screenX;
131 //long screenY; 134 //long screenY;
132 //long clientX; 135 //long clientX;
133 //long clientY; 136 //long clientY;
166 struct GuiAdapterUiEvent {}; 169 struct GuiAdapterUiEvent {};
167 170
168 // EmscriptenKeyboardEvent 171 // EmscriptenKeyboardEvent
169 struct GuiAdapterKeyboardEvent 172 struct GuiAdapterKeyboardEvent
170 { 173 {
174 GuiAdapterHidEventType type;
175 char sym[32];
171 bool ctrlKey; 176 bool ctrlKey;
172 bool shiftKey; 177 bool shiftKey;
173 bool altKey; 178 bool altKey;
174 }; 179 };
175 180
191 7ms to 15ms 196 7ms to 15ms
192 197
193 FROM: https://codingrepo.com/javascript/2017/05/19/javascript-difference-mousedown-mouseup-click-events/ 198 FROM: https://codingrepo.com/javascript/2017/05/19/javascript-difference-mousedown-mouseup-click-events/
194 */ 199 */
195 #if ORTHANC_ENABLE_WASM == 1 200 #if ORTHANC_ENABLE_WASM == 1
196 void ConvertFromPlatform( 201 void ConvertFromPlatform(GuiAdapterUiEvent& dest, int eventType, const EmscriptenUiEvent& src);
197 GuiAdapterUiEvent& dest, 202
198 int eventType, 203 void ConvertFromPlatform(GuiAdapterMouseEvent& dest, int eventType, const EmscriptenMouseEvent& src);
199 const EmscriptenUiEvent& src);
200
201 void ConvertFromPlatform(
202 GuiAdapterMouseEvent& dest,
203 int eventType,
204 const EmscriptenMouseEvent& src);
205 204
206 void ConvertFromPlatform( 205 void ConvertFromPlatform(GuiAdapterWheelEvent& dest, int eventType, const EmscriptenWheelEvent& src);
207 GuiAdapterWheelEvent& dest, 206
208 int eventType, 207 void ConvertFromPlatform(GuiAdapterKeyboardEvent& dest, const EmscriptenKeyboardEvent& src);
209 const EmscriptenWheelEvent& src);
210
211 void ConvertFromPlatform(
212 GuiAdapterKeyboardEvent& dest,
213 const EmscriptenKeyboardEvent& src);
214
215 #else 208 #else
216 209
217 # if ORTHANC_ENABLE_SDL == 1 210 # if ORTHANC_ENABLE_SDL == 1
218 void ConvertFromPlatform( 211 void ConvertFromPlatform(GuiAdapterMouseEvent& dest, bool ctrlPressed, bool shiftPressed, bool altPressed, const SDL_Event& source);
219 GuiAdapterMouseEvent& dest, 212
220 bool ctrlPressed, bool shiftPressed, bool altPressed, 213 void ConvertFromPlatform(GuiAdapterWheelEvent& dest, bool ctrlPressed, bool shiftPressed, bool altPressed, const SDL_Event& source);
221 const SDL_Event& source); 214
222 215 void ConvertFromPlatform(GuiAdapterKeyboardEvent& dest, const SDL_Event& source);
223 void ConvertFromPlatform(
224 GuiAdapterWheelEvent& dest,
225 bool ctrlPressed, bool shiftPressed, bool altPressed,
226 const SDL_Event& source);
227 216
228 # endif 217 # endif
229 218
230 #endif 219 #endif
231 220
340 std::vector<EventHandlerData<OnWindowResizeFunc> > resizeHandlers_; 329 std::vector<EventHandlerData<OnWindowResizeFunc> > resizeHandlers_;
341 std::vector<EventHandlerData<OnMouseEventFunc > > mouseDownHandlers_; 330 std::vector<EventHandlerData<OnMouseEventFunc > > mouseDownHandlers_;
342 std::vector<EventHandlerData<OnMouseEventFunc > > mouseMoveHandlers_; 331 std::vector<EventHandlerData<OnMouseEventFunc > > mouseMoveHandlers_;
343 std::vector<EventHandlerData<OnMouseEventFunc > > mouseUpHandlers_; 332 std::vector<EventHandlerData<OnMouseEventFunc > > mouseUpHandlers_;
344 std::vector<EventHandlerData<OnMouseWheelFunc > > mouseWheelHandlers_; 333 std::vector<EventHandlerData<OnMouseWheelFunc > > mouseWheelHandlers_;
345 334 std::vector<EventHandlerData<OnKeyDownFunc > > keyDownHandlers_;
335 std::vector<EventHandlerData<OnKeyUpFunc > > keyUpHandlers_;
346 336
347 /** 337 /**
348 This executes all the registered headers if needed (in wasm, the browser 338 This executes all the registered headers if needed (in wasm, the browser
349 deals with this) 339 deals with this)
350 */ 340 */
351 void OnMouseEvent(uint32_t windowID, const GuiAdapterMouseEvent& event); 341 void OnMouseEvent(uint32_t windowID, const GuiAdapterMouseEvent& event);
352 342
343 void OnKeyboardEvent(uint32_t windowID, const GuiAdapterKeyboardEvent& event);
344
353 /** 345 /**
354 Same remark as OnMouseEvent 346 Same remark as OnMouseEvent
355 */ 347 */
356 void OnMouseWheelEvent(uint32_t windowID, const GuiAdapterWheelEvent& event); 348 void OnMouseWheelEvent(uint32_t windowID, const GuiAdapterWheelEvent& event);
357 349