add ::covered_by_y_range() to TimeAxisView
authorPaul Davis <paul@linuxaudiosystems.com>
Wed, 26 Feb 2014 02:53:04 +0000 (21:53 -0500)
committerPaul Davis <paul@linuxaudiosystems.com>
Wed, 26 Feb 2014 02:53:04 +0000 (21:53 -0500)
gtk2_ardour/time_axis_view.cc
gtk2_ardour/time_axis_view.h

index 6efea93fc86b357196a152633dd31479dc1768bd..036323627cb1679ce0f80742925344946ce3d7a2 100644 (file)
@@ -1177,7 +1177,7 @@ TimeAxisView::color_handler ()
  * and is in stacked or expanded * region display mode, otherwise 0.
  */
 std::pair<TimeAxisView*, double>
-TimeAxisView::covers_y_position (double y)
+TimeAxisView::covers_y_position (double y) const
 {
        if (hidden()) {
                return std::make_pair ((TimeAxisView *) 0, 0);
@@ -1212,7 +1212,7 @@ TimeAxisView::covers_y_position (double y)
                        break;
                }
 
-               return std::make_pair (this, l);
+               return std::make_pair (const_cast<TimeAxisView*>(this), l);
        }
 
        for (Children::const_iterator i = children.begin(); i != children.end(); ++i) {
@@ -1226,6 +1226,30 @@ TimeAxisView::covers_y_position (double y)
        return std::make_pair ((TimeAxisView *) 0, 0);
 }
 
+bool
+TimeAxisView::covered_by_y_range (double y0, double y1) const
+{
+       if (hidden()) {
+               return false;
+       }
+
+       /* if either the top or bottom of the axisview is in the vertical
+        * range, we cover it.
+        */
+       
+       if ((y0 < _y_position && y1 < _y_position) ||
+           (y0 >= _y_position + height && y1 >= _y_position + height)) {
+               return false;
+       }
+
+       for (Children::const_iterator i = children.begin(); i != children.end(); ++i) {
+               if ((*i)->covered_by_y_range (y0, y1)) {
+                       return true;
+               }
+       }
+
+       return true;
+}
 
 uint32_t
 TimeAxisView::preset_height (Height h)
index a22ba9443959d12be288aeb8d7b9f345cd0d6533..38626a080d880b5dd9d30a360484b178d22a394e 100644 (file)
@@ -144,7 +144,8 @@ class TimeAxisView : public virtual AxisView
 
        virtual void reset_visual_state ();
 
-       std::pair<TimeAxisView*, double> covers_y_position (double);
+       std::pair<TimeAxisView*, double> covers_y_position (double) const;
+        bool covered_by_y_range (double y0, double y1) const;
 
        virtual void step_height (bool);