Gnome::Canvas -> ArdourCanvas and some other small fixes
[ardour.git] / gtk2_ardour / crossfade_view.cc
index 6d983cfa6509e72815960293affefc4c556b3d4b..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 (GnomeCanvasGroup *parent, 
+CrossfadeView::CrossfadeView (ArdourCanvas::Group *parent, 
                              AudioTimeAxisView &tv, 
                              Crossfade& xf, 
                              double spu,
-                             GdkColor& basic_color,
+                             Gdk::Color& basic_color,
                              AudioRegionView& lview,
                              AudioRegionView& rview)
                              
 
-       : TimeAxisViewItem ("xf.name()", parent, tv, spu, basic_color, xf.position(), 
+       : TimeAxisViewItem ("xf.name()", *parent, tv, spu, basic_color, xf.position(), 
                            xf.overlap_length(), TimeAxisViewItem::Visibility (TimeAxisViewItem::ShowFrame)),
          crossfade (xf),
          left_view (lview),
@@ -57,34 +59,28 @@ CrossfadeView::CrossfadeView (GnomeCanvasGroup *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);
 
        /* no frame around the xfade or overlap rects */
 
-       gnome_canvas_item_set (frame, "outline_what", 0, NULL);
+       frame->set_property ("outline_what", 0);
 
        /* never show the vestigial frame */
 
-       gnome_canvas_item_hide (vestigial_frame);
+       vestigial_frame->hide();
        show_vestigial = false;
 
-       gtk_object_set_data (GTK_OBJECT(group), "crossfadeview", this);
-       gtk_signal_connect (GTK_OBJECT(group), "event",
-                           (GtkSignalFunc) PublicEditor::canvas_crossfade_view_event,
-                           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));
@@ -110,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();
        }
 }
 
@@ -149,7 +145,7 @@ CrossfadeView::crossfade_changed (Change what_changed)
 void
 CrossfadeView::redraw_curves ()
 {
-       GnomeCanvasPoints* points; 
+       Points* points; 
        int32_t npoints;
        float* vec;
        
@@ -178,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);
@@ -191,36 +187,38 @@ 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.
        */
 
-       gnome_canvas_item_raise_to_top (group);
+       group->raise_to_top();
 }
 
 void
 CrossfadeView::active_changed ()
 {
        if (crossfade.active()) {
-               gnome_canvas_item_set (frame, "fill_color_rgba", color_map[cActiveCrossfade], NULL);
+               frame->set_property ("fill_color_rgba", color_map[cActiveCrossfade]);
        } else {
-               gnome_canvas_item_set (frame, "fill_color_rgba", color_map[cInactiveCrossfade], NULL);
+               frame->set_property ("fill_color_rgba", color_map[cInactiveCrossfade]);
        }
 
        redraw_curves ();
@@ -245,19 +243,19 @@ CrossfadeView::upper_regionview () const
 void
 CrossfadeView::show ()
 {
-       gnome_canvas_item_show (group);
+       group->show();
        _visible = true;
 }
 
 void
 CrossfadeView::hide ()
 {
-       gnome_canvas_item_hide (group);
+       group->hide();
        _visible = false;
 }
 
 void
 CrossfadeView::fake_hide ()
 {
-       gnome_canvas_item_hide (group);
+       group->hide();
 }