Mercurial > hg > orthanc-stone
comparison Framework/Viewport/WebAssemblyViewport.cpp @ 1346:df8bf351c23f broker
The flag that allows the WebAssemblyViewport to
**not** register the mouse events in the canvas
(in case they are handled by other means) is now
correctly passed down from the factory method.
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Mon, 06 Apr 2020 16:57:56 +0200 |
parents | ab81ee8fce1f |
children | 1b8e37770d78 |
comparison
equal
deleted
inserted
replaced
1345:0d6a01ffa1dd | 1346:df8bf351c23f |
---|---|
158 } | 158 } |
159 | 159 |
160 | 160 |
161 EM_BOOL WebAssemblyViewport::OnMouseMove(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData) | 161 EM_BOOL WebAssemblyViewport::OnMouseMove(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData) |
162 { | 162 { |
163 LOG(TRACE) << "WebAssemblyViewport::OnMouseMove CP1. userData = " << userData; | 163 WebAssemblyViewport* that = reinterpret_cast<WebAssemblyViewport*>(userData); |
164 | |
165 WebAssemblyViewport* that = reinterpret_cast<WebAssemblyViewport*>(userData); | |
166 LOG(TRACE) << "WebAssemblyViewport::OnMouseMove CP2"; | |
167 | 164 |
168 if (that->compositor_.get() != NULL && | 165 if (that->compositor_.get() != NULL && |
169 that->controller_->HasActiveTracker()) | 166 that->controller_->HasActiveTracker()) |
170 { | 167 { |
171 LOG(TRACE) << "WebAssemblyViewport::OnMouseMove CP3"; | |
172 PointerEvent pointer; | 168 PointerEvent pointer; |
173 ConvertMouseEvent(pointer, *mouseEvent, *that->compositor_); | 169 ConvertMouseEvent(pointer, *mouseEvent, *that->compositor_); |
174 LOG(TRACE) << "WebAssemblyViewport::OnMouseMove CP4"; | |
175 if (that->controller_->HandleMouseMove(pointer)) | 170 if (that->controller_->HandleMouseMove(pointer)) |
176 { | 171 { |
177 LOG(TRACE) << "WebAssemblyViewport::OnMouseMove CP5"; | |
178 that->Invalidate(); | 172 that->Invalidate(); |
179 LOG(TRACE) << "WebAssemblyViewport::OnMouseMove CP6"; | |
180 } | 173 } |
181 } | 174 } |
182 | 175 |
183 LOG(TRACE) << "Exiting: " << __func__; | 176 LOG(TRACE) << "Exiting: " << __func__; |
184 return true; | 177 return true; |
217 compositor_.reset(compositor); | 210 compositor_.reset(compositor); |
218 } | 211 } |
219 } | 212 } |
220 | 213 |
221 WebAssemblyViewport::WebAssemblyViewport( | 214 WebAssemblyViewport::WebAssemblyViewport( |
222 const std::string& canvasId, bool enableEmscriptenEvents) : | 215 const std::string& canvasId, bool enableEmscriptenMouseEvents) : |
223 shortCanvasId_(canvasId), | 216 shortCanvasId_(canvasId), |
224 fullCanvasId_(canvasId), | 217 fullCanvasId_(canvasId), |
225 interactor_(new DefaultViewportInteractor), | 218 interactor_(new DefaultViewportInteractor), |
226 enableEmscriptenEvents_(enableEmscriptenEvents) | 219 enableEmscriptenMouseEvents_(enableEmscriptenMouseEvents) |
227 { | 220 { |
228 } | 221 } |
229 | 222 |
230 void WebAssemblyViewport::PostConstructor() | 223 void WebAssemblyViewport::PostConstructor() |
231 { | 224 { |
251 } | 244 } |
252 }, | 245 }, |
253 shortCanvasId_.c_str() // $0 | 246 shortCanvasId_.c_str() // $0 |
254 ); | 247 ); |
255 | 248 |
256 if (enableEmscriptenEvents_) | 249 // It is not possible to monitor the resizing of individual |
257 { | 250 // canvas, so we track the full window of the browser |
258 // It is not possible to monitor the resizing of individual | 251 emscripten_set_resize_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, |
259 // canvas, so we track the full window of the browser | 252 reinterpret_cast<void*>(this), |
260 emscripten_set_resize_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, | 253 false, |
261 reinterpret_cast<void*>(this), | 254 OnResize); |
262 false, | 255 |
263 OnResize); | 256 if (enableEmscriptenMouseEvents_) |
257 { | |
264 | 258 |
265 emscripten_set_mousedown_callback(fullCanvasId_.c_str(), | 259 emscripten_set_mousedown_callback(fullCanvasId_.c_str(), |
266 reinterpret_cast<void*>(this), | 260 reinterpret_cast<void*>(this), |
267 false, | 261 false, |
268 OnMouseDown); | 262 OnMouseDown); |
279 } | 273 } |
280 } | 274 } |
281 | 275 |
282 WebAssemblyViewport::~WebAssemblyViewport() | 276 WebAssemblyViewport::~WebAssemblyViewport() |
283 { | 277 { |
284 if (enableEmscriptenEvents_) | 278 emscripten_set_resize_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, |
285 { | 279 reinterpret_cast<void*>(this), |
286 emscripten_set_resize_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, | 280 false, |
287 reinterpret_cast<void*>(this), | 281 NULL); |
288 false, | 282 |
289 NULL); | 283 if (enableEmscriptenMouseEvents_) |
284 { | |
290 | 285 |
291 emscripten_set_mousedown_callback(fullCanvasId_.c_str(), | 286 emscripten_set_mousedown_callback(fullCanvasId_.c_str(), |
292 reinterpret_cast<void*>(this), | 287 reinterpret_cast<void*>(this), |
293 false, | 288 false, |
294 OnMouseDown); | 289 OnMouseDown); |