Mercurial > hg > orthanc-stone
annotate Applications/Generic/GuiAdapter.h @ 1192:91d86144fb79
fix build
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 27 Nov 2019 14:16:20 +0100 |
parents | ac88989817e3 |
children | 4383382db01d 2d8ab34c8c91 |
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 **/ |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
850
diff
changeset
|
20 #pragma once |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
850
diff
changeset
|
21 |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
22 #include <string> |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
23 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
24 #if ORTHANC_ENABLE_WASM != 1 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
25 # ifdef __EMSCRIPTEN__ |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
26 # error __EMSCRIPTEN__ is defined and ORTHANC_ENABLE_WASM != 1 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
27 # endif |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
28 #endif |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
29 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
30 #if ORTHANC_ENABLE_WASM == 1 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
31 # ifndef __EMSCRIPTEN__ |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
32 # error __EMSCRIPTEN__ is not defined and ORTHANC_ENABLE_WASM == 1 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
33 # endif |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
34 #endif |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
35 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
36 #if ORTHANC_ENABLE_WASM == 1 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
37 # include <emscripten/html5.h> |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
38 #else |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
39 # if ORTHANC_ENABLE_SDL == 1 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
40 # include <SDL.h> |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
41 # endif |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
42 #endif |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
43 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
44 #include "../../Framework/StoneException.h" |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
45 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
46 #if ORTHANC_ENABLE_THREADS != 1 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
47 # include "../../Framework/Messages/LockingEmitter.h" |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
48 #endif |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
49 |
845
cdba0dbb4682
removed some c++11 for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
843
diff
changeset
|
50 #include <vector> |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
51 #include <boost/shared_ptr.hpp> |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
52 #include <boost/weak_ptr.hpp> |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
53 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
54 namespace OrthancStone |
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 This interface is used to store the widgets that are controlled by the |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
59 GuiAdapter and receive event callbacks. |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
60 The callbacks may possibly be downcast (using dynamic_cast, for safety) \ |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
61 to the actual widget type |
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 class IGuiAdapterWidget |
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 public: |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
66 virtual ~IGuiAdapterWidget() {} |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
850
diff
changeset
|
67 |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
68 }; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
69 |
879 | 70 enum GuiAdapterMouseButtonType |
71 { | |
72 GUIADAPTER_MOUSEBUTTON_LEFT = 0, | |
73 GUIADAPTER_MOUSEBUTTON_MIDDLE = 1, | |
74 GUIADAPTER_MOUSEBUTTON_RIGHT = 2 | |
75 }; | |
76 | |
77 | |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
78 enum GuiAdapterHidEventType |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
79 { |
1020
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
937
diff
changeset
|
80 GUIADAPTER_EVENT_MOUSEDOWN = 1973, |
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
937
diff
changeset
|
81 GUIADAPTER_EVENT_MOUSEMOVE = 1974, |
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
937
diff
changeset
|
82 GUIADAPTER_EVENT_MOUSEDBLCLICK = 1975, |
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
937
diff
changeset
|
83 GUIADAPTER_EVENT_MOUSEUP = 1976, |
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
937
diff
changeset
|
84 GUIADAPTER_EVENT_WHEEL = 1977, |
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
937
diff
changeset
|
85 GUIADAPTER_EVENT_KEYDOWN = 1978, |
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
937
diff
changeset
|
86 GUIADAPTER_EVENT_KEYUP = 1979, |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
87 }; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
88 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
89 const unsigned int GUIADAPTER_DELTA_PIXEL = 2973; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
90 const unsigned int GUIADAPTER_DELTA_LINE = 2974; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
91 const unsigned int GUIADAPTER_DELTA_PAGE = 2975; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
92 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
93 struct GuiAdapterUiEvent; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
94 struct GuiAdapterMouseEvent; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
95 struct GuiAdapterWheelEvent; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
96 struct GuiAdapterKeyboardEvent; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
97 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
98 class LockingEmitter; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
99 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
100 #if 1 |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
850
diff
changeset
|
101 typedef bool (*OnMouseEventFunc)(std::string canvasId, const GuiAdapterMouseEvent* mouseEvent, void* userData); |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
850
diff
changeset
|
102 typedef bool (*OnMouseWheelFunc)(std::string canvasId, const GuiAdapterWheelEvent* wheelEvent, void* userData); |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
850
diff
changeset
|
103 typedef bool (*OnKeyDownFunc) (std::string canvasId, const GuiAdapterKeyboardEvent* keyEvent, void* userData); |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
850
diff
changeset
|
104 typedef bool (*OnKeyUpFunc) (std::string canvasId, const GuiAdapterKeyboardEvent* keyEvent, void* userData); |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
105 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
106 typedef bool (*OnAnimationFrameFunc)(double time, void* userData); |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
850
diff
changeset
|
107 typedef bool (*OnWindowResizeFunc)(std::string canvasId, const GuiAdapterUiEvent* uiEvent, void* userData); |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
108 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
109 #else |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
110 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
111 #if ORTHANC_ENABLE_WASM == 1 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
112 typedef EM_BOOL (*OnMouseEventFunc)(int eventType, const EmscriptenMouseEvent* mouseEvent, void* userData); |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
113 typedef EM_BOOL (*OnMouseWheelFunc)(int eventType, const EmscriptenWheelEvent* wheelEvent, void* userData); |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
114 typedef EM_BOOL (*OnKeyDownFunc) (int eventType, const EmscriptenKeyboardEvent* keyEvent, void* userData); |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
115 typedef EM_BOOL (*OnKeyUpFunc) (int eventType, const EmscriptenKeyboardEvent* keyEvent, void* userData); |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
116 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
117 typedef EM_BOOL (*OnAnimationFrameFunc)(double time, void* userData); |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
118 typedef EM_BOOL (*OnWindowResizeFunc)(int eventType, const EmscriptenUiEvent* uiEvent, void* userData); |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
119 #else |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
120 typedef bool (*OnMouseEventFunc)(int eventType, const SDL_Event* mouseEvent, void* userData); |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
121 typedef bool (*OnMouseWheelFunc)(int eventType, const SDL_Event* wheelEvent, void* userData); |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
122 typedef bool (*OnKeyDownFunc) (int eventType, const SDL_Event* keyEvent, void* userData); |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
123 typedef bool (*OnKeyUpFunc) (int eventType, const SDL_Event* keyEvent, void* userData); |
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 typedef bool (*OnAnimationFrameFunc)(double time, void* userData); |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
126 typedef bool (*OnWindowResizeFunc)(int eventType, const GuiAdapterUiEvent* uiEvent, void* userData); |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
127 #endif |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
128 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
129 #endif |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
130 struct GuiAdapterMouseEvent |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
131 { |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
132 GuiAdapterHidEventType type; |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
133 //double timestamp; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
134 //long screenX; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
135 //long screenY; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
136 //long clientX; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
137 //long clientY; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
138 bool ctrlKey; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
139 bool shiftKey; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
140 bool altKey; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
141 //bool metaKey; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
142 unsigned short button; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
143 //unsigned short buttons; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
144 //long movementX; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
145 //long movementY; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
146 long targetX; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
147 long targetY; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
148 // canvasX and canvasY are deprecated - there no longer exists a Module['canvas'] object, so canvasX/Y are no longer reported (register a listener on canvas directly to get canvas coordinates, or translate manually) |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
149 //long canvasX; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
150 //long canvasY; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
151 //long padding; |
879 | 152 |
153 public: | |
154 GuiAdapterMouseEvent() | |
155 : ctrlKey(false), | |
156 shiftKey(false), | |
157 altKey(false) | |
158 { | |
159 } | |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
160 }; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
161 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
162 struct GuiAdapterWheelEvent { |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
163 GuiAdapterMouseEvent mouse; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
164 double deltaX; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
165 double deltaY; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
166 unsigned long deltaMode; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
167 }; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
168 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
169 // we don't use any data now |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
170 struct GuiAdapterUiEvent {}; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
171 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
172 // EmscriptenKeyboardEvent |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
173 struct GuiAdapterKeyboardEvent |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
174 { |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
175 GuiAdapterHidEventType type; |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
176 char sym[32]; |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
177 bool ctrlKey; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
178 bool shiftKey; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
179 bool altKey; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
180 }; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
181 |
879 | 182 std::ostream& operator<<(std::ostream& os, const GuiAdapterKeyboardEvent& event); |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
850
diff
changeset
|
183 |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
184 /* |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
185 Mousedown event trigger when either the left or right (or middle) mouse is pressed |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
186 on the object; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
187 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
188 Mouseup event trigger when either the left or right (or middle) mouse is released |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
189 above the object after triggered mousedown event and held. |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
190 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
191 Click event trigger when the only left mouse button is pressed and released on the |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
192 same object, requires the Mousedown and Mouseup event happened before Click event. |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
193 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
194 The normal expect trigger order: onMousedown >> onMouseup >> onClick |
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 Testing in Chrome v58, the time between onMouseup and onClick events are around |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
197 7ms to 15ms |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
198 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
199 FROM: https://codingrepo.com/javascript/2017/05/19/javascript-difference-mousedown-mouseup-click-events/ |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
200 */ |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
201 #if ORTHANC_ENABLE_WASM == 1 |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
202 void ConvertFromPlatform(GuiAdapterUiEvent& dest, int eventType, const EmscriptenUiEvent& src); |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
203 |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
204 void ConvertFromPlatform(GuiAdapterMouseEvent& dest, int eventType, const EmscriptenMouseEvent& src); |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
205 |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
206 void ConvertFromPlatform(GuiAdapterWheelEvent& dest, int eventType, const EmscriptenWheelEvent& src); |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
207 |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
208 void ConvertFromPlatform(GuiAdapterKeyboardEvent& dest, const EmscriptenKeyboardEvent& src); |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
209 #else |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
210 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
211 # if ORTHANC_ENABLE_SDL == 1 |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
212 void ConvertFromPlatform(GuiAdapterMouseEvent& dest, bool ctrlPressed, bool shiftPressed, bool altPressed, const SDL_Event& source); |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
850
diff
changeset
|
213 |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
214 void ConvertFromPlatform(GuiAdapterWheelEvent& dest, bool ctrlPressed, bool shiftPressed, bool altPressed, const SDL_Event& source); |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
215 |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
216 void ConvertFromPlatform(GuiAdapterKeyboardEvent& dest, const SDL_Event& source); |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
850
diff
changeset
|
217 |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
218 # endif |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
219 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
220 #endif |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
221 |
937
86ac61a040c9
Added getters and notifications to allow clients of the loaders (DicomStructureSetLoader, OrthancSeriesVolumeProgressiveLoader and OrthancMultiframeVolumeLoader) to know when the loading is finished + added ability for SDL event loop to execute a callback repeatedly (used to check the view loading state)
Benjamin Golinvaux <bgo@osimis.io>
parents:
935
diff
changeset
|
222 typedef void (*GuiAdapterRunFunc)(void*); |
86ac61a040c9
Added getters and notifications to allow clients of the loaders (DicomStructureSetLoader, OrthancSeriesVolumeProgressiveLoader and OrthancMultiframeVolumeLoader) to know when the loading is finished + added ability for SDL event loop to execute a callback repeatedly (used to check the view loading state)
Benjamin Golinvaux <bgo@osimis.io>
parents:
935
diff
changeset
|
223 |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
224 class GuiAdapter |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
225 { |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
226 public: |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
227 #if ORTHANC_ENABLE_THREADS == 1 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
228 GuiAdapter(LockingEmitter& lockingEmitter) : lockingEmitter_(lockingEmitter) |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
229 #else |
850
df0c73ee7afa
Prevent creation of multiple GuiAdapter instances
Benjamin Golinvaux <bgo@osimis.io>
parents:
845
diff
changeset
|
230 GuiAdapter() |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
231 #endif |
850
df0c73ee7afa
Prevent creation of multiple GuiAdapter instances
Benjamin Golinvaux <bgo@osimis.io>
parents:
845
diff
changeset
|
232 { |
df0c73ee7afa
Prevent creation of multiple GuiAdapter instances
Benjamin Golinvaux <bgo@osimis.io>
parents:
845
diff
changeset
|
233 static int instanceCount = 0; |
df0c73ee7afa
Prevent creation of multiple GuiAdapter instances
Benjamin Golinvaux <bgo@osimis.io>
parents:
845
diff
changeset
|
234 ORTHANC_ASSERT(instanceCount == 0); |
df0c73ee7afa
Prevent creation of multiple GuiAdapter instances
Benjamin Golinvaux <bgo@osimis.io>
parents:
845
diff
changeset
|
235 instanceCount = 1; |
df0c73ee7afa
Prevent creation of multiple GuiAdapter instances
Benjamin Golinvaux <bgo@osimis.io>
parents:
845
diff
changeset
|
236 } |
843
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 void RegisterWidget(boost::shared_ptr<IGuiAdapterWidget> widget); |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
239 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
240 /** |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
241 emscripten_set_resize_callback("#window", NULL, false, OnWindowResize); |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
242 |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
850
diff
changeset
|
243 emscripten_set_wheel_callback("mycanvas1", widget1_.get(), false, OnXXXMouseWheel); |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
850
diff
changeset
|
244 emscripten_set_wheel_callback("mycanvas2", widget2_.get(), false, OnXXXMouseWheel); |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
850
diff
changeset
|
245 emscripten_set_wheel_callback("mycanvas3", widget3_.get(), false, OnXXXMouseWheel); |
843
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 emscripten_set_keydown_callback("#window", NULL, false, OnKeyDown); |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
248 emscripten_set_keyup_callback("#window", NULL, false, OnKeyUp); |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
249 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
250 emscripten_request_animation_frame_loop(OnAnimationFrame, NULL); |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
251 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
252 SDL: |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
253 see https://wiki.libsdl.org/SDL_CaptureMouse |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
254 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
255 */ |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
256 |
1020
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
937
diff
changeset
|
257 void SetMouseDownCallback (std::string canvasId, void* userData, bool capture, OnMouseEventFunc func); |
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
937
diff
changeset
|
258 void SetMouseDblClickCallback (std::string canvasId, void* userData, bool capture, OnMouseEventFunc func); |
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
937
diff
changeset
|
259 void SetMouseMoveCallback (std::string canvasId, void* userData, bool capture, OnMouseEventFunc func); |
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
937
diff
changeset
|
260 void SetMouseUpCallback (std::string canvasId, void* userData, bool capture, OnMouseEventFunc func); |
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
937
diff
changeset
|
261 void SetWheelCallback (std::string canvasId, void* userData, bool capture, OnMouseWheelFunc func); |
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
937
diff
changeset
|
262 void SetKeyDownCallback (std::string canvasId, void* userData, bool capture, OnKeyDownFunc func); |
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
937
diff
changeset
|
263 void SetKeyUpCallback (std::string canvasId, void* userData, bool capture, OnKeyUpFunc func); |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
264 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
265 // if you pass "#window", under SDL, then any Window resize will trigger the callback |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
266 void 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
|
267 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
268 void RequestAnimationFrame(OnAnimationFrameFunc func, void* userData); |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
269 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
270 // TODO: implement and call to remove canvases [in SDL, although code should be generic] |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
271 void SetOnExitCallback(); |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
272 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
273 // void |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
274 // OnWindowResize |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
275 // oracle |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
276 // broker |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
277 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
278 /** |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
279 Under SDL, this function does NOT return until all windows have been closed. |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
280 Under wasm, it returns without doing anything, since the event loop is managed |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
281 by the browser. |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
282 */ |
937
86ac61a040c9
Added getters and notifications to allow clients of the loaders (DicomStructureSetLoader, OrthancSeriesVolumeProgressiveLoader and OrthancMultiframeVolumeLoader) to know when the loading is finished + added ability for SDL event loop to execute a callback repeatedly (used to check the view loading state)
Benjamin Golinvaux <bgo@osimis.io>
parents:
935
diff
changeset
|
283 void Run(GuiAdapterRunFunc func = NULL, void* cookie = NULL); |
843
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 #if ORTHANC_ENABLE_WASM != 1 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
286 /** |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
287 This method must be called in order for callback handler to be allowed to |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
288 be registered. |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
289 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
290 We'll retrieve its name and use it as the canvas name in all subsequent |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
291 calls |
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 RegisterSdlWindow(SDL_Window* window); |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
294 //void UnregisterSdlWindow(SDL_Window* window); |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
295 #endif |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
296 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
297 private: |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
298 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
299 #if ORTHANC_ENABLE_THREADS == 1 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
300 /** |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
301 This object is used by the multithreaded Oracle to serialize access to |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
302 shared data. We need to use it as soon as we access the state. |
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 LockingEmitter& lockingEmitter_; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
305 #endif |
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 /** |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
308 In SDL, this executes all the registered headers |
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 void OnAnimationFrame(); |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
311 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
312 //void RequestAnimationFrame(OnAnimationFrameFunc func, void* userData); |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
313 std::vector<std::pair<OnAnimationFrameFunc, void*> > |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
314 animationFrameHandlers_; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
315 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
316 void OnResize(); |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
317 |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
850
diff
changeset
|
318 #if ORTHANC_ENABLE_SDL == 1 |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
850
diff
changeset
|
319 template<typename Func> |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
850
diff
changeset
|
320 struct EventHandlerData |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
850
diff
changeset
|
321 { |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
850
diff
changeset
|
322 EventHandlerData(std::string canvasName, Func func, void* userData) |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
850
diff
changeset
|
323 : canvasName(canvasName) |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
850
diff
changeset
|
324 , func(func) |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
850
diff
changeset
|
325 , userData(userData) |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
850
diff
changeset
|
326 { |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
850
diff
changeset
|
327 } |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
850
diff
changeset
|
328 |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
850
diff
changeset
|
329 std::string canvasName; |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
850
diff
changeset
|
330 Func func; |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
850
diff
changeset
|
331 void* userData; |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
850
diff
changeset
|
332 }; |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
850
diff
changeset
|
333 std::vector<EventHandlerData<OnWindowResizeFunc> > resizeHandlers_; |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
850
diff
changeset
|
334 std::vector<EventHandlerData<OnMouseEventFunc > > mouseDownHandlers_; |
1020
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
937
diff
changeset
|
335 std::vector<EventHandlerData<OnMouseEventFunc > > mouseDblCickHandlers_; |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
850
diff
changeset
|
336 std::vector<EventHandlerData<OnMouseEventFunc > > mouseMoveHandlers_; |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
850
diff
changeset
|
337 std::vector<EventHandlerData<OnMouseEventFunc > > mouseUpHandlers_; |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
850
diff
changeset
|
338 std::vector<EventHandlerData<OnMouseWheelFunc > > mouseWheelHandlers_; |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
339 std::vector<EventHandlerData<OnKeyDownFunc > > keyDownHandlers_; |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
340 std::vector<EventHandlerData<OnKeyUpFunc > > keyUpHandlers_; |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
341 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
342 /** |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
343 This executes all the registered headers if needed (in wasm, the browser |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
344 deals with this) |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
345 */ |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
346 void OnMouseEvent(uint32_t windowID, const GuiAdapterMouseEvent& event); |
861
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
347 |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
348 void OnKeyboardEvent(uint32_t windowID, const GuiAdapterKeyboardEvent& event); |
f0bf971a1e31
Keyboard event routing (handling done in app)
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
349 |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
850
diff
changeset
|
350 /** |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
850
diff
changeset
|
351 Same remark as OnMouseEvent |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
850
diff
changeset
|
352 */ |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
850
diff
changeset
|
353 void 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:
850
diff
changeset
|
354 |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
850
diff
changeset
|
355 boost::shared_ptr<IGuiAdapterWidget> GetWidgetFromWindowId(); |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
850
diff
changeset
|
356 |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
357 #endif |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
358 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
359 /** |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
360 This executes all the registered headers if needed (in wasm, the browser |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
361 deals with this) |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
362 */ |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
363 void ViewportsUpdateSize(); |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
364 |
845
cdba0dbb4682
removed some c++11 for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
843
diff
changeset
|
365 std::vector<boost::weak_ptr<IGuiAdapterWidget> > widgets_; |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
366 |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
367 template<typename F> void VisitWidgets(F func) |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
368 { |
845
cdba0dbb4682
removed some c++11 for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
843
diff
changeset
|
369 for (size_t i = 0; i < widgets_.size(); i++) |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
370 { |
845
cdba0dbb4682
removed some c++11 for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
843
diff
changeset
|
371 boost::shared_ptr<IGuiAdapterWidget> widget = widgets_[i].lock(); |
935
401808e7ff2e
Added traces in LoaderCache objects dtors + fuse to prevent dead weak ptrs to be calleds in VisitWdigets (in GuiAdapter.h)
Benjamin Golinvaux <bgo@osimis.io>
parents:
880
diff
changeset
|
372 |
401808e7ff2e
Added traces in LoaderCache objects dtors + fuse to prevent dead weak ptrs to be calleds in VisitWdigets (in GuiAdapter.h)
Benjamin Golinvaux <bgo@osimis.io>
parents:
880
diff
changeset
|
373 // TODO: we need to clean widgets! |
401808e7ff2e
Added traces in LoaderCache objects dtors + fuse to prevent dead weak ptrs to be calleds in VisitWdigets (in GuiAdapter.h)
Benjamin Golinvaux <bgo@osimis.io>
parents:
880
diff
changeset
|
374 if (widget.get() != NULL) |
401808e7ff2e
Added traces in LoaderCache objects dtors + fuse to prevent dead weak ptrs to be calleds in VisitWdigets (in GuiAdapter.h)
Benjamin Golinvaux <bgo@osimis.io>
parents:
880
diff
changeset
|
375 { |
401808e7ff2e
Added traces in LoaderCache objects dtors + fuse to prevent dead weak ptrs to be calleds in VisitWdigets (in GuiAdapter.h)
Benjamin Golinvaux <bgo@osimis.io>
parents:
880
diff
changeset
|
376 func(widget); |
401808e7ff2e
Added traces in LoaderCache objects dtors + fuse to prevent dead weak ptrs to be calleds in VisitWdigets (in GuiAdapter.h)
Benjamin Golinvaux <bgo@osimis.io>
parents:
880
diff
changeset
|
377 } |
843
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
378 } |
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 }; |
67f9c27214c5
Removed extra logging + doc + added GuiAdapter and LockingEmitter
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
381 } |