one less annoying compiler warning.
[ardour.git] / libs / canvas / xfade_curve.cc
index d137cf6cbc12576e64d2433286f37a2fb0f5db41..f97cd234d2045a42076ab92ba6c65ffbdd585a43 100644 (file)
 #include <exception>
 #include <algorithm>
 
-#include "canvas/utils.h"
 #include "canvas/xfade_curve.h"
 #include "canvas/interpolated_curve.h"
+#include "canvas/utils.h"
 
 using namespace ArdourCanvas;
 using std::min;
 using std::max;
 
-XFadeCurve::XFadeCurve (Group* parent)
+XFadeCurve::XFadeCurve (Canvas* c)
+       : Item (c)
+       , points_per_segment (32)
+       , _xfadeposition (Start)
+       , _outline_color (0x000000ff)
+       , _fill_color (0x22448880)
+{
+}
+
+XFadeCurve::XFadeCurve (Canvas* c, XFadePosition pos)
+       : Item (c)
+       , points_per_segment (32)
+       , _xfadeposition (pos)
+       , _outline_color (0x000000ff)
+       , _fill_color (0x22448880)
+{
+}
+
+XFadeCurve::XFadeCurve (Item* parent)
        : Item (parent)
-       , points_per_segment (24)
+       , points_per_segment (32)
        , _xfadeposition (Start)
        , _outline_color (0x000000ff)
        , _fill_color (0x22448880)
 {
 }
 
-XFadeCurve::XFadeCurve (Group* parent, XFadePosition pos)
+XFadeCurve::XFadeCurve (Item* parent, XFadePosition pos)
        : Item (parent)
-       , points_per_segment (24)
+       , points_per_segment (32)
        , _xfadeposition (pos)
        , _outline_color (0x000000ff)
        , _fill_color (0x22448880)
@@ -139,9 +157,9 @@ XFadeCurve::get_path(Rect const & area, Cairo::RefPtr<Cairo::Context> context, C
 
        if (c.points.size () == 2) {
 
-               window_space = item_to_window (c.points.front());
+               window_space = item_to_window (c.points.front(), false);
                context->move_to (window_space.x, window_space.y);
-               window_space = item_to_window (c.points.back());
+               window_space = item_to_window (c.points.back(), false);
                context->line_to (window_space.x, window_space.y);
 
        } else {
@@ -152,30 +170,21 @@ XFadeCurve::get_path(Rect const & area, Cairo::RefPtr<Cairo::Context> context, C
 
                for (Points::size_type idx = 0; idx < c.n_samples - 1; ++idx) {
                        left = idx;
-                       window_space = item_to_window (Duple (c.samples[idx].x, 0.0));
+                       window_space = item_to_window (Duple (c.samples[idx].x, 0.0), false);
                        if (window_space.x >= area.x0) break;
                }
                for (Points::size_type idx = c.n_samples; idx > left + 1; --idx) {
-                       window_space = item_to_window (Duple (c.samples[idx].x, 0.0));
+                       window_space = item_to_window (Duple (c.samples[idx].x, 0.0), false);
                        if (window_space.x <= area.x1) break;
                        right = idx;
                }
 
                /* draw line between samples */
-               window_space = item_to_window (Duple (c.samples[left].x, c.samples[left].y));
+               window_space = item_to_window (Duple (c.samples[left].x, c.samples[left].y), false);
                context->move_to (window_space.x, window_space.y);
-               Coord last_x = round(window_space.x);
-               Coord last_y = round(window_space.y);
                for (uint32_t idx = left + 1; idx < right; ++idx) {
-                       window_space = item_to_window (Duple (c.samples[idx].x, c.samples[idx].y));
-                       if (last_x == round(window_space.x)) continue;
-                       if (last_y == round(window_space.y)) continue;
-                       last_x = round(window_space.x);
-                       last_y = round(window_space.y);
-                       context->line_to (last_x - .5 , last_y + .5);
-               }
-               if (last_x != round(window_space.x) || last_y != round(window_space.y)) {
-                       context->line_to (window_space.x - .5 , window_space.y + .5);
+                       window_space = item_to_window (Duple (c.samples[idx].x, c.samples[idx].y), false);
+                       context->line_to (window_space.x, window_space.y);
                }
        }
        return context->copy_path ();
@@ -186,15 +195,15 @@ XFadeCurve::close_path(Rect const & area, Cairo::RefPtr<Cairo::Context> context,
 {
        Duple window_space;
        if (inside) {
-               window_space = item_to_window (Duple(c.points.back().x, area.height()));
+               window_space = item_to_window (Duple(c.points.back().x, area.height()), false);
                context->line_to (window_space.x, window_space.y);
-               window_space = item_to_window (Duple(c.points.front().x, area.height()));
+               window_space = item_to_window (Duple(c.points.front().x, area.height()), false);
                context->line_to (window_space.x, window_space.y);
                context->close_path();
        } else {
-               window_space = item_to_window (Duple(c.points.back().x, 0.0));
+               window_space = item_to_window (Duple(c.points.back().x, 0.0), false);
                context->line_to (window_space.x, window_space.y);
-               window_space = item_to_window (Duple(c.points.front().x, 0.0));
+               window_space = item_to_window (Duple(c.points.front().x, 0.0), false);
                context->line_to (window_space.x, window_space.y);
                context->close_path();
        }
@@ -244,13 +253,13 @@ XFadeCurve::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) co
        context->begin_new_path ();
        context->append_path (IS ? *path_in : *path_out);
        close_path(draw, context, IS ? _in : _out, true);
-       //context->set_fill_rule (Cairo::FILL_RULE_EVEN_ODD);
+       context->set_fill_rule (Cairo::FILL_RULE_EVEN_ODD);
        context->clip ();
        context->begin_new_path ();
        context->append_path (IS ? *path_out: *path_in);
        close_path(draw, context, IS ? _out : _in, true);
        set_source_rgba (context, fill_shaded);
-       //context->set_fill_rule (Cairo::FILL_RULE_WINDING);
+       context->set_fill_rule (Cairo::FILL_RULE_WINDING);
        context->fill ();
        context->restore ();