Mercurial > hg > orthanc-stone
comparison Applications/Generic/GuiAdapter.cpp @ 1020:ac88989817e3 toa2019093001
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
+ added DeleteMeasureCommand + moved the various concrete measuring tool-related
classes to their pre-assigned file locations (everything was crammed into
MeasureCommands.* files up to this commit) + added double-click handler to
GuiAdapter (for TOA implementation of "delete measuring tool on double-click")
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Mon, 30 Sep 2019 10:41:06 +0200 |
parents | 1091b2adeb5a |
children | 4383382db01d 2d8ab34c8c91 |
comparison
equal
deleted
inserted
replaced
1019:29f5f2031310 | 1020:ac88989817e3 |
---|---|
76 ORTHANC_ASSERT(false, "Not supported"); | 76 ORTHANC_ASSERT(false, "Not supported"); |
77 break; | 77 break; |
78 case EMSCRIPTEN_EVENT_MOUSEDOWN: | 78 case EMSCRIPTEN_EVENT_MOUSEDOWN: |
79 dest.type = GUIADAPTER_EVENT_MOUSEDOWN; | 79 dest.type = GUIADAPTER_EVENT_MOUSEDOWN; |
80 break; | 80 break; |
81 case EMSCRIPTEN_EVENT_DBLCLICK: | |
82 dest.type = GUIADAPTER_EVENT_MOUSEDBLCLICK; | |
83 break; | |
81 case EMSCRIPTEN_EVENT_MOUSEMOVE: | 84 case EMSCRIPTEN_EVENT_MOUSEMOVE: |
82 dest.type = GUIADAPTER_EVENT_MOUSEMOVE; | 85 dest.type = GUIADAPTER_EVENT_MOUSEMOVE; |
83 break; | 86 break; |
84 case EMSCRIPTEN_EVENT_MOUSEUP: | 87 case EMSCRIPTEN_EVENT_MOUSEUP: |
85 dest.type = GUIADAPTER_EVENT_MOUSEUP; | 88 dest.type = GUIADAPTER_EVENT_MOUSEUP; |
285 userData, | 288 userData, |
286 capture, | 289 capture, |
287 func); | 290 func); |
288 } | 291 } |
289 | 292 |
293 | |
294 void GuiAdapter::SetMouseDblClickCallback( | |
295 std::string canvasId, void* userData, bool capture, OnMouseEventFunc func) | |
296 { | |
297 SetCallback<OnMouseEventFunc, GuiAdapterMouseEvent, EmscriptenMouseEvent>( | |
298 &emscripten_set_dblclick_callback_on_thread, | |
299 canvasId, | |
300 userData, | |
301 capture, | |
302 func); | |
303 } | |
304 | |
305 | |
290 void GuiAdapter::SetMouseDownCallback( | 306 void GuiAdapter::SetMouseDownCallback( |
291 std::string canvasId, void* userData, bool capture, OnMouseEventFunc func) | 307 std::string canvasId, void* userData, bool capture, OnMouseEventFunc func) |
292 { | 308 { |
293 SetCallback<OnMouseEventFunc, GuiAdapterMouseEvent, EmscriptenMouseEvent>( | 309 SetCallback<OnMouseEventFunc, GuiAdapterMouseEvent, EmscriptenMouseEvent>( |
294 &emscripten_set_mousedown_callback_on_thread, | 310 &emscripten_set_mousedown_callback_on_thread, |
399 { | 415 { |
400 memset(&dest, 0, sizeof(GuiAdapterMouseEvent)); | 416 memset(&dest, 0, sizeof(GuiAdapterMouseEvent)); |
401 switch (source.type) | 417 switch (source.type) |
402 { | 418 { |
403 case SDL_MOUSEBUTTONDOWN: | 419 case SDL_MOUSEBUTTONDOWN: |
404 dest.type = GUIADAPTER_EVENT_MOUSEDOWN; | 420 if (source.button.clicks == 1) { |
421 dest.type = GUIADAPTER_EVENT_MOUSEDOWN; | |
422 } else if (source.button.clicks == 2) { | |
423 dest.type = GUIADAPTER_EVENT_MOUSEDBLCLICK; | |
424 } else { | |
425 dest.type = GUIADAPTER_EVENT_MOUSEDBLCLICK; | |
426 LOG(WARNING) << "Multiple-click ignored."; | |
427 } | |
405 break; | 428 break; |
406 case SDL_MOUSEMOTION: | 429 case SDL_MOUSEMOTION: |
407 dest.type = GUIADAPTER_EVENT_MOUSEMOVE; | 430 dest.type = GUIADAPTER_EVENT_MOUSEMOVE; |
408 break; | 431 break; |
409 case SDL_MOUSEBUTTONUP: | 432 case SDL_MOUSEBUTTONUP: |
511 { | 534 { |
512 mouseDownHandlers_.push_back(EventHandlerData<OnMouseEventFunc>(canvasId, func, userData)); | 535 mouseDownHandlers_.push_back(EventHandlerData<OnMouseEventFunc>(canvasId, func, userData)); |
513 } | 536 } |
514 | 537 |
515 // SDL ONLY | 538 // SDL ONLY |
539 void GuiAdapter::SetMouseDblClickCallback( | |
540 std::string canvasId, void* userData, bool capture, OnMouseEventFunc func) | |
541 { | |
542 mouseDblCickHandlers_.push_back(EventHandlerData<OnMouseEventFunc>(canvasId, func, userData)); | |
543 } | |
544 | |
545 // SDL ONLY | |
516 void GuiAdapter::SetMouseMoveCallback( | 546 void GuiAdapter::SetMouseMoveCallback( |
517 std::string canvasId, void* userData, bool capture, OnMouseEventFunc func) | 547 std::string canvasId, void* userData, bool capture, OnMouseEventFunc func) |
518 { | 548 { |
519 mouseMoveHandlers_.push_back(EventHandlerData<OnMouseEventFunc>(canvasId, func, userData)); | 549 mouseMoveHandlers_.push_back(EventHandlerData<OnMouseEventFunc>(canvasId, func, userData)); |
520 } | 550 } |
670 case GUIADAPTER_EVENT_MOUSEDOWN: | 700 case GUIADAPTER_EVENT_MOUSEDOWN: |
671 for (size_t i = 0; i < mouseDownHandlers_.size(); i++) | 701 for (size_t i = 0; i < mouseDownHandlers_.size(); i++) |
672 { | 702 { |
673 if (mouseDownHandlers_[i].canvasName == windowTitle) | 703 if (mouseDownHandlers_[i].canvasName == windowTitle) |
674 (*(mouseDownHandlers_[i].func))(windowTitle, &event, mouseDownHandlers_[i].userData); | 704 (*(mouseDownHandlers_[i].func))(windowTitle, &event, mouseDownHandlers_[i].userData); |
705 } | |
706 break; | |
707 case GUIADAPTER_EVENT_MOUSEDBLCLICK: | |
708 for (size_t i = 0; i < mouseDblCickHandlers_.size(); i++) | |
709 { | |
710 if (mouseDblCickHandlers_[i].canvasName == windowTitle) | |
711 (*(mouseDblCickHandlers_[i].func))(windowTitle, &event, mouseDblCickHandlers_[i].userData); | |
675 } | 712 } |
676 break; | 713 break; |
677 case GUIADAPTER_EVENT_MOUSEMOVE: | 714 case GUIADAPTER_EVENT_MOUSEMOVE: |
678 for (size_t i = 0; i < mouseMoveHandlers_.size(); i++) | 715 for (size_t i = 0; i < mouseMoveHandlers_.size(); i++) |
679 { | 716 { |