Tidy up region drag move code a bit.
[ardour.git] / gtk2_ardour / crossfade_view.cc
index 2854de9a782e865e8bb9995fe26769a0e4f1e8be..f77f8db44283cfb906b6f84cef307afb8da6798a 100644 (file)
@@ -84,6 +84,7 @@ CrossfadeView::CrossfadeView (ArdourCanvas::Group *parent,
        crossfade_changed (all_crossfade_properties);
 
        crossfade->PropertyChanged.connect (*this, invalidator (*this), ui_bind (&CrossfadeView::crossfade_changed, this, _1), gui_context());
+       crossfade->FadesChanged.connect (*this, invalidator (*this), ui_bind (&CrossfadeView::crossfade_fades_changed, this), gui_context());
        ColorsChanged.connect (sigc::mem_fun (*this, &CrossfadeView::color_handler));
 }
 
@@ -108,10 +109,8 @@ CrossfadeView::reset_width_dependent_items (double pixel_width)
 void
 CrossfadeView::set_height (double h)
 {
-       if (h <= TimeAxisView::hSmall) {
-               h -= 3.0;
-       } else {
-               h -= NAME_HIGHLIGHT_SIZE + 3.0;
+       if (h > TimeAxisView::preset_height (HeightSmall)) {
+               h -= NAME_HIGHLIGHT_SIZE;
        }
 
        TimeAxisViewItem::set_height (h);
@@ -183,8 +182,8 @@ CrossfadeView::redraw_curves ()
 
        for (int i = 0, pci = 0; i < npoints; ++i) {
                Art::Point &p = (*points)[pci++];
-               p.set_x(i);
-               p.set_y(2.0 + _height - (_height * vec[i]));
+               p.set_x (i + 1);
+               p.set_y (_height - ((_height - 2) * vec[i]));
        }
        
        fade_in->property_points() = *points;
@@ -193,8 +192,8 @@ CrossfadeView::redraw_curves ()
 
        for (int i = 0, pci = 0; i < npoints; ++i) {
                Art::Point &p = (*points)[pci++];
-               p.set_x(i);
-               p.set_y(2.0 + _height - (_height * vec[i]));
+               p.set_x (i + 1);
+               p.set_y (_height - ((_height - 2) * vec[i]));
        }
        
        fade_out->property_points() = *points;
@@ -263,3 +262,9 @@ CrossfadeView::fake_hide ()
 {
        group->hide();
 }
+
+void
+CrossfadeView::crossfade_fades_changed ()
+{
+       redraw_curves ();
+}