changeset 331:7ccf919faff0 am-2

simplify WorldSceneWidget
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 17 Oct 2018 15:18:48 +0200
parents 7a364e44fbb4
children 50e5ec1bdd46
files Framework/Widgets/WorldSceneWidget.cpp Framework/Widgets/WorldSceneWidget.h
diffstat 2 files changed, 20 insertions(+), 51 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/Widgets/WorldSceneWidget.cpp	Wed Oct 17 12:45:52 2018 +0200
+++ b/Framework/Widgets/WorldSceneWidget.cpp	Wed Oct 17 15:18:48 2018 +0200
@@ -176,7 +176,11 @@
 
     double sceneX, sceneY;
     MapMouseToScene(sceneX, sceneY, view, x, y);
-    RenderSceneMouseOver(context, view, sceneX, sceneY);
+
+    if (interactor_)
+    {
+      interactor_->MouseOver(context, *this, view, sceneX, sceneY, GetStatusBar());
+    }
   }
 
 
@@ -232,13 +236,18 @@
     MapMouseToScene(sceneX, sceneY, view_, x, y);
 
     // asks the Widget Interactor to provide a mouse tracker
-    std::auto_ptr<IWorldSceneMouseTracker> tracker
-        (CreateMouseSceneTracker(view_, button, sceneX, sceneY, modifiers));
+    std::auto_ptr<IWorldSceneMouseTracker> tracker;
 
+    if (interactor_)
+    {
+      tracker.reset(interactor_->CreateMouseTracker(*this, view_, button, modifiers, sceneX, sceneY, GetStatusBar()));
+    }
+    
     if (tracker.get() != NULL)
     {
       return new SceneMouseTracker(view_, tracker.release());
     }
+
     //TODO: allow Interactor to create Pan & Zoom
     switch (button)
     {
@@ -254,34 +263,6 @@
   }
 
 
-  void WorldSceneWidget::RenderSceneMouseOver(CairoContext& context,
-                                              const ViewportGeometry& view,
-                                              double x,
-                                              double y)
-  {
-    if (interactor_)
-    {
-      interactor_->MouseOver(context, *this, view, x, y, GetStatusBar());
-    }
-  }
-
-  IWorldSceneMouseTracker* WorldSceneWidget::CreateMouseSceneTracker(const ViewportGeometry& view,
-                                                                     MouseButton button,
-                                                                     double x,
-                                                                     double y,
-                                                                     KeyboardModifiers modifiers)
-  {
-    if (interactor_)
-    {
-      return interactor_->CreateMouseTracker(*this, view, button, modifiers, x, y, GetStatusBar());
-    }
-    else
-    {
-      return NULL;
-    }
-  }
-
-
   void WorldSceneWidget::MouseWheel(MouseWheelDirection direction,
                                     int x,
                                     int y,
--- a/Framework/Widgets/WorldSceneWidget.h	Wed Oct 17 12:45:52 2018 +0200
+++ b/Framework/Widgets/WorldSceneWidget.h	Wed Oct 17 15:18:48 2018 +0200
@@ -72,22 +72,21 @@
     };
 
   private:
-    struct SizeChangeFunctor;
-
     class SceneMouseTracker;
 
     ViewportGeometry       view_;
     IWorldSceneInteractor* interactor_;
 
-  public:
+  protected:
     virtual Extent2D GetSceneExtent() = 0;
 
-  protected:
     virtual bool RenderScene(CairoContext& context,
                              const ViewportGeometry& view) = 0;
 
+    // From CairoWidget
     virtual bool RenderCairo(CairoContext& context);
 
+    // From CairoWidget
     virtual void RenderMouseOverCairo(CairoContext& context,
                                       int x,
                                       int y);
@@ -101,33 +100,22 @@
     {
     }
 
-    virtual void SetSize(unsigned int width,
-                         unsigned int height);
-
     void SetInteractor(IWorldSceneInteractor& interactor);
 
-    virtual void FitContent();
-
     void SetView(const ViewportGeometry& view);
 
     ViewportGeometry GetView();
 
+    virtual void SetSize(unsigned int width,
+                         unsigned int height);
+
+    virtual void FitContent();
+
     virtual IMouseTracker* CreateMouseTracker(MouseButton button,
                                               int x,
                                               int y,
                                               KeyboardModifiers modifiers);
 
-    virtual void RenderSceneMouseOver(CairoContext& context,
-                                      const ViewportGeometry& view,
-                                      double x,
-                                      double y);
-
-    virtual IWorldSceneMouseTracker* CreateMouseSceneTracker(const ViewportGeometry& view,
-                                                             MouseButton button,
-                                                             double x,
-                                                             double y,
-                                                             KeyboardModifiers modifiers);
-
     virtual void MouseWheel(MouseWheelDirection direction,
                             int x,
                             int y,