changeset 333:08683537a227 am-2

possibility to turn off default mouse events in WorldSceneWidget
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 17 Oct 2018 19:42:56 +0200
parents 50e5ec1bdd46
children c34784e5f299
files Framework/Widgets/WorldSceneWidget.cpp Framework/Widgets/WorldSceneWidget.h
diffstat 2 files changed, 28 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/Widgets/WorldSceneWidget.cpp	Wed Oct 17 19:38:39 2018 +0200
+++ b/Framework/Widgets/WorldSceneWidget.cpp	Wed Oct 17 19:42:56 2018 +0200
@@ -161,18 +161,23 @@
     {
       return new SceneMouseTracker(view_, tracker.release());
     }
-
-    //TODO: allow Interactor to create Pan & Zoom
-    switch (button)
+    else if (hasDefaultMouseEvents_)
     {
-      case MouseButton_Middle:
-        return new SceneMouseTracker(view_, new PanMouseTracker(*this, x, y));
+      switch (button)
+      {
+        case MouseButton_Middle:
+          return new SceneMouseTracker(view_, new PanMouseTracker(*this, x, y));
+
+        case MouseButton_Right:
+          return new SceneMouseTracker(view_, new ZoomMouseTracker(*this, x, y));
 
-      case MouseButton_Right:
-        return new SceneMouseTracker(view_, new ZoomMouseTracker(*this, x, y));
-
-      default:
-        return NULL;
+        default:
+          return NULL;
+      }      
+    }
+    else
+    {
+      return NULL;
     }
   }
 
--- a/Framework/Widgets/WorldSceneWidget.h	Wed Oct 17 19:38:39 2018 +0200
+++ b/Framework/Widgets/WorldSceneWidget.h	Wed Oct 17 19:42:56 2018 +0200
@@ -36,6 +36,7 @@
 
     ViewportGeometry       view_;
     IWorldSceneInteractor* interactor_;
+    bool                   hasDefaultMouseEvents_;
 
   protected:
     virtual Extent2D GetSceneExtent() = 0;
@@ -56,8 +57,19 @@
   public:
     WorldSceneWidget(const std::string& name) :
       CairoWidget(name),
-      interactor_(NULL)
+      interactor_(NULL),
+      hasDefaultMouseEvents_(true)
+    {
+    }
+
+    void SetDefaultMouseEvents(bool value)
     {
+      hasDefaultMouseEvents_ = value;
+    }
+
+    bool HasDefaultMouseEvents() const
+    {
+      return hasDefaultMouseEvents_;
     }
 
     void SetInteractor(IWorldSceneInteractor& interactor);