changeset 54:01aa453d4d5b wasm

IWidget::HasRenderMouseOver
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 27 Apr 2017 17:49:29 +0200
parents c2dc924f1a63
children f0f354a97581
files Applications/Samples/SampleInteractor.h Framework/Viewport/WidgetViewport.cpp Framework/Widgets/EmptyWidget.h Framework/Widgets/IWidget.h Framework/Widgets/IWorldSceneInteractor.h Framework/Widgets/LayoutWidget.cpp Framework/Widgets/LayoutWidget.h Framework/Widgets/TestCairoWidget.h Framework/Widgets/TestWorldSceneWidget.cpp Framework/Widgets/WidgetBase.h Framework/Widgets/WorldSceneWidget.cpp Framework/Widgets/WorldSceneWidget.h
diffstat 12 files changed, 104 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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,
--- 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);
+    }
   }
 
 
--- 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;
+    }
   };
 }
--- 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,
--- 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,
--- 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;
+  }
 }
--- 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);
   };
 }
--- 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;
+      }
     };
   }
 }
--- 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,
--- 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;
+    }
   };
 }
--- 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;
+    }
+  }
 }
--- 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);
   };
 }