make waveforms centered when height hits NAME_HIGHLIGHT_THRESHOLD
[ardour.git] / gtk2_ardour / imageframe_time_axis_view.cc
index 52726941fe9a367ad90bc2717ce67881ad4bfec2..a72508286373df338dac0cd22834cdae5f96db2c 100644 (file)
@@ -48,28 +48,21 @@ using namespace Editing;
  * @param ifta the parent ImageFrameTimeAxis of this view helper
  */
 ImageFrameTimeAxisView::ImageFrameTimeAxisView (ImageFrameTimeAxis& tv)
-       : _trackview (tv)
+       : _trackview (tv),
+         canvas_group (*_trackview.canvas_display),
+         canvas_rect (canvas_group, 0.0, 0.0, 1000000.0, tv.height)
 {
        region_color = _trackview.color() ;
        stream_base_color = color_map[cImageTrackBase] ;
 
-       canvas_group = gtk_canvas_item_new (GTK_CANVAS_GROUP(_trackview.canvas_display), gtk_canvas_group_get_type (), 0) ;
+       canvas_rect.property_outline_color_rgba() = color_map[cImageTrackOutline];
+       canvas_rect.property_fill_color_rgba() = stream_base_color;
 
-       canvas_rect = gtk_canvas_item_new (GTK_CANVAS_GROUP(canvas_group),
-               gtk_canvas_simplerect_get_type(),
-               "x1", 0.0,
-               "y1", 0.0,
-               "x2", 1000000.0,
-               "y2", (double) tv.height,
-               "outline_color_rgba", color_map[cImageTrackOutline],
-               "fill_color_rgba", stream_base_color,
-               0) ;
-
-       gtk_signal_connect(GTK_OBJECT(canvas_rect), "event", (GtkSignalFunc) PublicEditor::canvas_imageframe_view_event, &_trackview) ;
+       canvas_rect.signal_event().connect (bind (mem_fun (_trackview.editor, &PublicEditor::canvas_imageframe_view_event), (ArdourCanvas::Item*) &canvas_rect, &tv));
 
        _samples_per_unit = _trackview.editor.get_current_zoom() ;
 
-       _trackview.editor.ZoomChanged.connect (slot (*this, &ImageFrameTimeAxisView::reset_samples_per_unit)) ;
+       _trackview.editor.ZoomChanged.connect (mem_fun(*this, &ImageFrameTimeAxisView::reset_samples_per_unit)) ;
 
        selected_imageframe_group = 0 ;
        selected_imageframe_view = 0 ;
@@ -99,18 +92,6 @@ ImageFrameTimeAxisView::~ImageFrameTimeAxisView()
                iter = next ;
        }
        
-       // Destroy all our canvas components
-       if(canvas_rect)
-       {
-               gtk_object_destroy(GTK_OBJECT(canvas_rect)) ;
-               canvas_rect = 0 ;
-       }
-       
-       if(canvas_group)
-       {
-               gtk_object_destroy(GTK_OBJECT(canvas_group));
-               canvas_group = 0 ;
-       }
 }
 
 
@@ -126,15 +107,12 @@ int
 ImageFrameTimeAxisView::set_height (gdouble h)
 {
        /* limit the values to something sane-ish */
-       if (h < 10.0 || h > 1000.0)
-       {
+       if (h < 10.0 || h > 1000.0) {
                return(-1) ;
        }
        
-       if(canvas_rect != 0)
-       {
-               gtk_object_set(GTK_OBJECT(canvas_rect), "y2", h, NULL) ;
-       }
+       canvas_rect.property_y2() = h ;
+
 
        for(ImageFrameGroupList::const_iterator citer = imageframe_groups.begin(); citer != imageframe_groups.end(); ++citer)
        {
@@ -154,7 +132,9 @@ int
 ImageFrameTimeAxisView::set_position (gdouble x, gdouble y)
 
 {
-       gtk_canvas_item_set (canvas_group, "x", x, "y", y, NULL);
+       canvas_group.property_x() = x;
+       canvas_group.property_y() = y;
+
        return 0;
 }
 
@@ -187,7 +167,7 @@ ImageFrameTimeAxisView::set_samples_per_unit (gdouble spp)
  * @param color the new base color
  */
 void
-ImageFrameTimeAxisView::apply_color(GdkColor& color)
+ImageFrameTimeAxisView::apply_color(Gdk::Color& color)
 {
        region_color = color ;
        for(ImageFrameGroupList::const_iterator citer = imageframe_groups.begin(); citer != imageframe_groups.end(); citer++)
@@ -234,7 +214,7 @@ ImageFrameTimeAxisView::add_imageframe_group(std::string group_id, void* src)
 
                imageframe_groups.push_front(iftag) ;
        
-               iftag->GoingAway.connect(bind(slot (*this,&ImageFrameTimeAxisView::remove_imageframe_group), iftag, (void*)this)) ;
+               iftag->GoingAway.connect(bind(mem_fun(*this,&ImageFrameTimeAxisView::remove_imageframe_group), iftag, (void*)this)) ;
        
                 ImageFrameGroupAdded(iftag, src) ; /* EMIT_SIGNAL */
        }
@@ -310,7 +290,7 @@ ImageFrameTimeAxisView::remove_named_imageframe_group(std::string group_id, void
 void
 ImageFrameTimeAxisView::remove_imageframe_group(ImageFrameTimeAxisGroup* iftag, void* src)
 {
-       ENSURE_GUI_THREAD(bind (slot (*this, &ImageFrameTimeAxisView::remove_imageframe_group), iftag, src));
+       ENSURE_GUI_THREAD(bind (mem_fun(*this, &ImageFrameTimeAxisView::remove_imageframe_group), iftag, src));
 
        ImageFrameGroupList::iterator i;
        if((i = find (imageframe_groups.begin(), imageframe_groups.end(), iftag)) != imageframe_groups.end())
@@ -385,11 +365,11 @@ ImageFrameTimeAxisView::set_selected_imageframe_view(ImageFrameTimeAxisGroup* if
        
        if(selected_imageframe_view)
        {
-               selected_imageframe_view->set_selected(false, this) ;
+               selected_imageframe_view->set_selected(false) ;
        }
        
        selected_imageframe_view = ifv ;
-       selected_imageframe_view->set_selected(true, this) ;
+       selected_imageframe_view->set_selected(true) ;
 }
 
 /**
@@ -406,7 +386,7 @@ ImageFrameTimeAxisView::clear_selected_imageframe_item(bool clear_group)
        
        if(selected_imageframe_view)
        {
-               selected_imageframe_view->set_selected(false, this) ;
+               selected_imageframe_view->set_selected(false) ;
        }
        selected_imageframe_view = 0 ;
 }