Gnome::Canvas -> ArdourCanvas and some other small fixes
[ardour.git] / gtk2_ardour / crossfade_view.cc
index 7e6a889a3ecdca45fe2c948b47fc2571cd861b1d..f81e95a4a97341ca343d7db043f6171079e3406f 100644 (file)
 using namespace sigc;
 using namespace ARDOUR;
 using namespace Editing;
+using namespace Gnome;
+using namespace Canvas;
 
 sigc::signal<void,CrossfadeView*> CrossfadeView::GoingAway;
 
-CrossfadeView::CrossfadeView (Gnome::Canvas::Group *parent, 
+CrossfadeView::CrossfadeView (ArdourCanvas::Group *parent, 
                              AudioTimeAxisView &tv, 
                              Crossfade& xf, 
                              double spu,
@@ -57,17 +59,13 @@ CrossfadeView::CrossfadeView (Gnome::Canvas::Group *parent,
        _valid = true;
        _visible = true;
 
-       fade_in = gnome_canvas_item_new (GNOME_CANVAS_GROUP(group),
-                                      gnome_canvas_line_get_type(),
-                                      "fill_color_rgba", color_map[cCrossfadeLine],
-                                       "width_pixels", (guint) 1,
-                                      NULL);
-
-       fade_out = gnome_canvas_item_new (GNOME_CANVAS_GROUP(group),
-                                       gnome_canvas_line_get_type(),
-                                       "fill_color_rgba", color_map[cCrossfadeLine],
-                                       "width_pixels", (guint) 1,
-                                       NULL);
+       fade_in = new Line (*group);
+       fade_in->property_fill_color_rgba().set_value(color_map[cCrossfadeLine]);
+       fade_in->property_width_pixels().set_value(1);
+
+       fade_out = new Line (*group);
+       fade_out->property_fill_color_rgba().set_value(color_map[cCrossfadeLine]);
+       fade_out->property_width_pixels().set_value(1);
        
        set_height (get_time_axis_view().height);
 
@@ -80,8 +78,9 @@ CrossfadeView::CrossfadeView (Gnome::Canvas::Group *parent,
        vestigial_frame->hide();
        show_vestigial = false;
 
-       group->signal_event.connect (bind (mem_fun (editor, &Public::canvas_crossfade_view_event), group, this));
-
+       // GTK2FIX
+       // group->signal_event.connect (bind (mem_fun (tv.editor, &PublicEditor::canvas_crossfade_view_event), group, this));
+       
        crossfade_changed (Change (~0));
 
        crossfade.StateChanged.connect (mem_fun(*this, &CrossfadeView::crossfade_changed));
@@ -107,8 +106,8 @@ CrossfadeView::reset_width_dependent_items (double pixel_width)
        active_changed ();
 
        if (pixel_width < 5) {
-               gnome_canvas_item_hide (fade_in);
-               gnome_canvas_item_hide (fade_out);
+               fade_in->hide();
+               fade_out->hide();
        }
 }
 
@@ -146,7 +145,7 @@ CrossfadeView::crossfade_changed (Change what_changed)
 void
 CrossfadeView::redraw_curves ()
 {
-       GnomeCanvasPoints* points; 
+       Points* points; 
        int32_t npoints;
        float* vec;
        
@@ -175,12 +174,12 @@ CrossfadeView::redraw_curves ()
        npoints = std::min (gdk_screen_width(), npoints);
 
        if (!_visible || !crossfade.active() || npoints < 3) {
-               gnome_canvas_item_hide (fade_in);
-               gnome_canvas_item_hide (fade_out);
+               fade_in->hide();
+               fade_out->hide();
                return;
        } else {
-               gnome_canvas_item_show (fade_in);
-               gnome_canvas_item_show (fade_out);
+               fade_in->show();
+               fade_out->show();
        } 
 
        points = get_canvas_points ("xfade edit redraw", npoints);
@@ -188,21 +187,23 @@ CrossfadeView::redraw_curves ()
 
        crossfade.fade_in().get_vector (0, crossfade.length(), vec, npoints);
        for (int i = 0, pci = 0; i < npoints; ++i) {
-               points->coords[pci++] = i;
-               points->coords[pci++] = 2.0 + h - (h * vec[i]);
+               Art::Point &p = (*points)[pci++];
+               p.set_x(i);
+               p.set_y(2.0 + h - (h * vec[i]));
        }
-       gnome_canvas_item_set (fade_in, "points", points, NULL);
+       fade_in->property_points().set_value(*points);
 
        crossfade.fade_out().get_vector (0, crossfade.length(), vec, npoints);
        for (int i = 0, pci = 0; i < npoints; ++i) {
-               points->coords[pci++] = i;
-               points->coords[pci++] = 2.0 + h - (h * vec[i]);
+               Art::Point &p = (*points)[pci++];
+               p.set_x(i);
+               p.set_y(2.0 + h - (h * vec[i]));
        }
-       gnome_canvas_item_set (fade_out, "points", points, NULL);
+       fade_out->property_points().set_value(*points);
 
        delete [] vec;
 
-       gnome_canvas_points_unref (points);
+       delete points;
 
        /* XXX this is ugly, but it will have to wait till Crossfades are reimplented
           as regions. This puts crossfade views on top of a track, above all regions.