annotate Applications/Generic/GuiAdapter.cpp @ 1312:4f8c9065ee52 broker

coping with both viewport and loader changes
author Benjamin Golinvaux <bgo@osimis.io>
date Mon, 09 Mar 2020 14:56:04 +0100
parents 257f2c9a02ac
children f30905f5d246
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
bb88686acecc fix OS X build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 845
diff changeset
23 #if ORTHANC_ENABLE_OPENGL == 1
bb88686acecc fix OS X build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 845
diff changeset
24 # include "../../Framework/OpenGL/OpenGLIncludes.h"
bb88686acecc fix OS X build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 845
diff changeset
25 #endif
bb88686acecc fix OS X build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 845
diff changeset
26
bb88686acecc fix OS X build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 845
diff changeset
27 #if ORTHANC_ENABLE_SDL == 1
bb88686acecc fix OS X build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 845
diff changeset
28 # include <SDL_video.h>
bb88686acecc fix OS X build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 845
diff changeset
29 # include <SDL_render.h>
bb88686acecc fix OS X build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 845
diff changeset
30 # include <SDL.h>
bb88686acecc fix OS X build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 845
diff changeset
31 #endif
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
32
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
33 #if ORTHANC_ENABLE_THREADS == 1
1226
05d05cba0f4f explicitely tagging LockingEmitter as deprecated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1097
diff changeset
34 # include "../../Framework/Deprecated/Messages/LockingEmitter.h"
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
35 #endif
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
36
1298
8a0a62189f46 replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1290
diff changeset
37 #include <Core/Compatibility.h>
8a0a62189f46 replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1290
diff changeset
38
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
39 namespace OrthancStone
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
40 {
879
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
41 std::ostream& operator<<(
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
42 std::ostream& os, const GuiAdapterKeyboardEvent& event)
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
43 {
880
Alain Mazy <alain@mazy.be>
parents: 879 869
diff changeset
44 os << "sym: " << event.sym << " (" << (int)(event.sym[0]) << ") ctrl: " << event.ctrlKey << ", " <<
879
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
45 "shift: " << event.shiftKey << ", " <<
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
46 "alt: " << event.altKey;
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
47 return os;
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
48 }
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
49
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
50 #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
51 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
52 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
53 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
54
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
55 void ConvertFromPlatform(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
56 GuiAdapterUiEvent& dest,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
57 int eventType,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
58 const EmscriptenUiEvent& src)
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 // no data for now
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
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
63 void ConvertFromPlatform(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
64 GuiAdapterMouseEvent& dest,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
65 int eventType,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
66 const EmscriptenMouseEvent& src)
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
67 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
68 memset(&dest, 0, sizeof(GuiAdapterMouseEvent));
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
69 switch (eventType)
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
70 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
71 case EMSCRIPTEN_EVENT_CLICK:
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
72 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
73 ORTHANC_ASSERT(false, "Not supported");
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
74 break;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
75 case EMSCRIPTEN_EVENT_MOUSEDOWN:
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
76 dest.type = GUIADAPTER_EVENT_MOUSEDOWN;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
77 break;
1020
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 947
diff changeset
78 case EMSCRIPTEN_EVENT_DBLCLICK:
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 947
diff changeset
79 dest.type = GUIADAPTER_EVENT_MOUSEDBLCLICK;
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 947
diff changeset
80 break;
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
81 case EMSCRIPTEN_EVENT_MOUSEMOVE:
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
82 dest.type = GUIADAPTER_EVENT_MOUSEMOVE;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
83 break;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
84 case EMSCRIPTEN_EVENT_MOUSEUP:
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
85 dest.type = GUIADAPTER_EVENT_MOUSEUP;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
86 break;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
87 case EMSCRIPTEN_EVENT_WHEEL:
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
88 dest.type = GUIADAPTER_EVENT_WHEEL;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
89 break;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
90
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
91 default:
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
92 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
93 ORTHANC_ASSERT(false, "Not supported");
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
94 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
95 //dest.timestamp = src.timestamp;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
96 //dest.screenX = src.screenX;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
97 //dest.screenY = src.screenY;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
98 //dest.clientX = src.clientX;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
99 //dest.clientY = src.clientY;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
100 dest.ctrlKey = src.ctrlKey;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
101 dest.shiftKey = src.shiftKey;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
102 dest.altKey = src.altKey;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
103 //dest.metaKey = src.metaKey;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
104 dest.button = src.button;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
105 //dest.buttons = src.buttons;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
106 //dest.movementX = src.movementX;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
107 //dest.movementY = src.movementY;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
108 dest.targetX = src.targetX;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
109 dest.targetY = src.targetY;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
110 //dest.canvasX = src.canvasX;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
111 //dest.canvasY = src.canvasY;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
112 //dest.padding = src.padding;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
113 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
114
861
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
115 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
116 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
117 ConvertFromPlatform(dest.mouse, eventType, src.mouse);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
118 dest.deltaX = src.deltaX;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
119 dest.deltaY = src.deltaY;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
120 switch (src.deltaMode)
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
121 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
122 case DOM_DELTA_PIXEL:
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
123 dest.deltaMode = GUIADAPTER_DELTA_PIXEL;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
124 break;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
125 case DOM_DELTA_LINE:
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
126 dest.deltaMode = GUIADAPTER_DELTA_LINE;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
127 break;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
128 case DOM_DELTA_PAGE:
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
129 dest.deltaMode = GUIADAPTER_DELTA_PAGE;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
130 break;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
131 default:
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
132 ORTHANC_ASSERT(false, "Unknown deltaMode: " << src.deltaMode <<
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
133 " in wheel event...");
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
134 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
135 dest.deltaMode = src.deltaMode;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
136 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
137
861
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
138 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
139 {
861
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
140 dest.sym[0] = src.key[0];
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
141 dest.sym[1] = 0;
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
142 dest.ctrlKey = src.ctrlKey;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
143 dest.shiftKey = src.shiftKey;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
144 dest.altKey = src.altKey;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
145 }
861
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
146
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
147 template<typename GenericFunc>
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
148 struct FuncAdapterPayload
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
149 {
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
150 std::string canvasId;
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
151 void* userData;
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
152 GenericFunc callback;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
153 };
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
154
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
155 template<typename GenericFunc,
861
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
156 typename GuiAdapterEvent,
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
157 typename EmscriptenEvent>
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
158 EM_BOOL OnEventAdapterFunc(
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
159 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
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 // userData is OnMouseWheelFuncAdapterPayload
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
163 FuncAdapterPayload<GenericFunc>* payload =
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
164 reinterpret_cast<FuncAdapterPayload<GenericFunc>*>(userData);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
165 // LOG(INFO) << "OnEventAdapterFunc";
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
166 // LOG(INFO) << "------------------";
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
167 // LOG(INFO) << "eventType: " << eventType << " wheelEvent: " <<
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
168 // (int)wheelEvent << " userData: " << userData <<
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
169 // " payload->userData: " << payload->userData;
861
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
170
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
171 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
172 ConvertFromPlatform(guiEvent, eventType, *emEvent);
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
173 bool ret = (*(payload->callback))(payload->canvasId, &guiEvent, payload->userData);
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
174 return static_cast<EM_BOOL>(ret);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
175 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
176
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
177 template<typename GenericFunc,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
178 typename GuiAdapterEvent,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
179 typename EmscriptenEvent>
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
180 EM_BOOL OnEventAdapterFunc2(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
181 int /*eventType*/, const EmscriptenEvent* wheelEvent, void* userData)
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 // userData is OnMouseWheelFuncAdapterPayload
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
184 FuncAdapterPayload<GenericFunc>* payload =
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
185 reinterpret_cast<FuncAdapterPayload<GenericFunc>*>(userData);
861
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
186
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
187 GuiAdapterEvent guiEvent;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
188 ConvertFromPlatform(guiEvent, *wheelEvent);
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
189 bool ret = (*(payload->callback))(payload->canvasId, &guiEvent, payload->userData);
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
190 return static_cast<EM_BOOL>(ret);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
191 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
192
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
193 template<typename GenericFunc>
861
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
194 EM_BOOL OnEventAdapterFunc3(
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
195 double time, void* userData)
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
196 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
197 // userData is OnMouseWheelFuncAdapterPayload
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
198 FuncAdapterPayload<GenericFunc>* payload =
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
199 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
200 //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
201 bool ret = (*(payload->callback))(time, payload->userData);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
202 return static_cast<EM_BOOL>(ret);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
203 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
204
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
205 // 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
206 template<
861
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
207 typename GenericFunc,
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
208 typename GuiAdapterEvent,
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
209 typename EmscriptenEvent,
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
210 typename EmscriptenSetCallbackFunc>
861
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
211 static void SetCallback(
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
212 EmscriptenSetCallbackFunc emFunc,
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
213 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
214 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
215 // TODO: write RemoveCallback with an int id that gets returned from
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
216 // here
861
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
217 FuncAdapterPayload<GenericFunc>* payload =
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
218 new FuncAdapterPayload<GenericFunc>();
1298
8a0a62189f46 replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1290
diff changeset
219 std::unique_ptr<FuncAdapterPayload<GenericFunc> > payloadP(payload);
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
220 payload->canvasId = canvasId;
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
221 payload->callback = func;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
222 payload->userData = userData;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
223 void* userDataRaw = reinterpret_cast<void*>(payload);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
224 // LOG(INFO) << "SetCallback -- userDataRaw: " << userDataRaw <<
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
225 // " payload: " << payload << " payload->userData: " << payload->userData;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
226 (*emFunc)(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
227 canvasId.c_str(),
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
228 userDataRaw,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
229 static_cast<EM_BOOL>(capture),
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
230 &OnEventAdapterFunc<GenericFunc, GuiAdapterEvent, EmscriptenEvent>,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
231 EM_CALLBACK_THREAD_CONTEXT_CALLING_THREAD);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
232 payloadP.release();
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
233 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
234
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
235 template<
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
236 typename GenericFunc,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
237 typename GuiAdapterEvent,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
238 typename EmscriptenEvent,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
239 typename EmscriptenSetCallbackFunc>
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
240 static void SetCallback2(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
241 EmscriptenSetCallbackFunc emFunc,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
242 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
243 {
1298
8a0a62189f46 replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1290
diff changeset
244 std::unique_ptr<FuncAdapterPayload<GenericFunc> > payload(
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
245 new FuncAdapterPayload<GenericFunc>()
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
246 );
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
247 payload->canvasId = canvasId;
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
248 payload->callback = func;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
249 payload->userData = userData;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
250 void* userDataRaw = reinterpret_cast<void*>(payload.release());
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
251 (*emFunc)(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
252 canvasId.c_str(),
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
253 userDataRaw,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
254 static_cast<EM_BOOL>(capture),
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
255 &OnEventAdapterFunc2<GenericFunc, GuiAdapterEvent, EmscriptenEvent>,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
256 EM_CALLBACK_THREAD_CONTEXT_CALLING_THREAD);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
257 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
258
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
259 template<
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
260 typename GenericFunc,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
261 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
262 static void SetAnimationFrameCallback(
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
263 EmscriptenSetCallbackFunc emFunc,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
264 void* userData, GenericFunc func)
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
265 {
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
266 // LOG(ERROR) << "SetAnimationFrameCallback !!!!!! (RequestAnimationFrame)";
1298
8a0a62189f46 replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1290
diff changeset
267 std::unique_ptr<FuncAdapterPayload<GenericFunc> > payload(
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
268 new FuncAdapterPayload<GenericFunc>()
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
269 );
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
270 payload->canvasId = "UNDEFINED";
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
271 payload->callback = func;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
272 payload->userData = userData;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
273 void* userDataRaw = reinterpret_cast<void*>(payload.release());
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
274 (*emFunc)(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
275 &OnEventAdapterFunc3<GenericFunc>,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
276 userDataRaw);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
277 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
278
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
279 void GuiAdapter::SetWheelCallback(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
280 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
281 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
282 SetCallback<OnMouseWheelFunc, GuiAdapterWheelEvent, EmscriptenWheelEvent>(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
283 &emscripten_set_wheel_callback_on_thread,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
284 canvasId,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
285 userData,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
286 capture,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
287 func);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
288 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
289
1020
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 947
diff changeset
290
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 947
diff changeset
291 void GuiAdapter::SetMouseDblClickCallback(
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 947
diff changeset
292 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
293 {
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 947
diff changeset
294 SetCallback<OnMouseEventFunc, GuiAdapterMouseEvent, EmscriptenMouseEvent>(
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 947
diff changeset
295 &emscripten_set_dblclick_callback_on_thread,
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 947
diff changeset
296 canvasId,
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 947
diff changeset
297 userData,
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 947
diff changeset
298 capture,
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 947
diff changeset
299 func);
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 947
diff changeset
300 }
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 947
diff changeset
301
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 947
diff changeset
302
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
303 void GuiAdapter::SetMouseDownCallback(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
304 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
305 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
306 SetCallback<OnMouseEventFunc, GuiAdapterMouseEvent, EmscriptenMouseEvent>(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
307 &emscripten_set_mousedown_callback_on_thread,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
308 canvasId,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
309 userData,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
310 capture,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
311 func);
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
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
314 void GuiAdapter::SetMouseMoveCallback(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
315 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
316 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
317 // LOG(INFO) << "SetMouseMoveCallback -- " << "supplied userData: " <<
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
318 // userData;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
319
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
320 SetCallback<OnMouseEventFunc, GuiAdapterMouseEvent, EmscriptenMouseEvent>(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
321 &emscripten_set_mousemove_callback_on_thread,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
322 canvasId,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
323 userData,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
324 capture,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
325 func);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
326 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
327
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
328 void GuiAdapter::SetMouseUpCallback(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
329 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
330 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
331 SetCallback<OnMouseEventFunc, GuiAdapterMouseEvent, EmscriptenMouseEvent>(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
332 &emscripten_set_mouseup_callback_on_thread,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
333 canvasId,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
334 userData,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
335 capture,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
336 func);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
337 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
338
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
339 void GuiAdapter::SetKeyDownCallback(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
340 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
341 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
342 SetCallback2<OnKeyDownFunc, GuiAdapterKeyboardEvent, EmscriptenKeyboardEvent>(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
343 &emscripten_set_keydown_callback_on_thread,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
344 canvasId,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
345 userData,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
346 capture,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
347 func);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
348 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
349
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
350 void GuiAdapter::SetKeyUpCallback(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
351 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
352 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
353 SetCallback2<OnKeyUpFunc, GuiAdapterKeyboardEvent, EmscriptenKeyboardEvent>(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
354 &emscripten_set_keyup_callback_on_thread,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
355 canvasId,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
356 userData,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
357 capture,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
358 func);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
359 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
360
1312
4f8c9065ee52 coping with both viewport and loader changes
Benjamin Golinvaux <bgo@osimis.io>
parents: 1300
diff changeset
361 #if 0
4f8c9065ee52 coping with both viewport and loader changes
Benjamin Golinvaux <bgo@osimis.io>
parents: 1300
diff changeset
362 // 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
363 void GuiAdapter::SetResizeCallback(
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, OnWindowResizeFunc 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<OnWindowResizeFunc, GuiAdapterUiEvent, EmscriptenUiEvent>(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
367 &emscripten_set_resize_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 }
1312
4f8c9065ee52 coping with both viewport and loader changes
Benjamin Golinvaux <bgo@osimis.io>
parents: 1300
diff changeset
373 #endif
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
374
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
375 void GuiAdapter::RequestAnimationFrame(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
376 OnAnimationFrameFunc func, void* userData)
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
377 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
378 // LOG(ERROR) << "-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+";
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
379 // LOG(ERROR) << "RequestAnimationFrame";
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
380 // LOG(ERROR) << "-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+";
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
381 SetAnimationFrameCallback<OnAnimationFrameFunc>(
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
382 &emscripten_request_animation_frame_loop,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
383 userData,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
384 func);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
385 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
386
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
387 #if 0
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
388 void GuiAdapter::SetKeyDownCallback(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
389 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
390 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
391 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
392 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
393 void GuiAdapter::SetKeyUpCallback(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
394 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
395 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
396 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
397 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
398
1312
4f8c9065ee52 coping with both viewport and loader changes
Benjamin Golinvaux <bgo@osimis.io>
parents: 1300
diff changeset
399 // handled from within WebAssemblyViewport
4f8c9065ee52 coping with both viewport and loader changes
Benjamin Golinvaux <bgo@osimis.io>
parents: 1300
diff changeset
400 //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
401 //{
4f8c9065ee52 coping with both viewport and loader changes
Benjamin Golinvaux <bgo@osimis.io>
parents: 1300
diff changeset
402 // 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
403 //}
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
404
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
405 void GuiAdapter::RequestAnimationFrame(OnAnimationFrameFunc func, void* userData)
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
406 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
407 emscripten_request_animation_frame_loop(func, userData);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
408 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
409 #endif
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 #else
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
413
861
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
414 // SDL ONLY
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
415 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
416 {
861
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
417 memset(&dest, 0, sizeof(GuiAdapterMouseEvent));
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
418 switch (source.type)
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
419 {
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
420 case SDL_MOUSEBUTTONDOWN:
1020
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 947
diff changeset
421 if (source.button.clicks == 1) {
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 947
diff changeset
422 dest.type = GUIADAPTER_EVENT_MOUSEDOWN;
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 947
diff changeset
423 } else if (source.button.clicks == 2) {
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 947
diff changeset
424 dest.type = GUIADAPTER_EVENT_MOUSEDBLCLICK;
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 947
diff changeset
425 } else {
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 947
diff changeset
426 dest.type = GUIADAPTER_EVENT_MOUSEDBLCLICK;
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 947
diff changeset
427 LOG(WARNING) << "Multiple-click ignored.";
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 947
diff changeset
428 }
861
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
429 break;
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
430 case SDL_MOUSEMOTION:
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
431 dest.type = GUIADAPTER_EVENT_MOUSEMOVE;
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
432 break;
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
433 case SDL_MOUSEBUTTONUP:
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
434 dest.type = GUIADAPTER_EVENT_MOUSEUP;
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
435 break;
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
436 case SDL_MOUSEWHEEL:
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
437 dest.type = GUIADAPTER_EVENT_WHEEL;
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
438 break;
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
439 default:
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
440 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
441 ORTHANC_ASSERT(false, "Not supported");
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
442 }
861
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
443 //dest.timestamp = src.timestamp;
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
444 //dest.screenX = src.screenX;
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
445 //dest.screenY = src.screenY;
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
446 //dest.clientX = src.clientX;
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
447 //dest.clientY = src.clientY;
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
448 dest.ctrlKey = ctrlPressed;
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
449 dest.shiftKey = shiftPressed;
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
450 dest.altKey = altPressed;
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
451 //dest.metaKey = src.metaKey;
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
452 switch (source.button.button)
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
453 {
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
454 case SDL_BUTTON_MIDDLE:
880
Alain Mazy <alain@mazy.be>
parents: 879 869
diff changeset
455 dest.button =GUIADAPTER_MOUSEBUTTON_MIDDLE;
861
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
456 break;
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
457
861
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
458 case SDL_BUTTON_RIGHT:
880
Alain Mazy <alain@mazy.be>
parents: 879 869
diff changeset
459 dest.button = GUIADAPTER_MOUSEBUTTON_RIGHT;
861
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
460 break;
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
461
861
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
462 case SDL_BUTTON_LEFT:
880
Alain Mazy <alain@mazy.be>
parents: 879 869
diff changeset
463 dest.button = GUIADAPTER_MOUSEBUTTON_LEFT;
861
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
464 break;
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
465
861
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
466 default:
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
467 break;
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
468 }
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
469 //dest.buttons = src.buttons;
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
470 //dest.movementX = src.movementX;
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
471 //dest.movementY = src.movementY;
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
472 dest.targetX = source.button.x;
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
473 dest.targetY = source.button.y;
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
474 //dest.canvasX = src.canvasX;
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
475 //dest.canvasY = src.canvasY;
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
476 //dest.padding = src.padding;
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
477 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
478
861
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
479 void ConvertFromPlatform(
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
480 GuiAdapterWheelEvent& dest,
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
481 bool ctrlPressed, bool shiftPressed, bool altPressed,
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
482 const SDL_Event& source)
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
483 {
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
484 ConvertFromPlatform(dest.mouse, ctrlPressed, shiftPressed, altPressed, source);
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
485 dest.deltaX = source.wheel.x;
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
486 dest.deltaY = source.wheel.y;
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
487 }
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
488
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
489 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
490 {
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
491 memset(&dest, 0, sizeof(GuiAdapterMouseEvent));
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
492 switch (src.type)
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
493 {
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
494 case SDL_KEYDOWN:
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
495 dest.type = GUIADAPTER_EVENT_KEYDOWN;
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
496 break;
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
497 case SDL_KEYUP:
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
498 dest.type = GUIADAPTER_EVENT_KEYUP;
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
499 break;
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
500 default:
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
501 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
502 ORTHANC_ASSERT(false, "Not supported");
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
503 }
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
504 dest.sym[0] = src.key.keysym.sym;
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
505 dest.sym[1] = 0;
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
506
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
507 if (src.key.keysym.mod & KMOD_CTRL)
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
508 dest.ctrlKey = true;
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
509 else
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
510 dest.ctrlKey = false;
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
511
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
512 if (src.key.keysym.mod & KMOD_SHIFT)
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
513 dest.shiftKey = true;
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
514 else
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
515 dest.shiftKey = false;
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
516
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
517 if (src.key.keysym.mod & KMOD_ALT)
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
518 dest.altKey = true;
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
519 else
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
520 dest.altKey = false;
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
521 }
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
522
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
523
1312
4f8c9065ee52 coping with both viewport and loader changes
Benjamin Golinvaux <bgo@osimis.io>
parents: 1300
diff changeset
524 #if ORTHANC_ENABLE_WASM != 1
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
525 // SDL ONLY
1312
4f8c9065ee52 coping with both viewport and loader changes
Benjamin Golinvaux <bgo@osimis.io>
parents: 1300
diff changeset
526 void GuiAdapter::SetSdlResizeCallback(
4f8c9065ee52 coping with both viewport and loader changes
Benjamin Golinvaux <bgo@osimis.io>
parents: 1300
diff changeset
527 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
528 {
1312
4f8c9065ee52 coping with both viewport and loader changes
Benjamin Golinvaux <bgo@osimis.io>
parents: 1300
diff changeset
529 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
530 }
1312
4f8c9065ee52 coping with both viewport and loader changes
Benjamin Golinvaux <bgo@osimis.io>
parents: 1300
diff changeset
531 #endif
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
532
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
533 // SDL ONLY
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
534 void GuiAdapter::SetMouseDownCallback(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
535 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
536 {
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
537 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
538 }
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
539
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
540 // SDL ONLY
1020
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 947
diff changeset
541 void GuiAdapter::SetMouseDblClickCallback(
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 947
diff changeset
542 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
543 {
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 947
diff changeset
544 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
545 }
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 947
diff changeset
546
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 947
diff changeset
547 // SDL ONLY
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
548 void GuiAdapter::SetMouseMoveCallback(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
549 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
550 {
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
551 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
552 }
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
553
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
554 // SDL ONLY
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
555 void GuiAdapter::SetMouseUpCallback(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
556 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
557 {
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
558 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
559 }
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
560
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
561 // SDL ONLY
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
562 void GuiAdapter::SetWheelCallback(
861
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
563 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
564 {
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
565 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
566 }
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
567
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
568 // SDL ONLY
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
569 void GuiAdapter::SetKeyDownCallback(
861
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
570 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
571 {
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
572 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
573 }
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
574
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
575 // SDL ONLY
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
576 void GuiAdapter::SetKeyUpCallback(
861
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
577 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
578 {
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
579 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
580 }
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
581
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
582 // SDL ONLY
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
583 void GuiAdapter::OnAnimationFrame()
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
584 {
947
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
585 std::vector<size_t> disabledAnimationHandlers;
845
cdba0dbb4682 removed some c++11 for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 843
diff changeset
586 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
587 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
588 // 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
589 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
590
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
591 // 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
592 // 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
593 if (!goOn)
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
594 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
595 }
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
596 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
597 {
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
598 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
599 animationFrameHandlers_.erase(animationFrameHandlers_.begin() + disabledAnimationHandlers[i]);
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
600 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
601 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
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 // SDL ONLY
1312
4f8c9065ee52 coping with both viewport and loader changes
Benjamin Golinvaux <bgo@osimis.io>
parents: 1300
diff changeset
604 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
605 {
845
cdba0dbb4682 removed some c++11 for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 843
diff changeset
606 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
607 {
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
608 (*(resizeHandlers_[i].func))(
1312
4f8c9065ee52 coping with both viewport and loader changes
Benjamin Golinvaux <bgo@osimis.io>
parents: 1300
diff changeset
609 resizeHandlers_[i].canvasName, nullptr, 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
610 }
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
611 }
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
612
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
613 // SDL ONLY
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
614 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
615 {
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
616
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
617 // 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
618 // is designed for Wasm
879
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
619 SDL_Window* sdlWindow = SDL_GetWindowFromID(windowID);
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
620 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
621
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
622 const char* windowTitleSz = SDL_GetWindowTitle(sdlWindow);
879
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
623 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
624
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
625 std::string windowTitle(windowTitleSz);
879
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
626 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
627
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
628 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
629 {
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
630 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
631 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
632 {
861
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
633 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
634 (*(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
635 }
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
636 break;
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
637 default:
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
638 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
639 break;
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
640 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
641 }
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
642
861
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
643
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
644 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
645 {
861
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
646 // 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
647 ORTHANC_ASSERT(event.sym[0] != 0);
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
648 ORTHANC_ASSERT(event.sym[1] == 0);
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
649
879
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
650 SDL_Window* sdlWindow = SDL_GetWindowFromID(windowID);
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
651 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
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 const char* windowTitleSz = SDL_GetWindowTitle(sdlWindow);
879
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
654 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
655
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
656 std::string windowTitle(windowTitleSz);
879
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
657 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
658
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
659 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
660 {
861
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
661 case GUIADAPTER_EVENT_KEYDOWN:
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
662 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
663 {
861
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
664 (*(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
665 }
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
666 break;
861
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
667 case GUIADAPTER_EVENT_KEYUP:
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
668 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
669 {
861
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
670 (*(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
671 }
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
672 break;
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
673 default:
861
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
674 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
675 break;
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
676 }
861
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
677 }
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
678
861
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
679 // SDL ONLY
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
680 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
681 {
880
Alain Mazy <alain@mazy.be>
parents: 879 869
diff changeset
682 if (windowID == 0)
Alain Mazy <alain@mazy.be>
parents: 879 869
diff changeset
683 {
Alain Mazy <alain@mazy.be>
parents: 879 869
diff changeset
684 LOG(WARNING) << "GuiAdapter::OnMouseEvent -- windowID == 0 and event won't be routed!";
Alain Mazy <alain@mazy.be>
parents: 879 869
diff changeset
685 }
Alain Mazy <alain@mazy.be>
parents: 879 869
diff changeset
686 else
Alain Mazy <alain@mazy.be>
parents: 879 869
diff changeset
687 {
861
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
688 // 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
689 // is designed for Wasm
880
Alain Mazy <alain@mazy.be>
parents: 879 869
diff changeset
690 SDL_Window* sdlWindow = SDL_GetWindowFromID(windowID);
Alain Mazy <alain@mazy.be>
parents: 879 869
diff changeset
691
Alain Mazy <alain@mazy.be>
parents: 879 869
diff changeset
692 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
693
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
694 const char* windowTitleSz = SDL_GetWindowTitle(sdlWindow);
880
Alain Mazy <alain@mazy.be>
parents: 879 869
diff changeset
695 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
696
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
697 std::string windowTitle(windowTitleSz);
880
Alain Mazy <alain@mazy.be>
parents: 879 869
diff changeset
698 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
699
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
700 switch (event.type)
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
701 {
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
702 case GUIADAPTER_EVENT_MOUSEDOWN:
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
703 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
704 {
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
705 if (mouseDownHandlers_[i].canvasName == windowTitle)
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
706 (*(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
707 }
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
708 break;
1020
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 947
diff changeset
709 case GUIADAPTER_EVENT_MOUSEDBLCLICK:
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 947
diff changeset
710 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
711 {
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 947
diff changeset
712 if (mouseDblCickHandlers_[i].canvasName == windowTitle)
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 947
diff changeset
713 (*(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
714 }
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 947
diff changeset
715 break;
861
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
716 case GUIADAPTER_EVENT_MOUSEMOVE:
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
717 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
718 {
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
719 if (mouseMoveHandlers_[i].canvasName == windowTitle)
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
720 (*(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
721 }
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
722 break;
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
723 case GUIADAPTER_EVENT_MOUSEUP:
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
724 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
725 {
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
726 if (mouseUpHandlers_[i].canvasName == windowTitle)
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
727 (*(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
728 }
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
729 break;
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
730 default:
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
731 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
732 break;
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
733 }
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
734
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
735 ////boost::shared_ptr<IGuiAdapterWidget> GetWidgetFromWindowId();
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
736 //boost::shared_ptr<IGuiAdapterWidget> foundWidget;
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
737 //VisitWidgets([foundWidget, windowID](auto widget)
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
738 // {
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
739 // if (widget->GetSdlWindowID() == windowID)
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
740 // foundWidget = widget;
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
741 // });
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
742 //ORTHANC_ASSERT(foundWidget, "WindowID " << windowID << " was not found in the registered widgets!");
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
743 //if(foundWidget)
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
744 // foundWidget->
880
Alain Mazy <alain@mazy.be>
parents: 879 869
diff changeset
745 }
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
746 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
747
947
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
748
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
749 // 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
750 // 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
751
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
752 // SDL ONLY
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
753 void GuiAdapter::RequestAnimationFrame(OnAnimationFrameFunc func, void* userData)
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
754 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
755 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
756 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
757
853
bb88686acecc fix OS X build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 845
diff changeset
758 # 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
759
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
760 // SDL ONLY
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
761 static void GLAPIENTRY
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
762 OpenGLMessageCallback(GLenum source,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
763 GLenum type,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
764 GLuint id,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
765 GLenum severity,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
766 GLsizei length,
861
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
767 const GLchar * message,
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
768 const void* userParam)
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
769 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
770 if (severity != GL_DEBUG_SEVERITY_NOTIFICATION)
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
771 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
772 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
773 (type == GL_DEBUG_TYPE_ERROR ? "** GL ERROR **" : ""),
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
774 type, severity, message);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
775 }
861
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
776 }
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
777 # endif
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
778
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
779 // 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
780 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
781 {
913
2b4b6b86520a Re-enabled gl debug output in GuiAdapter +
Benjamin Golinvaux <bgo@osimis.io>
parents: 906
diff changeset
782 #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
783 // TODO: MAKE THIS DYNAMIC !!! See SdlOpenGLViewport vs Cairo in ViewportWrapper
853
bb88686acecc fix OS X build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 845
diff changeset
784 # 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
785 glEnable(GL_DEBUG_OUTPUT);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
786 glDebugMessageCallback(OpenGLMessageCallback, 0);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
787 # 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
788 #endif
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
789
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
790 // Uint32 SDL_GetWindowID(SDL_Window* window)
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
791 // 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
792
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
793 bool stop = false;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
794 while (!stop)
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
795 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
796 {
1312
4f8c9065ee52 coping with both viewport and loader changes
Benjamin Golinvaux <bgo@osimis.io>
parents: 1300
diff changeset
797 // 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
798 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
799 (*func)(cookie);
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
800 OnAnimationFrame(); // in SDL we must call it
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
801 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
802
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
803 SDL_Event event;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
804
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
805 while (!stop && SDL_PollEvent(&event))
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
806 {
1312
4f8c9065ee52 coping with both viewport and loader changes
Benjamin Golinvaux <bgo@osimis.io>
parents: 1300
diff changeset
807 // TODO: lock all viewports here! (use a scoped object)
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
808
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
809 if (event.type == SDL_QUIT)
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
810 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
811 // TODO: call exit callbacks here
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
812 stop = true;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
813 break;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
814 }
861
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
815 else if ((event.type == SDL_MOUSEMOTION) ||
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
816 (event.type == SDL_MOUSEBUTTONDOWN) ||
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
817 (event.type == SDL_MOUSEBUTTONUP))
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
818 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
819 int scancodeCount = 0;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
820 const uint8_t* keyboardState = SDL_GetKeyboardState(&scancodeCount);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
821 bool ctrlPressed(false);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
822 bool shiftPressed(false);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
823 bool altPressed(false);
861
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
824
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
825 if (SDL_SCANCODE_LCTRL < scancodeCount && keyboardState[SDL_SCANCODE_LCTRL])
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
826 ctrlPressed = true;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
827 if (SDL_SCANCODE_RCTRL < scancodeCount && keyboardState[SDL_SCANCODE_RCTRL])
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
828 ctrlPressed = true;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
829 if (SDL_SCANCODE_LSHIFT < scancodeCount && keyboardState[SDL_SCANCODE_LSHIFT])
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
830 shiftPressed = true;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
831 if (SDL_SCANCODE_RSHIFT < scancodeCount && keyboardState[SDL_SCANCODE_RSHIFT])
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
832 shiftPressed = true;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
833 if (SDL_SCANCODE_LALT < scancodeCount && keyboardState[SDL_SCANCODE_LALT])
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
834 altPressed = true;
861
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
835
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
836 GuiAdapterMouseEvent dest;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
837 ConvertFromPlatform(dest, ctrlPressed, shiftPressed, altPressed, event);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
838 OnMouseEvent(event.window.windowID, dest);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
839 #if 0
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
840 // for reference, how to create trackers
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
841 if (tracker)
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
842 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
843 PointerEvent e;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
844 e.AddPosition(compositor.GetPixelCenterCoordinates(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
845 event.button.x, event.button.y));
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
846 tracker->PointerMove(e);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
847 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
848 #endif
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
849 }
879
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
850 else if (event.type == SDL_MOUSEWHEEL)
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
851 {
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
852
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
853 int scancodeCount = 0;
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
854 const uint8_t* keyboardState = SDL_GetKeyboardState(&scancodeCount);
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
855 bool ctrlPressed(false);
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
856 bool shiftPressed(false);
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
857 bool altPressed(false);
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
859 if (SDL_SCANCODE_LCTRL < scancodeCount && keyboardState[SDL_SCANCODE_LCTRL])
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
860 ctrlPressed = true;
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
861 if (SDL_SCANCODE_RCTRL < scancodeCount && keyboardState[SDL_SCANCODE_RCTRL])
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
862 ctrlPressed = true;
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
863 if (SDL_SCANCODE_LSHIFT < scancodeCount && keyboardState[SDL_SCANCODE_LSHIFT])
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
864 shiftPressed = true;
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
865 if (SDL_SCANCODE_RSHIFT < scancodeCount && keyboardState[SDL_SCANCODE_RSHIFT])
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
866 shiftPressed = true;
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
867 if (SDL_SCANCODE_LALT < scancodeCount && keyboardState[SDL_SCANCODE_LALT])
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
868 altPressed = true;
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
869
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
870 GuiAdapterWheelEvent dest;
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
871 ConvertFromPlatform(dest, ctrlPressed, shiftPressed, altPressed, event);
879
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
872 OnMouseWheelEvent(event.window.windowID, dest);
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
873
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
874 //KeyboardModifiers modifiers = GetKeyboardModifiers(keyboardState, scancodeCount);
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
875
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
876 //int x, y;
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
877 //SDL_GetMouseState(&x, &y);
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
878
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
879 //if (event.wheel.y > 0)
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
880 //{
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
881 // locker.GetCentralViewport().MouseWheel(MouseWheelDirection_Up, x, y, modifiers);
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
882 //}
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
883 //else if (event.wheel.y < 0)
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
884 //{
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
885 // locker.GetCentralViewport().MouseWheel(MouseWheelDirection_Down, x, y, modifiers);
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
886 //}
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
887 }
1312
4f8c9065ee52 coping with both viewport and loader changes
Benjamin Golinvaux <bgo@osimis.io>
parents: 1300
diff changeset
888 else if (event.type == SDL_WINDOWEVENT &&
4f8c9065ee52 coping with both viewport and loader changes
Benjamin Golinvaux <bgo@osimis.io>
parents: 1300
diff changeset
889 (event.window.event == SDL_WINDOWEVENT_RESIZED ||
4f8c9065ee52 coping with both viewport and loader changes
Benjamin Golinvaux <bgo@osimis.io>
parents: 1300
diff changeset
890 event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED))
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
891 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
892 #if 0
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
893 tracker.reset();
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
894 #endif
1312
4f8c9065ee52 coping with both viewport and loader changes
Benjamin Golinvaux <bgo@osimis.io>
parents: 1300
diff changeset
895 OnResize(event.window.data1, event.window.data2);
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
896 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
897 else if (event.type == SDL_KEYDOWN && event.key.repeat == 0 /* Ignore key bounce */)
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
898 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
899 switch (event.key.keysym.sym)
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 case SDLK_f:
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
902 // window.GetWindow().ToggleMaximize(); //TODO: move to particular handler
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
903 break;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
904
947
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
905 // This commented out code was used to debug the context
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
906 // loss/restoring code (2019-08-10)
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
907 // case SDLK_k:
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
908 // {
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
909 // SDL_Window* window = SDL_GetWindowFromID(event.window.windowID);
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
910 // std::string windowTitle(SDL_GetWindowTitle(window));
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
911 // Debug_SetContextToBeKilled(windowTitle);
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
912 // }
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
913 // break;
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
914 // case SDLK_l:
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
915 // {
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
916 // SDL_Window* window = SDL_GetWindowFromID(event.window.windowID);
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
917 // std::string windowTitle(SDL_GetWindowTitle(window));
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
918 // Debug_SetContextToBeRestored(windowTitle);
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
919 // }
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
920 // break;
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
921
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
922 case SDLK_q:
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
923 stop = true;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
924 break;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
925
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
926 default:
861
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
927 GuiAdapterKeyboardEvent dest;
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
928 ConvertFromPlatform(dest, event);
f0bf971a1e31 Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
929 OnKeyboardEvent(event.window.windowID, dest);
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
930 break;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
931 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
932 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
933 // HandleApplicationEvent(controller, compositor, event, tracker);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
934 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
935
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
936 SDL_Delay(1);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
937 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
938 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
939 #endif
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
940 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
941