fixes for endemic (compiler?) issues with virtual inheritance of sigc::trackable...
[ardour.git] / gtk2_ardour / crossfade_view.cc
index 75dd3008fd87a11acea2bcc2fa90a1121aa22b9c..e8a97c4cf465d76acc0ec42ba24dd937eda9da05 100644 (file)
 #include "rgb_macros.h"
 #include "audio_time_axis.h"
 #include "public_editor.h"
-#include "regionview.h"
+#include "audio_region_view.h"
 #include "utils.h"
+#include "canvas_impl.h"
 
 using namespace sigc;
 using namespace ARDOUR;
+using namespace PBD;
 using namespace Editing;
 using namespace Gnome;
 using namespace Canvas;
 
 sigc::signal<void,CrossfadeView*> CrossfadeView::GoingAway;
 
-CrossfadeView::CrossfadeView (Gnome::Canvas::Group *parent, 
-                             AudioTimeAxisView &tv, 
+CrossfadeView::CrossfadeView (ArdourCanvas::Group *parent, 
+                             RouteTimeAxisView &tv, 
                              Crossfade& xf, 
                              double spu,
                              Gdk::Color& basic_color,
@@ -49,7 +51,7 @@ CrossfadeView::CrossfadeView (Gnome::Canvas::Group *parent,
                              AudioRegionView& rview)
                              
 
-       : TimeAxisViewItem ("xf.name()", *parent, tv, spu, basic_color, xf.position(), 
+       : TimeAxisViewItem ("xfade" /*xf.name()*/, *parent, tv, spu, basic_color, xf.position(), 
                            xf.overlap_length(), TimeAxisViewItem::Visibility (TimeAxisViewItem::ShowFrame)),
          crossfade (xf),
          left_view (lview),
@@ -60,26 +62,25 @@ CrossfadeView::CrossfadeView (Gnome::Canvas::Group *parent,
        _visible = true;
 
        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_in->property_fill_color_rgba() = color_map[cCrossfadeLine];
+       fade_in->property_width_pixels() = 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);
+       fade_out->property_fill_color_rgba() = color_map[cCrossfadeLine];
+       fade_out->property_width_pixels() = 1;
        
        set_height (get_time_axis_view().height);
 
        /* no frame around the xfade or overlap rects */
 
-       frame->set_property ("outline_what", 0);
+       frame->property_outline_what() = 0;
 
        /* never show the vestigial frame */
 
        vestigial_frame->hide();
        show_vestigial = false;
-
-       // GTK2FIX
-       // group->signal_event.connect (bind (mem_fun (tv.editor, &PublicEditor::canvas_crossfade_view_event), group, this));
+       
+       group->signal_event().connect (bind (mem_fun (tv.editor, &PublicEditor::canvas_crossfade_view_event), group, this));
        
        crossfade_changed (Change (~0));
 
@@ -88,14 +89,7 @@ CrossfadeView::CrossfadeView (Gnome::Canvas::Group *parent,
 
 CrossfadeView::~CrossfadeView ()
 {
-        GoingAway (this) ; /* EMIT_SIGNAL */
-}
-
-std::string
-CrossfadeView::get_item_name ()
-{
-       return "xfade";
-//     return crossfade.name();
+       GoingAway (this) ; /* EMIT_SIGNAL */
 }
 
 void
@@ -114,8 +108,8 @@ CrossfadeView::reset_width_dependent_items (double pixel_width)
 void
 CrossfadeView::set_height (double height)
 {
-       if (height == TimeAxisView::Smaller ||
-               height == TimeAxisView::Small)
+       if (height == TimeAxisView::hSmaller ||
+           height == TimeAxisView::hSmall)
                TimeAxisViewItem::set_height (height - 3 );
        else
                TimeAxisViewItem::set_height (height - NAME_HIGHLIGHT_SIZE - 3 );
@@ -133,6 +127,10 @@ CrossfadeView::crossfade_changed (Change what_changed)
                set_duration (crossfade.overlap_length(), this);
                need_redraw_curves = true;
        }
+
+       if (what_changed & Crossfade::FollowOverlapChanged) {
+               need_redraw_curves = true;
+       }
        
        if (what_changed & Crossfade::ActiveChanged) {
                /* calls redraw_curves */
@@ -148,21 +146,25 @@ CrossfadeView::redraw_curves ()
        Points* points; 
        int32_t npoints;
        float* vec;
-       
        double h;
 
+       if (!crossfade.following_overlap()) {
+               /* curves should not be visible */
+               fade_in->hide ();
+               fade_out->hide ();
+               return;
+       }
+
        /*
         At "height - 3.0" the bottom of the crossfade touches the name highlight or the bottom of the track (if the
         track is either Small or Smaller.
         */
-       switch(get_time_axis_view().height) {
-               case TimeAxisView::Smaller:
-               case TimeAxisView::Small:
-                       h = get_time_axis_view().height - 3.0;
-                       break;
-
-               default:
-                       h = get_time_axis_view().height - NAME_HIGHLIGHT_SIZE - 3.0;
+       double tav_height = get_time_axis_view().height;
+       if (tav_height == TimeAxisView::hSmaller ||
+           tav_height == TimeAxisView::hSmall) {
+               h = tav_height - 3.0;
+       } else {
+               h = tav_height - NAME_HIGHLIGHT_SIZE - 3.0;
        }
 
        if (h < 0) {
@@ -191,7 +193,7 @@ CrossfadeView::redraw_curves ()
                p.set_x(i);
                p.set_y(2.0 + h - (h * vec[i]));
        }
-       fade_in->property_points().set_value(*points);
+       fade_in->property_points() = *points;
 
        crossfade.fade_out().get_vector (0, crossfade.length(), vec, npoints);
        for (int i = 0, pci = 0; i < npoints; ++i) {
@@ -199,7 +201,7 @@ CrossfadeView::redraw_curves ()
                p.set_x(i);
                p.set_y(2.0 + h - (h * vec[i]));
        }
-       fade_out->property_points().set_value(*points);
+       fade_out->property_points() = *points;
 
        delete [] vec;
 
@@ -216,9 +218,9 @@ void
 CrossfadeView::active_changed ()
 {
        if (crossfade.active()) {
-               frame->set_property ("fill_color_rgba", color_map[cActiveCrossfade]);
+               frame->property_fill_color_rgba() = color_map[cActiveCrossfade];
        } else {
-               frame->set_property ("fill_color_rgba", color_map[cInactiveCrossfade]);
+               frame->property_fill_color_rgba() = color_map[cInactiveCrossfade];
        }
 
        redraw_curves ();
@@ -233,7 +235,7 @@ CrossfadeView::set_valid (bool yn)
 AudioRegionView&
 CrossfadeView::upper_regionview () const
 {
-       if (left_view.region.layer() > right_view.region.layer()) {
+       if (left_view.region()->layer() > right_view.region()->layer()) {
                return left_view;
        } else {
                return right_view;