Fix reference of track after free() (#4795).
[ardour.git] / gtk2_ardour / crossfade_view.cc
index 81f5f4173feb00814d686e809b8a21be5180a364..10792e0a9332abf7abf966577c861077ee01f248 100644 (file)
@@ -25,6 +25,7 @@
 #include "canvas-simplerect.h"
 #include "canvas-curve.h"
 #include "crossfade_view.h"
+#include "global_signals.h"
 #include "gui_thread.h"
 #include "rgb_macros.h"
 #include "audio_time_axis.h"
@@ -56,7 +57,8 @@ CrossfadeView::CrossfadeView (ArdourCanvas::Group *parent,
          crossfade (xf),
          left_view (lview),
          right_view (rview),
-         _all_in_view (false)
+         _all_in_view (false),
+         _child_height (0)
 {
        _valid = true;
        _visible = true;
@@ -108,13 +110,15 @@ CrossfadeView::reset_width_dependent_items (double pixel_width)
 }
 
 void
-CrossfadeView::set_height (double h)
+CrossfadeView::set_heights (double fade_height, double child_height)
 {
-       if (h > TimeAxisView::preset_height (HeightSmall)) {
-               h -= NAME_HIGHLIGHT_SIZE;
+       if (child_height > TimeAxisViewItem::NAME_HIGHLIGHT_THRESH) {
+               fade_height -= NAME_HIGHLIGHT_SIZE;
+               child_height -= NAME_HIGHLIGHT_SIZE;
        }
 
-       TimeAxisViewItem::set_height (h);
+       TimeAxisViewItem::set_height (fade_height);
+       _child_height = child_height;
 
        redraw_curves ();
 }
@@ -178,7 +182,7 @@ CrossfadeView::redraw_curves ()
 
        /* Hence the number of points that we will render */
        int32_t const npoints = editor.frame_to_pixel (max_frames - min_frames);
-       
+
        if (!_visible || !crossfade->active() || npoints < 3) {
                fade_in->hide();
                fade_out->hide();
@@ -202,7 +206,9 @@ CrossfadeView::redraw_curves ()
        for (int i = 0, pci = 0; i < npoints; ++i) {
                Art::Point &p = (*points)[pci++];
                p.set_x (xoff + i + 1);
-               p.set_y (_height - ((_height - 2) * vec[i]));
+
+               double const ho = crossfade->in()->layer() > crossfade->out()->layer() ? _child_height : _height;
+               p.set_y (ho - ((_child_height - 2) * vec[i]));
        }
 
        fade_in->property_points() = *points;
@@ -212,9 +218,11 @@ CrossfadeView::redraw_curves ()
        for (int i = 0, pci = 0; i < npoints; ++i) {
                Art::Point &p = (*points)[pci++];
                p.set_x (xoff + i + 1);
-               p.set_y (_height - ((_height - 2) * vec[i]));
+               
+               double const ho = crossfade->in()->layer() < crossfade->out()->layer() ? _child_height : _height;
+               p.set_y (ho - ((_child_height - 2) * vec[i]));
        }
-       
+
        fade_out->property_points() = *points;
 
        delete [] vec;
@@ -252,16 +260,6 @@ CrossfadeView::set_valid (bool yn)
        _valid = yn;
 }
 
-AudioRegionView&
-CrossfadeView::upper_regionview () const
-{
-       if (left_view.region()->layer() > right_view.region()->layer()) {
-               return left_view;
-       } else {
-               return right_view;
-       }
-}
-
 void
 CrossfadeView::show ()
 {
@@ -297,7 +295,7 @@ CrossfadeView::horizontal_position_changed ()
           the other case where the horizontal position change will uncover `undrawn'
           sections).
        */
-       
+
        if (!_all_in_view) {
                redraw_curves ();
        }