Mercurial > hg > orthanc-stone
annotate OrthancStone/Sources/Deprecated/GuiAdapter.cpp @ 1520:3a79d551dd8b
hgignore fixes
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Fri, 31 Jul 2020 12:51:41 +0200 |
parents | 244ad1e4e76a |
children |
rev | line source |
---|---|
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
1 /** |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
2 * Stone of Orthanc |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
1270
2d8ab34c8c91
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1020
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
6 * |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Affero General Public License |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
10 * the License, or (at your option) any later version. |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
11 * |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, but |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
15 * Affero General Public License for more details. |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
16 * |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Affero General Public License |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
19 **/ |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
20 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
21 #include "GuiAdapter.h" |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
22 |
853 | 23 #if ORTHANC_ENABLE_OPENGL == 1 |
1502
e5729dab3f67
moving Deprecated/Applications/Generic/GuiAdapter.[cpp|h] to Framework/Deprecated/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1475
diff
changeset
|
24 # include "../OpenGL/OpenGLIncludes.h" |
853 | 25 #endif |
26 | |
27 #if ORTHANC_ENABLE_SDL == 1 | |
28 # include <SDL_video.h> | |
29 # include <SDL_render.h> | |
30 # include <SDL.h> | |
31 #endif | |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
32 |
1475
615035c2f3ba
fix GuiAdapter.cpp, removed unused option ENABLE_STONE_DEPRECATED
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
33 #include <Compatibility.h> |
1298
8a0a62189f46
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1290
diff
changeset
|
34 |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
35 namespace OrthancStone |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
36 { |
879 | 37 std::ostream& operator<<( |
38 std::ostream& os, const GuiAdapterKeyboardEvent& event) | |
39 { | |
880 | 40 os << "sym: " << event.sym << " (" << (int)(event.sym[0]) << ") ctrl: " << event.ctrlKey << ", " << |
879 | 41 "shift: " << event.shiftKey << ", " << |
42 "alt: " << event.altKey; | |
43 return os; | |
44 } | |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
45 |
1371
f15529add7b0
operator << for GuiAdapterMouseEvent
Benjamin Golinvaux <bgo@osimis.io>
parents:
1370
diff
changeset
|
46 std::ostream& operator<<( |
f15529add7b0
operator << for GuiAdapterMouseEvent
Benjamin Golinvaux <bgo@osimis.io>
parents:
1370
diff
changeset
|
47 std::ostream& os, const GuiAdapterMouseEvent& event) |
f15529add7b0
operator << for GuiAdapterMouseEvent
Benjamin Golinvaux <bgo@osimis.io>
parents:
1370
diff
changeset
|
48 { |
f15529add7b0
operator << for GuiAdapterMouseEvent
Benjamin Golinvaux <bgo@osimis.io>
parents:
1370
diff
changeset
|
49 os << "targetX: " << event.targetX << " targetY: " << event.targetY << " button: " << event.button |
f15529add7b0
operator << for GuiAdapterMouseEvent
Benjamin Golinvaux <bgo@osimis.io>
parents:
1370
diff
changeset
|
50 << "ctrlKey: " << event.ctrlKey << "shiftKey: " << event.shiftKey << "altKey: " << event.altKey; |
f15529add7b0
operator << for GuiAdapterMouseEvent
Benjamin Golinvaux <bgo@osimis.io>
parents:
1370
diff
changeset
|
51 |
f15529add7b0
operator << for GuiAdapterMouseEvent
Benjamin Golinvaux <bgo@osimis.io>
parents:
1370
diff
changeset
|
52 return os; |
f15529add7b0
operator << for GuiAdapterMouseEvent
Benjamin Golinvaux <bgo@osimis.io>
parents:
1370
diff
changeset
|
53 } |
f15529add7b0
operator << for GuiAdapterMouseEvent
Benjamin Golinvaux <bgo@osimis.io>
parents:
1370
diff
changeset
|
54 |
1436
fb8c36073983
Fix problem where multiple init/exit were not possible when using GuiAdapter
Benjamin Golinvaux <bgo@osimis.io>
parents:
1435
diff
changeset
|
55 int GuiAdapter::s_instanceCount = 0; |
fb8c36073983
Fix problem where multiple init/exit were not possible when using GuiAdapter
Benjamin Golinvaux <bgo@osimis.io>
parents:
1435
diff
changeset
|
56 |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
57 #if ORTHANC_ENABLE_WASM == 1 |
937
86ac61a040c9
Added getters and notifications to allow clients of the loaders (DicomStructureSetLoader, OrthancSeriesVolumeProgressiveLoader and OrthancMultiframeVolumeLoader) to know when the loading is finished + added ability for SDL event loop to execute a callback repeatedly (used to check the view loading state)
Benjamin Golinvaux <bgo@osimis.io>
parents:
915
diff
changeset
|
58 void GuiAdapter::Run(GuiAdapterRunFunc /*func*/, void* /*cookie*/) |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
59 { |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
60 } |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
61 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
62 void ConvertFromPlatform( |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
63 GuiAdapterUiEvent& dest, |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
64 int eventType, |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
65 const EmscriptenUiEvent& src) |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
66 { |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
67 // no data for now |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
68 } |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
69 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
70 void ConvertFromPlatform( |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
71 GuiAdapterMouseEvent& dest, |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
72 int eventType, |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
73 const EmscriptenMouseEvent& src) |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
74 { |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
75 memset(&dest, 0, sizeof(GuiAdapterMouseEvent)); |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
76 switch (eventType) |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
77 { |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
78 case EMSCRIPTEN_EVENT_CLICK: |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
79 LOG(ERROR) << "Emscripten EMSCRIPTEN_EVENT_CLICK is not supported"; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
80 ORTHANC_ASSERT(false, "Not supported"); |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
81 break; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
82 case EMSCRIPTEN_EVENT_MOUSEDOWN: |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
83 dest.type = GUIADAPTER_EVENT_MOUSEDOWN; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
84 break; |
1020
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
85 case EMSCRIPTEN_EVENT_DBLCLICK: |
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
86 dest.type = GUIADAPTER_EVENT_MOUSEDBLCLICK; |
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
87 break; |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
88 case EMSCRIPTEN_EVENT_MOUSEMOVE: |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
89 dest.type = GUIADAPTER_EVENT_MOUSEMOVE; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
90 break; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
91 case EMSCRIPTEN_EVENT_MOUSEUP: |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
92 dest.type = GUIADAPTER_EVENT_MOUSEUP; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
93 break; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
94 case EMSCRIPTEN_EVENT_WHEEL: |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
95 dest.type = GUIADAPTER_EVENT_WHEEL; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
96 break; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
97 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
98 default: |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
99 LOG(ERROR) << "Emscripten event: " << eventType << " is not supported"; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
100 ORTHANC_ASSERT(false, "Not supported"); |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
101 } |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
102 //dest.timestamp = src.timestamp; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
103 //dest.screenX = src.screenX; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
104 //dest.screenY = src.screenY; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
105 //dest.clientX = src.clientX; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
106 //dest.clientY = src.clientY; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
107 dest.ctrlKey = src.ctrlKey; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
108 dest.shiftKey = src.shiftKey; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
109 dest.altKey = src.altKey; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
110 //dest.metaKey = src.metaKey; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
111 dest.button = src.button; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
112 //dest.buttons = src.buttons; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
113 //dest.movementX = src.movementX; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
114 //dest.movementY = src.movementY; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
115 dest.targetX = src.targetX; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
116 dest.targetY = src.targetY; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
117 //dest.canvasX = src.canvasX; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
118 //dest.canvasY = src.canvasY; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
119 //dest.padding = src.padding; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
120 } |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
121 |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
122 void ConvertFromPlatform( GuiAdapterWheelEvent& dest, int eventType, const EmscriptenWheelEvent& src) |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
123 { |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
124 ConvertFromPlatform(dest.mouse, eventType, src.mouse); |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
125 dest.deltaX = src.deltaX; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
126 dest.deltaY = src.deltaY; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
127 switch (src.deltaMode) |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
128 { |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
129 case DOM_DELTA_PIXEL: |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
130 dest.deltaMode = GUIADAPTER_DELTA_PIXEL; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
131 break; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
132 case DOM_DELTA_LINE: |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
133 dest.deltaMode = GUIADAPTER_DELTA_LINE; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
134 break; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
135 case DOM_DELTA_PAGE: |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
136 dest.deltaMode = GUIADAPTER_DELTA_PAGE; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
137 break; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
138 default: |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
139 ORTHANC_ASSERT(false, "Unknown deltaMode: " << src.deltaMode << |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
140 " in wheel event..."); |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
141 } |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
142 dest.deltaMode = src.deltaMode; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
143 } |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
144 |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
145 void ConvertFromPlatform(GuiAdapterKeyboardEvent& dest, const EmscriptenKeyboardEvent& src) |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
146 { |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
147 dest.sym[0] = src.key[0]; |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
148 dest.sym[1] = 0; |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
149 dest.ctrlKey = src.ctrlKey; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
150 dest.shiftKey = src.shiftKey; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
151 dest.altKey = src.altKey; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
152 } |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
153 |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
154 template<typename GenericFunc> |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
155 struct FuncAdapterPayload |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
156 { |
1370
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
157 std::string canvasCssSelector; |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
158 void* userData; |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
159 GenericFunc callback; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
160 }; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
161 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
162 template<typename GenericFunc, |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
163 typename GuiAdapterEvent, |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
164 typename EmscriptenEvent> |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
165 EM_BOOL OnEventAdapterFunc( |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
166 int eventType, const EmscriptenEvent* emEvent, void* userData) |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
167 { |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
168 // userData is OnMouseWheelFuncAdapterPayload |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
169 FuncAdapterPayload<GenericFunc>* payload = |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
170 reinterpret_cast<FuncAdapterPayload<GenericFunc>*>(userData); |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
171 // LOG(INFO) << "OnEventAdapterFunc"; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
172 // LOG(INFO) << "------------------"; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
173 // LOG(INFO) << "eventType: " << eventType << " wheelEvent: " << |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
174 // (int)wheelEvent << " userData: " << userData << |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
175 // " payload->userData: " << payload->userData; |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
176 |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
177 GuiAdapterEvent guiEvent; |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
178 ConvertFromPlatform(guiEvent, eventType, *emEvent); |
1370
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
179 bool ret = (*(payload->callback))(payload->canvasCssSelector, &guiEvent, payload->userData); |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
180 return static_cast<EM_BOOL>(ret); |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
181 } |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
182 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
183 template<typename GenericFunc, |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
184 typename GuiAdapterEvent, |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
185 typename EmscriptenEvent> |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
186 EM_BOOL OnEventAdapterFunc2( |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
187 int /*eventType*/, const EmscriptenEvent* wheelEvent, void* userData) |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
188 { |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
189 // userData is OnMouseWheelFuncAdapterPayload |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
190 FuncAdapterPayload<GenericFunc>* payload = |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
191 reinterpret_cast<FuncAdapterPayload<GenericFunc>*>(userData); |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
192 |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
193 GuiAdapterEvent guiEvent; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
194 ConvertFromPlatform(guiEvent, *wheelEvent); |
1370
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
195 bool ret = (*(payload->callback))(payload->canvasCssSelector, &guiEvent, payload->userData); |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
196 return static_cast<EM_BOOL>(ret); |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
197 } |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
198 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
199 template<typename GenericFunc> |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
200 EM_BOOL OnEventAdapterFunc3( |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
201 double time, void* userData) |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
202 { |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
203 // userData is OnMouseWheelFuncAdapterPayload |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
204 FuncAdapterPayload<GenericFunc>* payload = |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
205 reinterpret_cast<FuncAdapterPayload<GenericFunc>*>(userData); |
1298
8a0a62189f46
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1290
diff
changeset
|
206 //std::unique_ptr< FuncAdapterPayload<GenericFunc> > deleter(payload); |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
207 bool ret = (*(payload->callback))(time, payload->userData); |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
208 return static_cast<EM_BOOL>(ret); |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
209 } |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
210 |
1370
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
211 /* |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
212 |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
213 Explanation |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
214 =========== |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
215 |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
216 - in "older" Emscripten, where DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR doesn't exist or is set to 0, |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
217 the following strings need to be used to register events: |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
218 - for canvas, the canvas DOM id. In case of <canvas id="mycanvas1" width='640' ...></canvas>", the string needs |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
219 to be "mycanvas" |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
220 - for the window (for key events), the string needs to be "#window" |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
221 - in newer Emscripten where DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR==1 (or maybe is not there anymore, in the |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
222 future as of 2020-04-20) |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
223 - for canvas, the canvas DOM id. In case of <canvas id="mycanvas1" width='640' ...></canvas>", the string needs |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
224 to be "#mycanvas" (notice the "number sign", aka "hash", NOT AKA "sharp", as can be read on https://en.wikipedia.org/wiki/Number_sign) |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
225 - for the window (for key events), the string needs to be EMSCRIPTEN_EVENT_TARGET_WINDOW. I do not mean |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
226 "EMSCRIPTEN_EVENT_TARGET_WINDOW", but the #define EMSCRIPTEN_EVENT_TARGET_WINDOW ((const char*)2) that |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
227 can be found in emscripten/html5.h |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
228 |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
229 The code below converts the input canvasId (as in the old emscripten) to the emscripten-compliant one, with the |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
230 following compile condition : #if DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR == 1 |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
231 |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
232 If the DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR build parameter disappears, you might want to refactor this code |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
233 or continue to pass the DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR compile macro (which is different from the CMake |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
234 variable) |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
235 |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
236 What we are doing below: |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
237 - in older Emscripten, the registration functions will receive "mycanvas" and "#window" and the callbacks will receive |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
238 the same std::string in their payload ("mycanvas" and "#window") |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
239 |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
240 - in newer Emscripten, the registration functions will receive "#mycanvas" and EMSCRIPTEN_EVENT_TARGET_WINDOW, but |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
241 the callbacks will receive "#mycanvas" and "#window" (since it is not possible to store the EMSCRIPTEN_EVENT_TARGET_WINDOW |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
242 magic value in an std::string, while we still want the callback to be able to change its behavior according to the |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
243 target element. |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
244 |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
245 */ |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
246 |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
247 void convertElementTarget(const char*& outCanvasCssSelectorSz, std::string& outCanvasCssSelector, const std::string& canvasId) |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
248 { |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
249 // only "#window" can start with a # |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
250 if (canvasId[0] == '#') |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
251 { |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
252 ORTHANC_ASSERT(canvasId == "#window"); |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
253 } |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
254 #if DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR == 1 |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
255 if (canvasId == "#window") |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
256 { |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
257 // we store this in the payload so that the callback can |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
258 outCanvasCssSelector = "#window"; |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
259 outCanvasCssSelectorSz = EMSCRIPTEN_EVENT_TARGET_WINDOW; |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
260 } |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
261 else |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
262 { |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
263 outCanvasCssSelector = "#" + canvasId; |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
264 outCanvasCssSelectorSz = outCanvasCssSelector.c_str(); |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
265 } |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
266 #else |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
267 if (canvasId == "#window") |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
268 { |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
269 // we store this in the payload so that the callback can |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
270 outCanvasCssSelector = "#window"; |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
271 outCanvasCssSelectorSz = outCanvasCssSelector.c_str();; |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
272 } |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
273 else |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
274 { |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
275 outCanvasCssSelector = canvasId; |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
276 outCanvasCssSelectorSz = outCanvasCssSelector.c_str();; |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
277 } |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
278 #endif |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
279 } |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
280 |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
281 // resize: (const char* target, void* userData, EM_BOOL useCapture, em_ui_callback_func callback) |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
282 template< |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
283 typename GenericFunc, |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
284 typename GuiAdapterEvent, |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
285 typename EmscriptenEvent, |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
286 typename EmscriptenSetCallbackFunc> |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
287 static void SetCallback( |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
288 EmscriptenSetCallbackFunc emFunc, |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
289 std::string canvasId, void* userData, bool capture, GenericFunc func) |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
290 { |
1370
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
291 std::string canvasCssSelector; |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
292 const char* canvasCssSelectorSz = NULL; |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
293 convertElementTarget(canvasCssSelectorSz, canvasCssSelector, canvasId); |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
294 |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
295 // TODO: write RemoveCallback with an int id that gets returned from here |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
296 |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
297 // create userdata payload |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
298 std::unique_ptr<FuncAdapterPayload<GenericFunc> > payload(new FuncAdapterPayload<GenericFunc>()); |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
299 payload->canvasCssSelector = canvasCssSelector; |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
300 payload->callback = func; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
301 payload->userData = userData; |
1370
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
302 void* userDataRaw = reinterpret_cast<void*>(payload.release()); |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
303 |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
304 // call the registration function |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
305 (*emFunc)( |
1370
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
306 canvasCssSelectorSz, |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
307 userDataRaw, |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
308 static_cast<EM_BOOL>(capture), |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
309 &OnEventAdapterFunc<GenericFunc, GuiAdapterEvent, EmscriptenEvent>, |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
310 EM_CALLBACK_THREAD_CONTEXT_CALLING_THREAD); |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
311 } |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
312 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
313 template< |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
314 typename GenericFunc, |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
315 typename GuiAdapterEvent, |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
316 typename EmscriptenEvent, |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
317 typename EmscriptenSetCallbackFunc> |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
318 static void SetCallback2( |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
319 EmscriptenSetCallbackFunc emFunc, |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
320 std::string canvasId, void* userData, bool capture, GenericFunc func) |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
321 { |
1370
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
322 std::string canvasCssSelector; |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
323 const char* canvasCssSelectorSz = NULL; |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
324 convertElementTarget(canvasCssSelectorSz, canvasCssSelector, canvasId); |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
325 |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
326 // TODO: write RemoveCallback with an int id that gets returned from here |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
327 |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
328 // create userdata payload |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
329 std::unique_ptr<FuncAdapterPayload<GenericFunc> > payload(new FuncAdapterPayload<GenericFunc>()); |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
330 payload->canvasCssSelector = canvasCssSelector; |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
331 payload->callback = func; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
332 payload->userData = userData; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
333 void* userDataRaw = reinterpret_cast<void*>(payload.release()); |
1370
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
334 |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
335 // call the registration function |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
336 (*emFunc)( |
1370
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
337 canvasCssSelectorSz, |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
338 userDataRaw, |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
339 static_cast<EM_BOOL>(capture), |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
340 &OnEventAdapterFunc2<GenericFunc, GuiAdapterEvent, EmscriptenEvent>, |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
341 EM_CALLBACK_THREAD_CONTEXT_CALLING_THREAD); |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
342 } |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
343 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
344 template< |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
345 typename GenericFunc, |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
346 typename EmscriptenSetCallbackFunc> |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
347 static void SetAnimationFrameCallback( |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
348 EmscriptenSetCallbackFunc emFunc, |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
349 void* userData, GenericFunc func) |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
350 { |
1298
8a0a62189f46
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1290
diff
changeset
|
351 std::unique_ptr<FuncAdapterPayload<GenericFunc> > payload( |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
352 new FuncAdapterPayload<GenericFunc>() |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
353 ); |
1370
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1341
diff
changeset
|
354 payload->canvasCssSelector = "UNDEFINED"; |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
355 payload->callback = func; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
356 payload->userData = userData; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
357 void* userDataRaw = reinterpret_cast<void*>(payload.release()); |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
358 (*emFunc)( |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
359 &OnEventAdapterFunc3<GenericFunc>, |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
360 userDataRaw); |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
361 } |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
362 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
363 void GuiAdapter::SetWheelCallback( |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
364 std::string canvasId, void* userData, bool capture, OnMouseWheelFunc func) |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
365 { |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
366 SetCallback<OnMouseWheelFunc, GuiAdapterWheelEvent, EmscriptenWheelEvent>( |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
367 &emscripten_set_wheel_callback_on_thread, |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
368 canvasId, |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
369 userData, |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
370 capture, |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
371 func); |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
372 } |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
373 |
1020
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
374 |
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
375 void GuiAdapter::SetMouseDblClickCallback( |
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
376 std::string canvasId, void* userData, bool capture, OnMouseEventFunc func) |
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
377 { |
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
378 SetCallback<OnMouseEventFunc, GuiAdapterMouseEvent, EmscriptenMouseEvent>( |
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
379 &emscripten_set_dblclick_callback_on_thread, |
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
380 canvasId, |
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
381 userData, |
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
382 capture, |
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
383 func); |
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
384 } |
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
385 |
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
386 |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
387 void GuiAdapter::SetMouseDownCallback( |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
388 std::string canvasId, void* userData, bool capture, OnMouseEventFunc func) |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
389 { |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
390 SetCallback<OnMouseEventFunc, GuiAdapterMouseEvent, EmscriptenMouseEvent>( |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
391 &emscripten_set_mousedown_callback_on_thread, |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
392 canvasId, |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
393 userData, |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
394 capture, |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
395 func); |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
396 } |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
397 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
398 void GuiAdapter::SetMouseMoveCallback( |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
399 std::string canvasId, void* userData, bool capture, OnMouseEventFunc func) |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
400 { |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
401 // LOG(INFO) << "SetMouseMoveCallback -- " << "supplied userData: " << |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
402 // userData; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
403 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
404 SetCallback<OnMouseEventFunc, GuiAdapterMouseEvent, EmscriptenMouseEvent>( |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
405 &emscripten_set_mousemove_callback_on_thread, |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
406 canvasId, |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
407 userData, |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
408 capture, |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
409 func); |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
410 } |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
411 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
412 void GuiAdapter::SetMouseUpCallback( |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
413 std::string canvasId, void* userData, bool capture, OnMouseEventFunc func) |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
414 { |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
415 SetCallback<OnMouseEventFunc, GuiAdapterMouseEvent, EmscriptenMouseEvent>( |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
416 &emscripten_set_mouseup_callback_on_thread, |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
417 canvasId, |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
418 userData, |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
419 capture, |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
420 func); |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
421 } |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
422 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
423 void GuiAdapter::SetKeyDownCallback( |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
424 std::string canvasId, void* userData, bool capture, OnKeyDownFunc func) |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
425 { |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
426 SetCallback2<OnKeyDownFunc, GuiAdapterKeyboardEvent, EmscriptenKeyboardEvent>( |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
427 &emscripten_set_keydown_callback_on_thread, |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
428 canvasId, |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
429 userData, |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
430 capture, |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
431 func); |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
432 } |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
433 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
434 void GuiAdapter::SetKeyUpCallback( |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
435 std::string canvasId, void* userData, bool capture, OnKeyUpFunc func) |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
436 { |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
437 SetCallback2<OnKeyUpFunc, GuiAdapterKeyboardEvent, EmscriptenKeyboardEvent>( |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
438 &emscripten_set_keyup_callback_on_thread, |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
439 canvasId, |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
440 userData, |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
441 capture, |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
442 func); |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
443 } |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
444 |
1312
4f8c9065ee52
coping with both viewport and loader changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
445 #if 0 |
4f8c9065ee52
coping with both viewport and loader changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
446 // useless under Wasm where canvas resize is handled automatically |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
447 void GuiAdapter::SetResizeCallback( |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
448 std::string canvasId, void* userData, bool capture, OnWindowResizeFunc func) |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
449 { |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
450 SetCallback<OnWindowResizeFunc, GuiAdapterUiEvent, EmscriptenUiEvent>( |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
451 &emscripten_set_resize_callback_on_thread, |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
452 canvasId, |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
453 userData, |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
454 capture, |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
455 func); |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
456 } |
1312
4f8c9065ee52
coping with both viewport and loader changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
457 #endif |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
458 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
459 void GuiAdapter::RequestAnimationFrame( |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
460 OnAnimationFrameFunc func, void* userData) |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
461 { |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
462 SetAnimationFrameCallback<OnAnimationFrameFunc>( |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
463 &emscripten_request_animation_frame_loop, |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
464 userData, |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
465 func); |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
466 } |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
467 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
468 #if 0 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
469 void GuiAdapter::SetKeyDownCallback( |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
470 std::string canvasId, void* userData, bool capture, OnKeyDownFunc func) |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
471 { |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
472 emscripten_set_keydown_callback(canvasId.c_str(), userData, static_cast<EM_BOOL>(capture), func); |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
473 } |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
474 void GuiAdapter::SetKeyUpCallback( |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
475 std::string canvasId, void* userData, bool capture, OnKeyUpFunc func) |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
476 { |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
477 emscripten_set_keyup_callback(canvasId.c_str(), userData, static_cast<EM_BOOL>(capture), func); |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
478 } |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
479 |
1312
4f8c9065ee52
coping with both viewport and loader changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
480 // handled from within WebAssemblyViewport |
4f8c9065ee52
coping with both viewport and loader changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
481 //void GuiAdapter::SetResizeCallback(std::string canvasId, void* userData, bool capture, OnWindowResizeFunc func) |
4f8c9065ee52
coping with both viewport and loader changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
482 //{ |
4f8c9065ee52
coping with both viewport and loader changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
483 // emscripten_set_resize_callback(canvasId.c_str(), userData, static_cast<EM_BOOL>(capture), func); |
4f8c9065ee52
coping with both viewport and loader changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
484 //} |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
485 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
486 void GuiAdapter::RequestAnimationFrame(OnAnimationFrameFunc func, void* userData) |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
487 { |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
488 emscripten_request_animation_frame_loop(func, userData); |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
489 } |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
490 #endif |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
491 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
492 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
493 #else |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
494 |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
495 // SDL ONLY |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
496 void ConvertFromPlatform(GuiAdapterMouseEvent& dest, bool ctrlPressed, bool shiftPressed, bool altPressed, const SDL_Event& source) |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
497 { |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
498 memset(&dest, 0, sizeof(GuiAdapterMouseEvent)); |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
499 switch (source.type) |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
500 { |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
501 case SDL_MOUSEBUTTONDOWN: |
1020
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
502 if (source.button.clicks == 1) { |
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
503 dest.type = GUIADAPTER_EVENT_MOUSEDOWN; |
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
504 } else if (source.button.clicks == 2) { |
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
505 dest.type = GUIADAPTER_EVENT_MOUSEDBLCLICK; |
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
506 } else { |
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
507 dest.type = GUIADAPTER_EVENT_MOUSEDBLCLICK; |
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
508 LOG(WARNING) << "Multiple-click ignored."; |
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
509 } |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
510 break; |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
511 case SDL_MOUSEMOTION: |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
512 dest.type = GUIADAPTER_EVENT_MOUSEMOVE; |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
513 break; |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
514 case SDL_MOUSEBUTTONUP: |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
515 dest.type = GUIADAPTER_EVENT_MOUSEUP; |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
516 break; |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
517 case SDL_MOUSEWHEEL: |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
518 dest.type = GUIADAPTER_EVENT_WHEEL; |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
519 break; |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
520 default: |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
521 LOG(ERROR) << "SDL event: " << source.type << " is not supported"; |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
522 ORTHANC_ASSERT(false, "Not supported"); |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
523 } |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
524 //dest.timestamp = src.timestamp; |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
525 //dest.screenX = src.screenX; |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
526 //dest.screenY = src.screenY; |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
527 //dest.clientX = src.clientX; |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
528 //dest.clientY = src.clientY; |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
529 dest.ctrlKey = ctrlPressed; |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
530 dest.shiftKey = shiftPressed; |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
531 dest.altKey = altPressed; |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
532 //dest.metaKey = src.metaKey; |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
533 switch (source.button.button) |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
534 { |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
535 case SDL_BUTTON_MIDDLE: |
880 | 536 dest.button =GUIADAPTER_MOUSEBUTTON_MIDDLE; |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
537 break; |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
538 |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
539 case SDL_BUTTON_RIGHT: |
880 | 540 dest.button = GUIADAPTER_MOUSEBUTTON_RIGHT; |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
541 break; |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
542 |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
543 case SDL_BUTTON_LEFT: |
880 | 544 dest.button = GUIADAPTER_MOUSEBUTTON_LEFT; |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
545 break; |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
546 |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
547 default: |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
548 break; |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
549 } |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
550 //dest.buttons = src.buttons; |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
551 //dest.movementX = src.movementX; |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
552 //dest.movementY = src.movementY; |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
553 dest.targetX = source.button.x; |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
554 dest.targetY = source.button.y; |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
555 //dest.canvasX = src.canvasX; |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
556 //dest.canvasY = src.canvasY; |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
557 //dest.padding = src.padding; |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
558 } |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
559 |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
560 void ConvertFromPlatform( |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
561 GuiAdapterWheelEvent& dest, |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
562 bool ctrlPressed, bool shiftPressed, bool altPressed, |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
563 const SDL_Event& source) |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
564 { |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
565 ConvertFromPlatform(dest.mouse, ctrlPressed, shiftPressed, altPressed, source); |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
566 dest.deltaX = source.wheel.x; |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
567 dest.deltaY = source.wheel.y; |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
568 } |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
569 |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
570 void ConvertFromPlatform(GuiAdapterKeyboardEvent& dest, const SDL_Event& src) |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
571 { |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
572 memset(&dest, 0, sizeof(GuiAdapterMouseEvent)); |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
573 switch (src.type) |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
574 { |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
575 case SDL_KEYDOWN: |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
576 dest.type = GUIADAPTER_EVENT_KEYDOWN; |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
577 break; |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
578 case SDL_KEYUP: |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
579 dest.type = GUIADAPTER_EVENT_KEYUP; |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
580 break; |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
581 default: |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
582 LOG(ERROR) << "SDL event: " << src.type << " is not supported"; |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
583 ORTHANC_ASSERT(false, "Not supported"); |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
584 } |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
585 dest.sym[0] = src.key.keysym.sym; |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
586 dest.sym[1] = 0; |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
587 |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
588 if (src.key.keysym.mod & KMOD_CTRL) |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
589 dest.ctrlKey = true; |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
590 else |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
591 dest.ctrlKey = false; |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
592 |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
593 if (src.key.keysym.mod & KMOD_SHIFT) |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
594 dest.shiftKey = true; |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
595 else |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
596 dest.shiftKey = false; |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
597 |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
598 if (src.key.keysym.mod & KMOD_ALT) |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
599 dest.altKey = true; |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
600 else |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
601 dest.altKey = false; |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
602 } |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
603 |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
604 // SDL ONLY |
1312
4f8c9065ee52
coping with both viewport and loader changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
605 void GuiAdapter::SetSdlResizeCallback( |
4f8c9065ee52
coping with both viewport and loader changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
606 std::string canvasId, void* userData, bool capture, OnSdlWindowResizeFunc func) |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
607 { |
1312
4f8c9065ee52
coping with both viewport and loader changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
608 resizeHandlers_.push_back(EventHandlerData<OnSdlWindowResizeFunc>(canvasId, func, userData)); |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
609 } |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
610 |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
611 // SDL ONLY |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
612 void GuiAdapter::SetMouseDownCallback( |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
613 std::string canvasId, void* userData, bool capture, OnMouseEventFunc func) |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
614 { |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
615 mouseDownHandlers_.push_back(EventHandlerData<OnMouseEventFunc>(canvasId, func, userData)); |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
616 } |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
617 |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
618 // SDL ONLY |
1020
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
619 void GuiAdapter::SetMouseDblClickCallback( |
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
620 std::string canvasId, void* userData, bool capture, OnMouseEventFunc func) |
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
621 { |
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
622 mouseDblCickHandlers_.push_back(EventHandlerData<OnMouseEventFunc>(canvasId, func, userData)); |
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
623 } |
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
624 |
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
625 // SDL ONLY |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
626 void GuiAdapter::SetMouseMoveCallback( |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
627 std::string canvasId, void* userData, bool capture, OnMouseEventFunc func) |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
628 { |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
629 mouseMoveHandlers_.push_back(EventHandlerData<OnMouseEventFunc>(canvasId, func, userData)); |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
630 } |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
631 |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
632 // SDL ONLY |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
633 void GuiAdapter::SetMouseUpCallback( |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
634 std::string canvasId, void* userData, bool capture, OnMouseEventFunc func) |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
635 { |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
636 mouseUpHandlers_.push_back(EventHandlerData<OnMouseEventFunc>(canvasId, func, userData)); |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
637 } |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
638 |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
639 // SDL ONLY |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
640 void GuiAdapter::SetWheelCallback( |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
641 std::string canvasId, void* userData, bool capture, OnMouseWheelFunc func) |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
642 { |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
643 mouseWheelHandlers_.push_back(EventHandlerData<OnMouseWheelFunc>(canvasId, func, userData)); |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
644 } |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
645 |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
646 // SDL ONLY |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
647 void GuiAdapter::SetKeyDownCallback( |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
648 std::string canvasId, void* userData, bool capture, OnKeyDownFunc func) |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
649 { |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
650 keyDownHandlers_.push_back(EventHandlerData<OnKeyDownFunc>(canvasId, func, userData)); |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
651 } |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
652 |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
653 // SDL ONLY |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
654 void GuiAdapter::SetKeyUpCallback( |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
655 std::string canvasId, void* userData, bool capture, OnKeyUpFunc func) |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
656 { |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
657 keyUpHandlers_.push_back(EventHandlerData<OnKeyUpFunc>(canvasId, func, userData)); |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
658 } |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
659 |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
660 // SDL ONLY |
1313
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
661 void GuiAdapter::SetGenericSdlEventCallback( |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
662 std::string canvasId, void* userData, bool capture, OnSdlEventCallback func) |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
663 { |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
664 sdlEventHandlers_.push_back(EventHandlerData<OnSdlEventCallback>(canvasId, func, userData)); |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
665 } |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
666 |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
667 // SDL ONLY |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
668 void GuiAdapter::OnAnimationFrame() |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
669 { |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
937
diff
changeset
|
670 std::vector<size_t> disabledAnimationHandlers; |
845
cdba0dbb4682
removed some c++11 for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
843
diff
changeset
|
671 for (size_t i = 0; i < animationFrameHandlers_.size(); i++) |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
672 { |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
673 // TODO: fix time |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
937
diff
changeset
|
674 bool goOn = (*(animationFrameHandlers_[i].first))(0, animationFrameHandlers_[i].second); |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
937
diff
changeset
|
675 |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
937
diff
changeset
|
676 // If the function returns false, we need to emulate what happens in Web |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
937
diff
changeset
|
677 // and remove the function from the handlers... |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
937
diff
changeset
|
678 if (!goOn) |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
937
diff
changeset
|
679 disabledAnimationHandlers.push_back(i); |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
937
diff
changeset
|
680 } |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
937
diff
changeset
|
681 for (size_t i = 0; i < disabledAnimationHandlers.size(); i++) |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
937
diff
changeset
|
682 { |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
937
diff
changeset
|
683 ORTHANC_ASSERT(animationFrameHandlers_.begin() + disabledAnimationHandlers[i] < animationFrameHandlers_.end()); |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
937
diff
changeset
|
684 animationFrameHandlers_.erase(animationFrameHandlers_.begin() + disabledAnimationHandlers[i]); |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
685 } |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
686 } |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
687 |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
688 // SDL ONLY |
1312
4f8c9065ee52
coping with both viewport and loader changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
689 void GuiAdapter::OnResize(unsigned int width, unsigned int height) |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
690 { |
845
cdba0dbb4682
removed some c++11 for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
843
diff
changeset
|
691 for (size_t i = 0; i < resizeHandlers_.size(); i++) |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
692 { |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
693 (*(resizeHandlers_[i].func))( |
1317 | 694 resizeHandlers_[i].canvasName, NULL, width, height, resizeHandlers_[i].userData); |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
695 } |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
696 } |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
697 |
1313
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
698 |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
699 |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
700 void GuiAdapter::OnSdlGenericEvent(const SDL_Event& sdlEvent) |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
701 { |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
702 // Events related to a window are only sent to the related canvas |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
703 // User events are sent to everyone (we can't filter them here) |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
704 |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
705 /* |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
706 SDL_WindowEvent SDL_WINDOWEVENT |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
707 SDL_KeyboardEvent SDL_KEYDOWN |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
708 SDL_KEYUP |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
709 SDL_TextEditingEvent SDL_TEXTEDITING |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
710 SDL_TextInputEvent SDL_TEXTINPUT |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
711 SDL_MouseMotionEvent SDL_MOUSEMOTION |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
712 SDL_MouseButtonEvent SDL_MOUSEBUTTONDOWN |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
713 SDL_MOUSEBUTTONUP |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
714 SDL_MouseWheelEvent SDL_MOUSEWHEEL |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
715 SDL_UserEvent SDL_USEREVENT through ::SDL_LASTEVENT-1 |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
716 */ |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
717 |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
718 // if this string is left empty, it means the message will be sent to |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
719 // all widgets. |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
720 // otherwise, it contains the originating message window title |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
721 |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
722 std::string windowTitle; |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
723 uint32_t windowId = 0; |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
724 |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
725 if (sdlEvent.type == SDL_WINDOWEVENT) |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
726 windowId = sdlEvent.window.windowID; |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
727 else if (sdlEvent.type == SDL_KEYDOWN || sdlEvent.type == SDL_KEYUP) |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
728 windowId = sdlEvent.key.windowID; |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
729 else if (sdlEvent.type == SDL_TEXTEDITING) |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
730 windowId = sdlEvent.edit.windowID; |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
731 else if (sdlEvent.type == SDL_TEXTINPUT) |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
732 windowId = sdlEvent.text.windowID; |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
733 else if (sdlEvent.type == SDL_MOUSEMOTION) |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
734 windowId = sdlEvent.motion.windowID; |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
735 else if (sdlEvent.type == SDL_MOUSEBUTTONDOWN || sdlEvent.type == SDL_MOUSEBUTTONUP) |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
736 windowId = sdlEvent.button.windowID; |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
737 else if (sdlEvent.type == SDL_MOUSEWHEEL) |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
738 windowId = sdlEvent.wheel.windowID; |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
739 else if (sdlEvent.type >= SDL_USEREVENT && sdlEvent.type <= (SDL_LASTEVENT-1)) |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
740 windowId = sdlEvent.user.windowID; |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
741 |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
742 if (windowId != 0) |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
743 { |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
744 SDL_Window* sdlWindow = SDL_GetWindowFromID(windowId); |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
745 ORTHANC_ASSERT(sdlWindow != NULL, "Window ID \"" << windowId << "\" is not a valid SDL window ID!"); |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
746 const char* windowTitleSz = SDL_GetWindowTitle(sdlWindow); |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
747 ORTHANC_ASSERT(windowTitleSz != NULL, "Window ID \"" << windowId << "\" has a NULL window title!"); |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
748 windowTitle = windowTitleSz; |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
749 ORTHANC_ASSERT(windowTitle != "", "Window ID \"" << windowId << "\" has an empty window title!"); |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
750 } |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
751 |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
752 for (size_t i = 0; i < sdlEventHandlers_.size(); i++) |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
753 { |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
754 // normally, the handlers return a bool indicating whether they |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
755 // have handled the event or not, but we don't really care about this |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
756 std::string& canvasName = sdlEventHandlers_[i].canvasName; |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
757 |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
758 bool sendEvent = true; |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
759 |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
760 if (windowTitle != "" && (canvasName != windowTitle)) |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
761 sendEvent = false; |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
762 |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
763 if (sendEvent) |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
764 { |
1319 | 765 OnSdlEventCallback func = sdlEventHandlers_[i].func; |
1313
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
766 (*func)(canvasName, sdlEvent, sdlEventHandlers_[i].userData); |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
767 } |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
768 } |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
769 } |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
770 |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
771 // SDL ONLY |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
772 void GuiAdapter::OnMouseWheelEvent(uint32_t windowID, const GuiAdapterWheelEvent& event) |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
773 { |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
774 // the SDL window name IS the canvas name ("canvas" is used because this lib |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
775 // is designed for Wasm |
879 | 776 SDL_Window* sdlWindow = SDL_GetWindowFromID(windowID); |
777 ORTHANC_ASSERT(sdlWindow != NULL, "Window ID \"" << windowID << "\" is not a valid SDL window ID!"); | |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
778 |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
779 const char* windowTitleSz = SDL_GetWindowTitle(sdlWindow); |
879 | 780 ORTHANC_ASSERT(windowTitleSz != NULL, "Window ID \"" << windowID << "\" has a NULL window title!"); |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
781 |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
782 std::string windowTitle(windowTitleSz); |
879 | 783 ORTHANC_ASSERT(windowTitle != "", "Window ID \"" << windowID << "\" has an empty window title!"); |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
784 |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
785 switch (event.mouse.type) |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
786 { |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
787 case GUIADAPTER_EVENT_WHEEL: |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
788 for (size_t i = 0; i < mouseWheelHandlers_.size(); i++) |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
789 { |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
790 if (mouseWheelHandlers_[i].canvasName == windowTitle) |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
791 (*(mouseWheelHandlers_[i].func))(windowTitle, &event, mouseWheelHandlers_[i].userData); |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
792 } |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
793 break; |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
794 default: |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
795 ORTHANC_ASSERT(false, "Wrong event.type: " << event.mouse.type << " in GuiAdapter::OnMouseWheelEvent(...)"); |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
796 break; |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
797 } |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
798 } |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
799 |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
800 |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
801 void GuiAdapter::OnKeyboardEvent(uint32_t windowID, const GuiAdapterKeyboardEvent& event) |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
802 { |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
803 // only one-letter (ascii) keyboard events supported for now |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
804 ORTHANC_ASSERT(event.sym[0] != 0); |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
805 ORTHANC_ASSERT(event.sym[1] == 0); |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
806 |
879 | 807 SDL_Window* sdlWindow = SDL_GetWindowFromID(windowID); |
808 ORTHANC_ASSERT(sdlWindow != NULL, "Window ID \"" << windowID << "\" is not a valid SDL window ID!"); | |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
809 |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
810 const char* windowTitleSz = SDL_GetWindowTitle(sdlWindow); |
879 | 811 ORTHANC_ASSERT(windowTitleSz != NULL, "Window ID \"" << windowID << "\" has a NULL window title!"); |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
812 |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
813 std::string windowTitle(windowTitleSz); |
879 | 814 ORTHANC_ASSERT(windowTitle != "", "Window ID \"" << windowID << "\" has an empty window title!"); |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
815 |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
816 switch (event.type) |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
817 { |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
818 case GUIADAPTER_EVENT_KEYDOWN: |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
819 for (size_t i = 0; i < keyDownHandlers_.size(); i++) |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
820 { |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
821 (*(keyDownHandlers_[i].func))(windowTitle, &event, keyDownHandlers_[i].userData); |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
822 } |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
823 break; |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
824 case GUIADAPTER_EVENT_KEYUP: |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
825 for (size_t i = 0; i < keyUpHandlers_.size(); i++) |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
826 { |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
827 (*(keyUpHandlers_[i].func))(windowTitle, &event, keyUpHandlers_[i].userData); |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
828 } |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
829 break; |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
830 default: |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
831 ORTHANC_ASSERT(false, "Wrong event.type: " << event.type << " in GuiAdapter::OnKeyboardEvent(...)"); |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
832 break; |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
833 } |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
834 } |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
835 |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
836 // SDL ONLY |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
837 void GuiAdapter::OnMouseEvent(uint32_t windowID, const GuiAdapterMouseEvent& event) |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
838 { |
880 | 839 if (windowID == 0) |
840 { | |
841 LOG(WARNING) << "GuiAdapter::OnMouseEvent -- windowID == 0 and event won't be routed!"; | |
842 } | |
843 else | |
844 { | |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
845 // the SDL window name IS the canvas name ("canvas" is used because this lib |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
846 // is designed for Wasm |
880 | 847 SDL_Window* sdlWindow = SDL_GetWindowFromID(windowID); |
848 | |
849 ORTHANC_ASSERT(sdlWindow != NULL, "Window ID \"" << windowID << "\" is not a valid SDL window ID!"); | |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
850 |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
851 const char* windowTitleSz = SDL_GetWindowTitle(sdlWindow); |
880 | 852 ORTHANC_ASSERT(windowTitleSz != NULL, "Window ID \"" << windowID << "\" has a NULL window title!"); |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
853 |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
854 std::string windowTitle(windowTitleSz); |
880 | 855 ORTHANC_ASSERT(windowTitle != "", "Window ID \"" << windowID << "\" has an empty window title!"); |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
856 |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
857 switch (event.type) |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
858 { |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
859 case GUIADAPTER_EVENT_MOUSEDOWN: |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
860 for (size_t i = 0; i < mouseDownHandlers_.size(); i++) |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
861 { |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
862 if (mouseDownHandlers_[i].canvasName == windowTitle) |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
863 (*(mouseDownHandlers_[i].func))(windowTitle, &event, mouseDownHandlers_[i].userData); |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
864 } |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
865 break; |
1020
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
866 case GUIADAPTER_EVENT_MOUSEDBLCLICK: |
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
867 for (size_t i = 0; i < mouseDblCickHandlers_.size(); i++) |
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
868 { |
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
869 if (mouseDblCickHandlers_[i].canvasName == windowTitle) |
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
870 (*(mouseDblCickHandlers_[i].func))(windowTitle, &event, mouseDblCickHandlers_[i].userData); |
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
871 } |
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
872 break; |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
873 case GUIADAPTER_EVENT_MOUSEMOVE: |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
874 for (size_t i = 0; i < mouseMoveHandlers_.size(); i++) |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
875 { |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
876 if (mouseMoveHandlers_[i].canvasName == windowTitle) |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
877 (*(mouseMoveHandlers_[i].func))(windowTitle, &event, mouseMoveHandlers_[i].userData); |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
878 } |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
879 break; |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
880 case GUIADAPTER_EVENT_MOUSEUP: |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
881 for (size_t i = 0; i < mouseUpHandlers_.size(); i++) |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
882 { |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
883 if (mouseUpHandlers_[i].canvasName == windowTitle) |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
884 (*(mouseUpHandlers_[i].func))(windowTitle, &event, mouseUpHandlers_[i].userData); |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
885 } |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
886 break; |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
887 default: |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
888 ORTHANC_ASSERT(false, "Wrong event.type: " << event.type << " in GuiAdapter::OnMouseEvent(...)"); |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
889 break; |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
890 } |
880 | 891 } |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
892 } |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
893 |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
937
diff
changeset
|
894 |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
937
diff
changeset
|
895 // extern void Debug_SetContextToBeKilled(std::string title); |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
937
diff
changeset
|
896 // extern void Debug_SetContextToBeRestored(std::string title); |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
937
diff
changeset
|
897 |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
898 // SDL ONLY |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
899 void GuiAdapter::RequestAnimationFrame(OnAnimationFrameFunc func, void* userData) |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
900 { |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
901 animationFrameHandlers_.push_back(std::make_pair(func, userData)); |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
902 } |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
903 |
853 | 904 # if ORTHANC_ENABLE_OPENGL == 1 && !defined(__APPLE__) /* OpenGL debug is not available on OS X */ |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
905 |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
906 // SDL ONLY |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
907 static void GLAPIENTRY |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
908 OpenGLMessageCallback(GLenum source, |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
909 GLenum type, |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
910 GLuint id, |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
911 GLenum severity, |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
912 GLsizei length, |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
913 const GLchar * message, |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
914 const void* userParam) |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
915 { |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
916 if (severity != GL_DEBUG_SEVERITY_NOTIFICATION) |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
917 { |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
918 fprintf(stderr, "GL CALLBACK: %s type = 0x%x, severity = 0x%x, message = %s\n", |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
919 (type == GL_DEBUG_TYPE_ERROR ? "** GL ERROR **" : ""), |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
920 type, severity, message); |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
921 } |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
922 } |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
923 # endif |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
924 |
1313
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
925 #if 0 |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
926 // TODO: remove this when generic sdl event handlers are implemented in |
1341 | 927 // the DoseView |
1313
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
928 // SDL ONLY |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
929 bool GuiAdapter::IsSdlViewPortRefreshEvent(const SDL_Event& event) const |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
930 { |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
931 SDL_Window* sdlWindow = SDL_GetWindowFromID(event.window.windowID); |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
932 |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
933 ORTHANC_ASSERT(sdlWindow != NULL, "Window ID \"" << event.window.windowID << "\" is not a valid SDL window ID!"); |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
934 |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
935 const char* windowTitleSz = SDL_GetWindowTitle(sdlWindow); |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
936 |
1341 | 937 // now we need to find the DoseView from from the canvas name! |
1313
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
938 // (and retrieve the SdlViewport) |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
939 boost::shared_ptr<IGuiAdapterWidget> foundWidget; |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
940 VisitWidgets([&foundWidget, windowTitleSz](auto widget) |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
941 { |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
942 if (widget->GetCanvasIdentifier() == std::string(windowTitleSz)) |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
943 foundWidget = widget; |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
944 }); |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
945 ORTHANC_ASSERT(foundWidget, "The window named: \"" << windowTitleSz << "\" was not found in the registered widgets!"); |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
946 return foundWidget->GetSdlViewport().IsRefreshEvent(event); |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
947 } |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
948 #endif |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
949 |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
950 // SDL ONLY |
937
86ac61a040c9
Added getters and notifications to allow clients of the loaders (DicomStructureSetLoader, OrthancSeriesVolumeProgressiveLoader and OrthancMultiframeVolumeLoader) to know when the loading is finished + added ability for SDL event loop to execute a callback repeatedly (used to check the view loading state)
Benjamin Golinvaux <bgo@osimis.io>
parents:
915
diff
changeset
|
951 void GuiAdapter::Run(GuiAdapterRunFunc func, void* cookie) |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
952 { |
913
2b4b6b86520a
Re-enabled gl debug output in GuiAdapter +
Benjamin Golinvaux <bgo@osimis.io>
parents:
906
diff
changeset
|
953 #if 1 |
906
52b1c6ff10c5
Disabled OpenGL in GuiAdapter to allow for Cairo-only workflows (THIS IS A TEMP CHANGE!!!) + disabled outlined text by default (build macro)
Benjamin Golinvaux <bgo@osimis.io>
parents:
869
diff
changeset
|
954 // TODO: MAKE THIS DYNAMIC !!! See SdlOpenGLViewport vs Cairo in ViewportWrapper |
853 | 955 # if ORTHANC_ENABLE_OPENGL == 1 && !defined(__APPLE__) |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
956 glEnable(GL_DEBUG_OUTPUT); |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
957 glDebugMessageCallback(OpenGLMessageCallback, 0); |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
958 # endif |
906
52b1c6ff10c5
Disabled OpenGL in GuiAdapter to allow for Cairo-only workflows (THIS IS A TEMP CHANGE!!!) + disabled outlined text by default (build macro)
Benjamin Golinvaux <bgo@osimis.io>
parents:
869
diff
changeset
|
959 #endif |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
960 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
961 // Uint32 SDL_GetWindowID(SDL_Window* window) |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
962 // SDL_Window* SDL_GetWindowFromID(Uint32 id) // may return NULL |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
963 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
964 bool stop = false; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
965 while (!stop) |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
966 { |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
967 { |
1312
4f8c9065ee52
coping with both viewport and loader changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
968 // TODO: lock all viewports here! (use a scoped object) |
937
86ac61a040c9
Added getters and notifications to allow clients of the loaders (DicomStructureSetLoader, OrthancSeriesVolumeProgressiveLoader and OrthancMultiframeVolumeLoader) to know when the loading is finished + added ability for SDL event loop to execute a callback repeatedly (used to check the view loading state)
Benjamin Golinvaux <bgo@osimis.io>
parents:
915
diff
changeset
|
969 if(func != NULL) |
86ac61a040c9
Added getters and notifications to allow clients of the loaders (DicomStructureSetLoader, OrthancSeriesVolumeProgressiveLoader and OrthancMultiframeVolumeLoader) to know when the loading is finished + added ability for SDL event loop to execute a callback repeatedly (used to check the view loading state)
Benjamin Golinvaux <bgo@osimis.io>
parents:
915
diff
changeset
|
970 (*func)(cookie); |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
971 OnAnimationFrame(); // in SDL we must call it |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
972 } |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
973 |
1313
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
974 while (!stop) |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
975 { |
1313
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
976 std::vector<SDL_Event> sdlEvents; |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
977 std::map<Uint32,SDL_Event> userEventsMap; |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
978 |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
979 SDL_Event sdlEvent; |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
980 |
1313
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
981 // FIRST: collect all pending events |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
982 while (SDL_PollEvent(&sdlEvent) != 0) |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
983 { |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
984 if ( (sdlEvent.type >= SDL_USEREVENT) && |
1435
d0a3de66bb42
Small fix for refresh events.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1410
diff
changeset
|
985 (sdlEvent.type < SDL_LASTEVENT) ) |
1313
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
986 { |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
987 // we don't want to have multiple events with the same event.type |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
988 userEventsMap[sdlEvent.type] = sdlEvent; |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
989 } |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
990 else |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
991 { |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
992 sdlEvents.push_back(sdlEvent); |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
993 } |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
853
diff
changeset
|
994 } |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
995 |
1313
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
996 // SECOND: collect all user events |
1319 | 997 for (std::map<Uint32,SDL_Event>::const_iterator it = userEventsMap.begin(); it != userEventsMap.end(); ++it) |
998 sdlEvents.push_back(it->second); | |
1313
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
999 |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1000 // now process the events |
1319 | 1001 for (std::vector<SDL_Event>::const_iterator it = sdlEvents.begin(); it != sdlEvents.end(); ++it) |
1313
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1002 { |
1319 | 1003 const SDL_Event& sdlEvent = *it; |
1313
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1004 // TODO: lock all viewports here! (use a scoped object) |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
937
diff
changeset
|
1005 |
1313
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1006 if (sdlEvent.type == SDL_QUIT) |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1007 { |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1008 // TODO: call exit callbacks here |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
1009 stop = true; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
1010 break; |
1313
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1011 } |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1012 else if ((sdlEvent.type == SDL_MOUSEMOTION) || |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1013 (sdlEvent.type == SDL_MOUSEBUTTONDOWN) || |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1014 (sdlEvent.type == SDL_MOUSEBUTTONUP)) |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1015 { |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1016 int scancodeCount = 0; |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1017 const uint8_t* keyboardState = SDL_GetKeyboardState(&scancodeCount); |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1018 bool ctrlPressed(false); |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1019 bool shiftPressed(false); |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1020 bool altPressed(false); |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
1021 |
1313
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1022 if (SDL_SCANCODE_LCTRL < scancodeCount && keyboardState[SDL_SCANCODE_LCTRL]) |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1023 ctrlPressed = true; |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1024 if (SDL_SCANCODE_RCTRL < scancodeCount && keyboardState[SDL_SCANCODE_RCTRL]) |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1025 ctrlPressed = true; |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1026 if (SDL_SCANCODE_LSHIFT < scancodeCount && keyboardState[SDL_SCANCODE_LSHIFT]) |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1027 shiftPressed = true; |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1028 if (SDL_SCANCODE_RSHIFT < scancodeCount && keyboardState[SDL_SCANCODE_RSHIFT]) |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1029 shiftPressed = true; |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1030 if (SDL_SCANCODE_LALT < scancodeCount && keyboardState[SDL_SCANCODE_LALT]) |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1031 altPressed = true; |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1032 |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1033 GuiAdapterMouseEvent dest; |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1034 ConvertFromPlatform(dest, ctrlPressed, shiftPressed, altPressed, sdlEvent); |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1035 OnMouseEvent(sdlEvent.window.windowID, dest); |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1036 #if 0 |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1037 // for reference, how to create trackers |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1038 if (tracker) |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1039 { |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1040 PointerEvent e; |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1041 e.AddPosition(compositor.GetPixelCenterCoordinates( |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1042 sdlEvent.button.x, sdlEvent.button.y)); |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1043 tracker->PointerMove(e); |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1044 } |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1045 #endif |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
1046 } |
1313
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1047 else if (sdlEvent.type == SDL_MOUSEWHEEL) |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1048 { |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1049 |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1050 int scancodeCount = 0; |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1051 const uint8_t* keyboardState = SDL_GetKeyboardState(&scancodeCount); |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1052 bool ctrlPressed(false); |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1053 bool shiftPressed(false); |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1054 bool altPressed(false); |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1055 |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1056 if (SDL_SCANCODE_LCTRL < scancodeCount && keyboardState[SDL_SCANCODE_LCTRL]) |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1057 ctrlPressed = true; |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1058 if (SDL_SCANCODE_RCTRL < scancodeCount && keyboardState[SDL_SCANCODE_RCTRL]) |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1059 ctrlPressed = true; |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1060 if (SDL_SCANCODE_LSHIFT < scancodeCount && keyboardState[SDL_SCANCODE_LSHIFT]) |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1061 shiftPressed = true; |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1062 if (SDL_SCANCODE_RSHIFT < scancodeCount && keyboardState[SDL_SCANCODE_RSHIFT]) |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1063 shiftPressed = true; |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1064 if (SDL_SCANCODE_LALT < scancodeCount && keyboardState[SDL_SCANCODE_LALT]) |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1065 altPressed = true; |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1066 |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1067 GuiAdapterWheelEvent dest; |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1068 ConvertFromPlatform(dest, ctrlPressed, shiftPressed, altPressed, sdlEvent); |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1069 OnMouseWheelEvent(sdlEvent.window.windowID, dest); |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1070 |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1071 //KeyboardModifiers modifiers = GetKeyboardModifiers(keyboardState, scancodeCount); |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1072 |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1073 //int x, y; |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1074 //SDL_GetMouseState(&x, &y); |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1075 |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1076 //if (sdlEvent.wheel.y > 0) |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1077 //{ |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1078 // locker.GetCentralViewport().MouseWheel(MouseWheelDirection_Up, x, y, modifiers); |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1079 //} |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1080 //else if (sdlEvent.wheel.y < 0) |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1081 //{ |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1082 // locker.GetCentralViewport().MouseWheel(MouseWheelDirection_Down, x, y, modifiers); |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1083 //} |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1084 } |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1085 else if (sdlEvent.type == SDL_WINDOWEVENT && |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1086 (sdlEvent.window.event == SDL_WINDOWEVENT_RESIZED || |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1087 sdlEvent.window.event == SDL_WINDOWEVENT_SIZE_CHANGED)) |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1088 { |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1089 #if 0 |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1090 tracker.reset(); |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1091 #endif |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1092 OnResize(sdlEvent.window.data1, sdlEvent.window.data2); |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1093 } |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1094 else if (sdlEvent.type == SDL_KEYDOWN && sdlEvent.key.repeat == 0 /* Ignore key bounce */) |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1095 { |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1096 switch (sdlEvent.key.keysym.sym) |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1097 { |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1098 case SDLK_f: |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1099 // window.GetWindow().ToggleMaximize(); //TODO: move to particular handler |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1100 break; |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1101 |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1102 // This commented out code was used to debug the context |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1103 // loss/restoring code (2019-08-10) |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1104 // case SDLK_k: |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1105 // { |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1106 // SDL_Window* window = SDL_GetWindowFromID(sdlEvent.window.windowID); |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1107 // std::string windowTitle(SDL_GetWindowTitle(window)); |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1108 // Debug_SetContextToBeKilled(windowTitle); |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1109 // } |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1110 // break; |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1111 // case SDLK_l: |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1112 // { |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1113 // SDL_Window* window = SDL_GetWindowFromID(sdlEvent.window.windowID); |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1114 // std::string windowTitle(SDL_GetWindowTitle(window)); |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1115 // Debug_SetContextToBeRestored(windowTitle); |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1116 // } |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1117 // break; |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1118 |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1119 case SDLK_q: |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1120 stop = true; |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1121 break; |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1122 |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1123 default: |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1124 GuiAdapterKeyboardEvent dest; |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1125 ConvertFromPlatform(dest, sdlEvent); |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1126 OnKeyboardEvent(sdlEvent.window.windowID, dest); |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1127 break; |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1128 } |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1129 } |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1130 |
f30905f5d246
Added support for OnGenericSdlEvent to GuiAdapter.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1312
diff
changeset
|
1131 OnSdlGenericEvent(sdlEvent); |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
1132 } |
1436
fb8c36073983
Fix problem where multiple init/exit were not possible when using GuiAdapter
Benjamin Golinvaux <bgo@osimis.io>
parents:
1435
diff
changeset
|
1133 SDL_Delay(1); |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
1134 } |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
1135 } |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
1136 } |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
1137 #endif |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
1138 } |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
1139 |