# HG changeset patch # User Sebastien Jodogne # Date 1539782328 -7200 # Node ID 7ccf919faff0b7ad7fffc8539b3340ec2ef8bb48 # Parent 7a364e44fbb4eaf2544c20a0b6642fb9598d0702 simplify WorldSceneWidget diff -r 7a364e44fbb4 -r 7ccf919faff0 Framework/Widgets/WorldSceneWidget.cpp --- 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 tracker - (CreateMouseSceneTracker(view_, button, sceneX, sceneY, modifiers)); + std::auto_ptr 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, diff -r 7a364e44fbb4 -r 7ccf919faff0 Framework/Widgets/WorldSceneWidget.h --- 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,