OSC: fix issue #7444 send fader position/gain even when 0.
[ardour.git] / libs / canvas / poly_line.cc
index 5d6abb9814923bab832b47d3595087d70404c192..99c3377874ada0463461c24bd341cba224031fff 100644 (file)
@@ -28,18 +28,66 @@ using namespace ArdourCanvas;
 PolyLine::PolyLine (Canvas* c)
        : PolyItem (c)
        , _threshold (1.0)
+       , _y1 (0)
 {
 }
 
 PolyLine::PolyLine (Item* parent)
        : PolyItem (parent)
        , _threshold (1.0)
+       , _y1 (0)
 {
 }
 
+void
+PolyLine::compute_bounding_box () const
+{
+       PolyItem::compute_bounding_box ();
+       if (_y1 > 0 && _bounding_box) {
+               _bounding_box.x0 = 0;
+               _bounding_box.x1 = COORD_MAX;
+               if (_y1 > _bounding_box.y1) {
+                       _bounding_box.y1 = _y1;
+               }
+       }
+}
+
+void
+PolyLine::set_fill_y1 (double y1) {
+       begin_change ();
+       _bounding_box_dirty = true;
+       _y1 = y1;
+       end_change ();
+}
+
 void
 PolyLine::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const
 {
+       if (_fill && _y1 > 0 && _points.size() > 0) {
+               const ArdourCanvas::Rect& vp (_canvas->visible_area());
+               setup_fill_context (context);
+
+               Duple y (0, _y1);
+               float y1 = item_to_window (y).y;
+               render_path (area, context);
+               Duple c0 (item_to_window (_points.back()));
+               Duple c1 (item_to_window (_points.front()));
+               if (c0.x < vp.x1) {
+                       context->line_to (vp.x1, c0.y);
+                       context->line_to (vp.x1, y1);
+               } else {
+                       context->line_to (vp.x1, y1);
+               }
+               if (c1.x > vp.x0) {
+                       context->line_to (vp.x0, y1);
+                       context->line_to (vp.x0, c1.y);
+               } else {
+                       context->line_to (vp.x0, y1);
+               }
+               context->close_path ();
+               context->fill ();
+       }
+
        if (_outline) {
                setup_outline_context (context);
                render_path (area, context);