annotate Applications/Generic/GuiAdapter.cpp @ 879:12b591d5d63c am-dev

some Qt integration (wip)
author Alain Mazy <alain@mazy.be>
date Fri, 05 Jul 2019 14:52:43 +0200
parents e3c56d4f863f
children 9953f16c304d
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
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium
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
853
bb88686acecc fix OS X build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 845
diff changeset
34 # include "../../Framework/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
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
37 namespace OrthancStone
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
38 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
39 void GuiAdapter::RegisterWidget(boost::shared_ptr<IGuiAdapterWidget> widget)
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
40 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
41 widgets_.push_back(widget);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
42 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
43
879
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
44 std::ostream& operator<<(
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
45 std::ostream& os, const GuiAdapterKeyboardEvent& event)
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
46 {
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
47 os << "ctrl: " << event.ctrlKey << ", " <<
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
48 "shift: " << event.shiftKey << ", " <<
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
49 "alt: " << event.altKey;
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
50 return os;
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
51 }
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
52
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
53 #if ORTHANC_ENABLE_WASM == 1
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
54 void GuiAdapter::Run()
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
55 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
56 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
57
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
58 void ConvertFromPlatform(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
59 GuiAdapterUiEvent& dest,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
60 int eventType,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
61 const EmscriptenUiEvent& src)
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 // no data for now
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
64 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
65
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
66 void ConvertFromPlatform(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
67 GuiAdapterMouseEvent& dest,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
68 int eventType,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
69 const EmscriptenMouseEvent& src)
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 memset(&dest, 0, sizeof(GuiAdapterMouseEvent));
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
72 switch (eventType)
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
73 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
74 case EMSCRIPTEN_EVENT_CLICK:
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
75 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
76 ORTHANC_ASSERT(false, "Not supported");
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
77 break;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
78 case EMSCRIPTEN_EVENT_MOUSEDOWN:
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
79 dest.type = GUIADAPTER_EVENT_MOUSEDOWN;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
80 break;
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
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
115 void ConvertFromPlatform(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
116 GuiAdapterWheelEvent& dest,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
117 int eventType,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
118 const EmscriptenWheelEvent& src)
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
119 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
120 ConvertFromPlatform(dest.mouse, eventType, src.mouse);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
121 dest.deltaX = src.deltaX;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
122 dest.deltaY = src.deltaY;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
123 switch (src.deltaMode)
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
124 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
125 case DOM_DELTA_PIXEL:
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
126 dest.deltaMode = GUIADAPTER_DELTA_PIXEL;
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_LINE:
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
129 dest.deltaMode = GUIADAPTER_DELTA_LINE;
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 case DOM_DELTA_PAGE:
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
132 dest.deltaMode = GUIADAPTER_DELTA_PAGE;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
133 break;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
134 default:
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
135 ORTHANC_ASSERT(false, "Unknown deltaMode: " << src.deltaMode <<
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
136 " in wheel event...");
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
137 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
138 dest.deltaMode = src.deltaMode;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
139 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
140
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
141 void ConvertFromPlatform(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
142 GuiAdapterKeyboardEvent& dest,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
143 const EmscriptenKeyboardEvent& src)
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
144 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
145 dest.ctrlKey = src.ctrlKey;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
146 dest.shiftKey = src.shiftKey;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
147 dest.altKey = src.altKey;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
148 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
149
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
150 template<typename GenericFunc>
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
151 struct FuncAdapterPayload
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
152 {
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
153 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
154 void* userData;
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
155 GenericFunc callback;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
156 };
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
157
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
158 template<typename GenericFunc,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
159 typename GuiAdapterEvent,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
160 typename EmscriptenEvent>
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
161 EM_BOOL OnEventAdapterFunc(
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
162 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
163 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
164
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
165 // userData is OnMouseWheelFuncAdapterPayload
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
166 FuncAdapterPayload<GenericFunc>* payload =
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
167 reinterpret_cast<FuncAdapterPayload<GenericFunc>*>(userData);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
168 // LOG(INFO) << "OnEventAdapterFunc";
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
169 // LOG(INFO) << "------------------";
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
170 // LOG(INFO) << "eventType: " << eventType << " wheelEvent: " <<
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
171 // (int)wheelEvent << " userData: " << userData <<
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
172 // " payload->userData: " << payload->userData;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
173
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
174 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
175 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
176 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
177 return static_cast<EM_BOOL>(ret);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
178 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
179
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
180 template<typename GenericFunc,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
181 typename GuiAdapterEvent,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
182 typename EmscriptenEvent>
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
183 EM_BOOL OnEventAdapterFunc2(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
184 int /*eventType*/, const EmscriptenEvent* wheelEvent, void* userData)
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
185 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
186 // userData is OnMouseWheelFuncAdapterPayload
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
187 FuncAdapterPayload<GenericFunc>* payload =
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
188 reinterpret_cast<FuncAdapterPayload<GenericFunc>*>(userData);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
189
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
190 GuiAdapterEvent guiEvent;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
191 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
192 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
193 return static_cast<EM_BOOL>(ret);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
194 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
195
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
196 template<typename GenericFunc>
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
197 EM_BOOL OnEventAdapterFunc3(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
198 double time, void* userData)
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
199 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
200 // userData is OnMouseWheelFuncAdapterPayload
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
201 FuncAdapterPayload<GenericFunc>* payload =
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
202 reinterpret_cast<FuncAdapterPayload<GenericFunc>*>(userData);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
203 //std::auto_ptr< FuncAdapterPayload<GenericFunc> > deleter(payload);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
204 bool ret = (*(payload->callback))(time, payload->userData);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
205 return static_cast<EM_BOOL>(ret);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
206 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
207
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
208 // 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
209 template<
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
210 typename GenericFunc,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
211 typename GuiAdapterEvent,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
212 typename EmscriptenEvent,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
213 typename EmscriptenSetCallbackFunc>
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
214 static void SetCallback(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
215 EmscriptenSetCallbackFunc emFunc,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
216 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
217 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
218 // 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
219 // here
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
220 FuncAdapterPayload<GenericFunc>* payload =
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
221 new FuncAdapterPayload<GenericFunc>();
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
222 std::auto_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
223 payload->canvasId = canvasId;
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
224 payload->callback = func;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
225 payload->userData = userData;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
226 void* userDataRaw = reinterpret_cast<void*>(payload);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
227 // LOG(INFO) << "SetCallback -- userDataRaw: " << userDataRaw <<
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
228 // " payload: " << payload << " payload->userData: " << payload->userData;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
229 (*emFunc)(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
230 canvasId.c_str(),
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
231 userDataRaw,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
232 static_cast<EM_BOOL>(capture),
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
233 &OnEventAdapterFunc<GenericFunc, GuiAdapterEvent, EmscriptenEvent>,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
234 EM_CALLBACK_THREAD_CONTEXT_CALLING_THREAD);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
235 payloadP.release();
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
236 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
237
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
238 template<
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
239 typename GenericFunc,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
240 typename GuiAdapterEvent,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
241 typename EmscriptenEvent,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
242 typename EmscriptenSetCallbackFunc>
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
243 static void SetCallback2(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
244 EmscriptenSetCallbackFunc emFunc,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
245 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
246 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
247 std::auto_ptr<FuncAdapterPayload<GenericFunc> > payload(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
248 new FuncAdapterPayload<GenericFunc>()
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
249 );
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
250 payload->canvasId = canvasId;
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
251 payload->callback = func;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
252 payload->userData = userData;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
253 void* userDataRaw = reinterpret_cast<void*>(payload.release());
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
254 (*emFunc)(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
255 canvasId.c_str(),
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
256 userDataRaw,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
257 static_cast<EM_BOOL>(capture),
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
258 &OnEventAdapterFunc2<GenericFunc, GuiAdapterEvent, EmscriptenEvent>,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
259 EM_CALLBACK_THREAD_CONTEXT_CALLING_THREAD);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
260 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
261
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
262 template<
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
263 typename GenericFunc,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
264 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
265 static void SetAnimationFrameCallback(
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
266 EmscriptenSetCallbackFunc emFunc,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
267 void* userData, GenericFunc func)
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
268 {
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
269 // LOG(ERROR) << "SetAnimationFrameCallback !!!!!! (RequestAnimationFrame)";
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
270 std::auto_ptr<FuncAdapterPayload<GenericFunc> > payload(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
271 new FuncAdapterPayload<GenericFunc>()
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
272 );
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
273 payload->canvasId = "UNDEFINED";
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
274 payload->callback = func;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
275 payload->userData = userData;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
276 void* userDataRaw = reinterpret_cast<void*>(payload.release());
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
277 (*emFunc)(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
278 &OnEventAdapterFunc3<GenericFunc>,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
279 userDataRaw);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
280 }
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 void GuiAdapter::SetWheelCallback(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
283 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
284 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
285 SetCallback<OnMouseWheelFunc, GuiAdapterWheelEvent, EmscriptenWheelEvent>(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
286 &emscripten_set_wheel_callback_on_thread,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
287 canvasId,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
288 userData,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
289 capture,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
290 func);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
291 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
292
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
293 void GuiAdapter::SetMouseDownCallback(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
294 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
295 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
296 SetCallback<OnMouseEventFunc, GuiAdapterMouseEvent, EmscriptenMouseEvent>(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
297 &emscripten_set_mousedown_callback_on_thread,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
298 canvasId,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
299 userData,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
300 capture,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
301 func);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
302 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
303
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
304 void GuiAdapter::SetMouseMoveCallback(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
305 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
306 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
307 // LOG(INFO) << "SetMouseMoveCallback -- " << "supplied userData: " <<
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
308 // userData;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
309
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
310 SetCallback<OnMouseEventFunc, GuiAdapterMouseEvent, EmscriptenMouseEvent>(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
311 &emscripten_set_mousemove_callback_on_thread,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
312 canvasId,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
313 userData,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
314 capture,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
315 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
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
318 void GuiAdapter::SetMouseUpCallback(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
319 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
320 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
321 SetCallback<OnMouseEventFunc, GuiAdapterMouseEvent, EmscriptenMouseEvent>(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
322 &emscripten_set_mouseup_callback_on_thread,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
323 canvasId,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
324 userData,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
325 capture,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
326 func);
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
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
329 void GuiAdapter::SetKeyDownCallback(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
330 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
331 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
332 SetCallback2<OnKeyDownFunc, GuiAdapterKeyboardEvent, EmscriptenKeyboardEvent>(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
333 &emscripten_set_keydown_callback_on_thread,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
334 canvasId,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
335 userData,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
336 capture,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
337 func);
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
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
340 void GuiAdapter::SetKeyUpCallback(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
341 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
342 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
343 SetCallback2<OnKeyUpFunc, GuiAdapterKeyboardEvent, EmscriptenKeyboardEvent>(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
344 &emscripten_set_keyup_callback_on_thread,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
345 canvasId,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
346 userData,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
347 capture,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
348 func);
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
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
351 void GuiAdapter::SetResizeCallback(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
352 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
353 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
354 SetCallback<OnWindowResizeFunc, GuiAdapterUiEvent, EmscriptenUiEvent>(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
355 &emscripten_set_resize_callback_on_thread,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
356 canvasId,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
357 userData,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
358 capture,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
359 func);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
360 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
361
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
362 void GuiAdapter::RequestAnimationFrame(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
363 OnAnimationFrameFunc func, void* userData)
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
364 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
365 // LOG(ERROR) << "-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+";
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
366 // LOG(ERROR) << "RequestAnimationFrame";
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
367 // 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
368 SetAnimationFrameCallback<OnAnimationFrameFunc>(
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
369 &emscripten_request_animation_frame_loop,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
370 userData,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
371 func);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
372 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
373
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
374 #if 0
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
375 void GuiAdapter::SetKeyDownCallback(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
376 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
377 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
378 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
379 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
380 void GuiAdapter::SetKeyUpCallback(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
381 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
382 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
383 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
384 }
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 void GuiAdapter::SetResizeCallback(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
387 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
388 emscripten_set_resize_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
389 }
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 void GuiAdapter::RequestAnimationFrame(OnAnimationFrameFunc func, void* userData)
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 emscripten_request_animation_frame_loop(func, userData);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
394 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
395 #endif
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
396
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
397
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
398 #else
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
399
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
400 // SDL ONLY
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
401 void ConvertFromPlatform(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
402 GuiAdapterMouseEvent& dest,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
403 bool ctrlPressed, bool shiftPressed, bool altPressed,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
404 const SDL_Event& source)
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
405 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
406 memset(&dest, 0, sizeof(GuiAdapterMouseEvent));
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
407 switch (source.type)
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 case SDL_MOUSEBUTTONDOWN:
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
410 dest.type = GUIADAPTER_EVENT_MOUSEDOWN;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
411 break;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
412 case SDL_MOUSEMOTION:
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
413 dest.type = GUIADAPTER_EVENT_MOUSEMOVE;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
414 break;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
415 case SDL_MOUSEBUTTONUP:
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
416 dest.type = GUIADAPTER_EVENT_MOUSEUP;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
417 break;
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
418 case SDL_MOUSEWHEEL:
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
419 dest.type = 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
420 break;
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
421 default:
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
422 LOG(ERROR) << "SDL event: " << source.type << " is not supported";
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
423 ORTHANC_ASSERT(false, "Not supported");
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
424 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
425 //dest.timestamp = src.timestamp;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
426 //dest.screenX = src.screenX;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
427 //dest.screenY = src.screenY;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
428 //dest.clientX = src.clientX;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
429 //dest.clientY = src.clientY;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
430 dest.ctrlKey = ctrlPressed;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
431 dest.shiftKey = shiftPressed;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
432 dest.altKey = altPressed;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
433 //dest.metaKey = src.metaKey;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
434 switch (source.button.button)
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
435 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
436 case SDL_BUTTON_MIDDLE:
879
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
437 dest.button = GUIADAPTER_MOUSEBUTTON_MIDDLE;
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
438 break;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
439
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
440 case SDL_BUTTON_RIGHT:
879
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
441 dest.button = GUIADAPTER_MOUSEBUTTON_RIGHT;
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
442 break;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
443
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
444 case SDL_BUTTON_LEFT:
879
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
445 dest.button = GUIADAPTER_MOUSEBUTTON_LEFT;
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
446 break;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
447
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
448 default:
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
449 break;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
450 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
451 //dest.buttons = src.buttons;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
452 //dest.movementX = src.movementX;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
453 //dest.movementY = src.movementY;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
454 dest.targetX = source.button.x;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
455 dest.targetY = source.button.y;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
456 //dest.canvasX = src.canvasX;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
457 //dest.canvasY = src.canvasY;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
458 //dest.padding = src.padding;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
459 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
460
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
461 void ConvertFromPlatform(
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
462 GuiAdapterWheelEvent& dest,
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
463 bool ctrlPressed, bool shiftPressed, bool altPressed,
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
464 const SDL_Event& source)
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
465 {
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
466 ConvertFromPlatform(dest.mouse, ctrlPressed, shiftPressed, altPressed, source);
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
467 dest.deltaX = source.wheel.x;
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
468 dest.deltaY = source.wheel.y;
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
469 }
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
470
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
471
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
472
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
473 // SDL ONLY
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
474 void GuiAdapter::SetResizeCallback(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
475 std::string canvasId, void* userData, bool capture, OnWindowResizeFunc func)
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
476 {
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
477 resizeHandlers_.push_back(EventHandlerData<OnWindowResizeFunc>(canvasId, func, userData));
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
478 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
479
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
480 // SDL ONLY
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
481 void GuiAdapter::SetMouseDownCallback(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
482 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
483 {
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
484 mouseDownHandlers_.push_back(EventHandlerData<OnMouseEventFunc>(canvasId, func, userData));
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
485 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
486
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
487 // SDL ONLY
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
488 void GuiAdapter::SetMouseMoveCallback(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
489 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
490 {
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
491 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
492 }
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
493
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
494 // SDL ONLY
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
495 void GuiAdapter::SetMouseUpCallback(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
496 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
497 {
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
498 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
499 }
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
500
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
501 // SDL ONLY
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
502 void GuiAdapter::SetWheelCallback(
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
503 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
504 {
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
505 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
506 }
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
507
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
508 // SDL ONLY
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
509 void GuiAdapter::SetKeyDownCallback(
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
510 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
511 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
512 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
513
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
514 // SDL ONLY
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
515 void GuiAdapter::SetKeyUpCallback(
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
516 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
517 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
518 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
519
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
520
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
521 // SDL ONLY
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
522 void GuiAdapter::OnAnimationFrame()
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
523 {
845
cdba0dbb4682 removed some c++11 for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 843
diff changeset
524 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
525 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
526 // TODO: fix time
845
cdba0dbb4682 removed some c++11 for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 843
diff changeset
527 (*(animationFrameHandlers_[i].first))(0, animationFrameHandlers_[i].second);
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
528 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
529 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
530
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
531 // SDL ONLY
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
532 void GuiAdapter::OnResize()
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
533 {
845
cdba0dbb4682 removed some c++11 for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 843
diff changeset
534 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
535 {
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
536 (*(resizeHandlers_[i].func))(
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
537 resizeHandlers_[i].canvasName, 0, resizeHandlers_[i].userData);
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
538 }
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
539 }
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
540
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
541 // SDL ONLY
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
542 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
543 {
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
544
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
545 // 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
546 // is designed for Wasm
879
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
547 SDL_Window* sdlWindow = SDL_GetWindowFromID(windowID);
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
548 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
549
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
550 const char* windowTitleSz = SDL_GetWindowTitle(sdlWindow);
879
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
551 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
552
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
553 std::string windowTitle(windowTitleSz);
879
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
554 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
555
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
556 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
557 {
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
558 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
559 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
560 {
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
561 if(mouseWheelHandlers_[i].canvasName == windowTitle)
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
562 (*(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
563 }
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
564 break;
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
565 default:
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
566 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
567 break;
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
568 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
569 }
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
570
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
571 // SDL ONLY
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
572 void GuiAdapter::OnMouseEvent(uint32_t windowID, const GuiAdapterMouseEvent& event)
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
573 {
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
574 // 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
575 // is designed for Wasm
879
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
576 SDL_Window* sdlWindow = SDL_GetWindowFromID(windowID);
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
577 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
578
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
579 const char* windowTitleSz = SDL_GetWindowTitle(sdlWindow);
879
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
580 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
581
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
582 std::string windowTitle(windowTitleSz);
879
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
583 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
584
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
585 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
586 {
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
587 case GUIADAPTER_EVENT_MOUSEDOWN:
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
588 for (size_t i = 0; i < mouseDownHandlers_.size(); i++)
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
589 {
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
590 if (mouseDownHandlers_[i].canvasName == windowTitle)
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
591 (*(mouseDownHandlers_[i].func))(windowTitle, &event, mouseDownHandlers_[i].userData);
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
592 }
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
593 break;
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
594 case GUIADAPTER_EVENT_MOUSEMOVE:
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
595 for (size_t i = 0; i < mouseMoveHandlers_.size(); i++)
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
596 {
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
597 if (mouseMoveHandlers_[i].canvasName == windowTitle)
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
598 (*(mouseMoveHandlers_[i].func))(windowTitle, &event, mouseMoveHandlers_[i].userData);
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
599 }
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
600 break;
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
601 case GUIADAPTER_EVENT_MOUSEUP:
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
602 for (size_t i = 0; i < mouseUpHandlers_.size(); i++)
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
603 {
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
604 if (mouseUpHandlers_[i].canvasName == windowTitle)
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
605 (*(mouseUpHandlers_[i].func))(windowTitle, &event, mouseUpHandlers_[i].userData);
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
606 }
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
607 break;
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
608 default:
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
609 ORTHANC_ASSERT(false, "Wrong event.type: " << event.type << " in GuiAdapter::OnMouseEvent(...)");
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
610 break;
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 ////boost::shared_ptr<IGuiAdapterWidget> GetWidgetFromWindowId();
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
614 //boost::shared_ptr<IGuiAdapterWidget> foundWidget;
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
615 //VisitWidgets([foundWidget, windowID](auto widget)
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 // if (widget->GetSdlWindowID() == windowID)
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
618 // foundWidget = widget;
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
619 // });
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
620 //ORTHANC_ASSERT(foundWidget, "WindowID " << windowID << " was not found in the registered widgets!");
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
621 //if(foundWidget)
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
622 // foundWidget->
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
623 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
624
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
625 // SDL ONLY
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
626 void GuiAdapter::RequestAnimationFrame(OnAnimationFrameFunc func, void* userData)
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
627 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
628 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
629 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
630
853
bb88686acecc fix OS X build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 845
diff changeset
631 # 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
632
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
633 // SDL ONLY
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
634 static void GLAPIENTRY
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
635 OpenGLMessageCallback(GLenum source,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
636 GLenum type,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
637 GLuint id,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
638 GLenum severity,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
639 GLsizei length,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
640 const GLchar* message,
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
641 const void* userParam)
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
642 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
643 if (severity != GL_DEBUG_SEVERITY_NOTIFICATION)
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
644 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
645 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
646 (type == GL_DEBUG_TYPE_ERROR ? "** GL ERROR **" : ""),
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
647 type, severity, message);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
648 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
649 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
650 # endif
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
651
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
652 // SDL ONLY
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
653 void GuiAdapter::Run()
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
654 {
853
bb88686acecc fix OS X build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 845
diff changeset
655 # 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
656 glEnable(GL_DEBUG_OUTPUT);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
657 glDebugMessageCallback(OpenGLMessageCallback, 0);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
658 # endif
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
659
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
660 // Uint32 SDL_GetWindowID(SDL_Window* window)
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
661 // 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
662
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
663 bool stop = false;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
664 while (!stop)
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
665 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
666 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
667 LockingEmitter::WriterLock lock(lockingEmitter_);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
668 OnAnimationFrame(); // in SDL we must call it
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
669 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
670
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
671 SDL_Event event;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
672
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
673 while (!stop && SDL_PollEvent(&event))
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
674 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
675 LockingEmitter::WriterLock lock(lockingEmitter_);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
676
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
677 if (event.type == SDL_QUIT)
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
678 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
679 // TODO: call exit callbacks here
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
680 stop = true;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
681 break;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
682 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
683 else if ( (event.type == SDL_MOUSEMOTION) ||
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
684 (event.type == SDL_MOUSEBUTTONDOWN) ||
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
685 (event.type == SDL_MOUSEBUTTONUP) )
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
686 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
687 int scancodeCount = 0;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
688 const uint8_t* keyboardState = SDL_GetKeyboardState(&scancodeCount);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
689 bool ctrlPressed(false);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
690 bool shiftPressed(false);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
691 bool altPressed(false);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
692
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
693 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
694 ctrlPressed = true;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
695 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
696 ctrlPressed = true;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
697 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
698 shiftPressed = true;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
699 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
700 shiftPressed = true;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
701 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
702 altPressed = true;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
703
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
704 GuiAdapterMouseEvent dest;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
705 ConvertFromPlatform(dest, ctrlPressed, shiftPressed, altPressed, event);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
706 OnMouseEvent(event.window.windowID, dest);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
707 #if 0
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
708 // for reference, how to create trackers
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
709 if (tracker)
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
710 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
711 PointerEvent e;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
712 e.AddPosition(compositor.GetPixelCenterCoordinates(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
713 event.button.x, event.button.y));
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
714 tracker->PointerMove(e);
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
715 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
716 #endif
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
717 }
879
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
718 else if (event.type == SDL_MOUSEWHEEL)
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
719 {
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
720
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
721 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
722 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
723 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
724 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
725 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
726
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
727 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
728 ctrlPressed = true;
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
729 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
730 ctrlPressed = true;
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
731 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
732 shiftPressed = true;
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
733 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
734 shiftPressed = true;
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
735 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
736 altPressed = true;
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
737
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
738 GuiAdapterWheelEvent dest;
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
739 ConvertFromPlatform(dest, ctrlPressed, shiftPressed, altPressed, event);
879
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
740 OnMouseWheelEvent(event.window.windowID, dest);
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
741
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
742 //KeyboardModifiers modifiers = GetKeyboardModifiers(keyboardState, scancodeCount);
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
743
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
744 //int x, y;
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
745 //SDL_GetMouseState(&x, &y);
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
746
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
747 //if (event.wheel.y > 0)
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
748 //{
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
749 // locker.GetCentralViewport().MouseWheel(MouseWheelDirection_Up, x, y, modifiers);
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
750 //}
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
751 //else if (event.wheel.y < 0)
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
752 //{
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
753 // locker.GetCentralViewport().MouseWheel(MouseWheelDirection_Down, x, y, modifiers);
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents: 858
diff changeset
754 //}
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 853
diff changeset
755 }
843
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
756 else if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED)
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
757 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
758 #if 0
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
759 tracker.reset();
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
760 #endif
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
761 OnResize();
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
762 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
763 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
764 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
765 switch (event.key.keysym.sym)
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
766 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
767 case SDLK_f:
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
768 // 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
769 break;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
770
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
771 case SDLK_s:
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
772 #if 0
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
773 // TODO: re-enable at application-level!!!!
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
774 VisitWidgets(
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
775 [](auto value)
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
776 {
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
777 auto widget = boost::dynamic_pointer_cast<VolumeSlicerWidget()
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
778 value->FitContent();
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
779 });
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
780 #endif
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
781 break;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
782
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
783 case SDLK_q:
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
784 stop = true;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
785 break;
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
786
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
787 default:
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
788 break;
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 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
791 // HandleApplicationEvent(controller, compositor, event, tracker);
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
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
794 SDL_Delay(1);
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 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
797 #endif
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
798 }
67f9c27214c5 Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
799