# HG changeset patch # User Sebastien Jodogne # Date 1493308169 -7200 # Node ID 01aa453d4d5b8b660bf14bd8903c441fcd942653 # Parent c2dc924f1a6331355535f389125bc4cb463008e6 IWidget::HasRenderMouseOver diff -r c2dc924f1a63 -r 01aa453d4d5b Applications/Samples/SampleInteractor.h --- a/Applications/Samples/SampleInteractor.h Thu Apr 27 16:57:49 2017 +0200 +++ b/Applications/Samples/SampleInteractor.h Thu Apr 27 17:49:29 2017 +0200 @@ -92,6 +92,14 @@ return NULL; } + virtual bool HasMouseOver(const WorldSceneWidget& widget, + const SliceGeometry& slice, + double x, + double y) + { + return false; + } + virtual void MouseOver(CairoContext& context, WorldSceneWidget& widget, const SliceGeometry& slice, diff -r c2dc924f1a63 -r 01aa453d4d5b Framework/Viewport/WidgetViewport.cpp --- a/Framework/Viewport/WidgetViewport.cpp Thu Apr 27 16:57:49 2017 +0200 +++ b/Framework/Viewport/WidgetViewport.cpp Thu Apr 27 17:49:29 2017 +0200 @@ -204,7 +204,7 @@ mouseTracker_.reset(NULL); } - observers_.NotifyChange(this);; + observers_.NotifyChange(this); } @@ -219,7 +219,7 @@ { mouseTracker_->MouseUp(); mouseTracker_.reset(NULL); - observers_.NotifyChange(this);; + observers_.NotifyChange(this); } } @@ -235,13 +235,23 @@ lastMouseX_ = x; lastMouseY_ = y; + bool repaint = false; + if (mouseTracker_.get() != NULL) { mouseTracker_->MouseMove(x, y); + repaint = true; + } + else + { + repaint = centralWidget_->HasRenderMouseOver(x, y); } - // The scene must be repainted - observers_.NotifyChange(this); + if (repaint) + { + // The scene must be repainted, notify the observers + observers_.NotifyChange(this); + } } diff -r c2dc924f1a63 -r 01aa453d4d5b Framework/Widgets/EmptyWidget.h --- a/Framework/Widgets/EmptyWidget.h Thu Apr 27 16:57:49 2017 +0200 +++ b/Framework/Widgets/EmptyWidget.h Thu Apr 27 17:49:29 2017 +0200 @@ -109,5 +109,11 @@ } virtual void UpdateContent(); + + virtual bool HasRenderMouseOver(int x, + int y) + { + return false; + } }; } diff -r c2dc924f1a63 -r 01aa453d4d5b Framework/Widgets/IWidget.h --- a/Framework/Widgets/IWidget.h Thu Apr 27 16:57:49 2017 +0200 +++ b/Framework/Widgets/IWidget.h Thu Apr 27 17:49:29 2017 +0200 @@ -70,6 +70,9 @@ int x, int y) = 0; + virtual bool HasRenderMouseOver(int x, + int y) = 0; + virtual void MouseWheel(MouseWheelDirection direction, int x, int y, diff -r c2dc924f1a63 -r 01aa453d4d5b Framework/Widgets/IWorldSceneInteractor.h --- a/Framework/Widgets/IWorldSceneInteractor.h Thu Apr 27 16:57:49 2017 +0200 +++ b/Framework/Widgets/IWorldSceneInteractor.h Thu Apr 27 17:49:29 2017 +0200 @@ -47,6 +47,11 @@ double y, IStatusBar* statusBar) = 0; + virtual bool HasMouseOver(const WorldSceneWidget& widget, + const SliceGeometry& slice, + double x, + double y) = 0; + virtual void MouseOver(CairoContext& context, WorldSceneWidget& widget, const SliceGeometry& slice, diff -r c2dc924f1a63 -r 01aa453d4d5b Framework/Widgets/LayoutWidget.cpp --- a/Framework/Widgets/LayoutWidget.cpp Thu Apr 27 16:57:49 2017 +0200 +++ b/Framework/Widgets/LayoutWidget.cpp Thu Apr 27 17:49:29 2017 +0200 @@ -189,6 +189,19 @@ widget_->MouseWheel(direction, x - left_, y - top_, modifiers); } } + + bool HasRenderMouseOver(int x, + int y) + { + if (Contains(x, y)) + { + return widget_->HasRenderMouseOver(x - left_, y - top_); + } + else + { + return false; + } + } }; @@ -504,4 +517,19 @@ throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); } } + + + bool LayoutWidget::HasRenderMouseOver(int x, + int y) + { + for (size_t i = 0; i < children_.size(); i++) + { + if (children_[i]->HasRenderMouseOver(x, y)) + { + return true; + } + } + + return false; + } } diff -r c2dc924f1a63 -r 01aa453d4d5b Framework/Widgets/LayoutWidget.h --- a/Framework/Widgets/LayoutWidget.h Thu Apr 27 16:57:49 2017 +0200 +++ b/Framework/Widgets/LayoutWidget.h Thu Apr 27 17:49:29 2017 +0200 @@ -133,5 +133,8 @@ } virtual void UpdateContent(); + + virtual bool HasRenderMouseOver(int x, + int y); }; } diff -r c2dc924f1a63 -r 01aa453d4d5b Framework/Widgets/TestCairoWidget.h --- a/Framework/Widgets/TestCairoWidget.h Thu Apr 27 16:57:49 2017 +0200 +++ b/Framework/Widgets/TestCairoWidget.h Thu Apr 27 17:49:29 2017 +0200 @@ -67,6 +67,12 @@ } virtual void UpdateContent(); + + virtual bool HasRenderMouseOver(int x, + int y) + { + return true; + } }; } } diff -r c2dc924f1a63 -r 01aa453d4d5b Framework/Widgets/TestWorldSceneWidget.cpp --- a/Framework/Widgets/TestWorldSceneWidget.cpp Thu Apr 27 16:57:49 2017 +0200 +++ b/Framework/Widgets/TestWorldSceneWidget.cpp Thu Apr 27 17:49:29 2017 +0200 @@ -48,6 +48,14 @@ return NULL; } + virtual bool HasMouseOver(const WorldSceneWidget& widget, + const SliceGeometry& slice, + double x, + double y) + { + return true; + } + virtual void MouseOver(CairoContext& context, WorldSceneWidget& widget, const SliceGeometry& slice, diff -r c2dc924f1a63 -r 01aa453d4d5b Framework/Widgets/WidgetBase.h --- a/Framework/Widgets/WidgetBase.h Thu Apr 27 16:57:49 2017 +0200 +++ b/Framework/Widgets/WidgetBase.h Thu Apr 27 17:49:29 2017 +0200 @@ -105,5 +105,11 @@ } virtual void UpdateContent(); + + virtual bool HasRenderMouseOver(int x, + int y) + { + return false; + } }; } diff -r c2dc924f1a63 -r 01aa453d4d5b Framework/Widgets/WorldSceneWidget.cpp --- a/Framework/Widgets/WorldSceneWidget.cpp Thu Apr 27 16:57:49 2017 +0200 +++ b/Framework/Widgets/WorldSceneWidget.cpp Thu Apr 27 17:49:29 2017 +0200 @@ -409,4 +409,18 @@ interactor_->KeyPressed(*this, key, modifiers, GetStatusBar()); } } + + + bool WorldSceneWidget::HasRenderMouseOver(int x, + int y) + { + if (interactor_) + { + return interactor_->HasMouseOver(*this, GetSlice(), x, y); + } + else + { + return false; + } + } } diff -r c2dc924f1a63 -r 01aa453d4d5b Framework/Widgets/WorldSceneWidget.h --- a/Framework/Widgets/WorldSceneWidget.h Thu Apr 27 16:57:49 2017 +0200 +++ b/Framework/Widgets/WorldSceneWidget.h Thu Apr 27 17:49:29 2017 +0200 @@ -137,5 +137,8 @@ virtual void KeyPressed(char key, KeyboardModifiers modifiers); + + virtual bool HasRenderMouseOver(int x, + int y); }; }