Reintroduce crossfade views for tracks in stacked region mode.
authorCarl Hetherington <carl@carlh.net>
Wed, 26 Aug 2009 01:49:08 +0000 (01:49 +0000)
committerCarl Hetherington <carl@carlh.net>
Wed, 26 Aug 2009 01:49:08 +0000 (01:49 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@5594 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/audio_streamview.cc
gtk2_ardour/audio_streamview.h
gtk2_ardour/crossfade_view.cc
gtk2_ardour/crossfade_view.h

index 99755d6a975ee215386aad7f63a84360b80e8af9..901828bb4e97af123977701878fe0ef374d6a3a0 100644 (file)
@@ -313,7 +313,7 @@ AudioStreamView::add_crossfade (boost::shared_ptr<Crossfade> crossfade)
 
        CrossfadeViewList::iterator i = crossfade_views.find (crossfade);
        if (i != crossfade_views.end()) {
-               if (!crossfades_visible || _layer_display == Stacked) {
+               if (!crossfades_visible) {
                        i->second->hide();
                } else {
                        i->second->show ();
@@ -344,9 +344,11 @@ AudioStreamView::add_crossfade (boost::shared_ptr<Crossfade> crossfade)
        cv->set_valid (true);
        crossfade->Invalidated.connect (mem_fun (*this, &AudioStreamView::remove_crossfade));
        crossfade_views[cv->crossfade] = cv;
-       if (!_trackview.session().config.get_xfades_visible() || !crossfades_visible || _layer_display == Stacked) {
+       if (!_trackview.session().config.get_xfades_visible() || !crossfades_visible) {
                cv->hide ();
        }
+
+       update_content_height (cv);
 }
 
 void
@@ -380,7 +382,7 @@ AudioStreamView::redisplay_diskstream ()
        // Flag crossfade views as invalid
        for (xi = crossfade_views.begin(); xi != crossfade_views.end(); ++xi) {
                xi->second->set_valid (false);
-               if (xi->second->visible() && _layer_display != Stacked) {
+               if (xi->second->visible()) {
                        xi->second->show ();
                }
        }
@@ -771,7 +773,7 @@ void
 AudioStreamView::reveal_xfades_involving (AudioRegionView& rv)
 {
        for (CrossfadeViewList::iterator i = crossfade_views.begin(); i != crossfade_views.end(); ++i) {
-               if (i->second->crossfade->involves (rv.audio_region()) && i->second->visible() && _layer_display != Stacked) {
+               if (i->second->crossfade->involves (rv.audio_region()) && i->second->visible()) {
                        i->second->show ();
                }
        }
@@ -799,14 +801,35 @@ void
 AudioStreamView::update_contents_height ()
 {
        StreamView::update_contents_height ();
-       
+
        for (CrossfadeViewList::iterator i = crossfade_views.begin(); i != crossfade_views.end(); ++i) {
-               if (_layer_display == Overlaid) {
-                       i->second->show ();
-                       i->second->set_height (height);
-               } else {
-                       i->second->hide ();
-               }
+               update_content_height (i->second);
+       }
+}
+
+void
+AudioStreamView::update_content_height (CrossfadeView* cv)
+{
+       cv->show ();
+       
+       if (_layer_display == Overlaid) {
+               
+               cv->set_y (0);
+               cv->set_height (height);
+               
+       } else {
+               
+               layer_t const inl = cv->crossfade->in()->layer ();
+               layer_t const outl = cv->crossfade->out()->layer ();
+
+               layer_t const high = max (inl, outl);
+               layer_t const low = min (inl, outl);
+               
+               const double h = child_height ();
+
+               cv->set_y ((_layers - high - 1) * h);
+               cv->set_height ((high - low + 1) * h);
+               
        }
 }
 
index 19254c03125a0e009d0fda9a1b7470b1a7f73830..8173e9bfb7c1805a85b67a16c6ced277a108832f 100644 (file)
@@ -100,6 +100,7 @@ class AudioStreamView : public StreamView
        void color_handler ();
 
        void update_contents_height ();
+       void update_content_height (CrossfadeView *);
 
        void parameter_changed (std::string const &);
        void set_waveform_shape (ARDOUR::WaveformShape);
index 521c33240a817b6260337cfc9dc1a72b3e74a5cb..152e1bf5c0dd5e2247e207cb7d8cf9b8d4a6efa1 100644 (file)
@@ -109,12 +109,16 @@ CrossfadeView::reset_width_dependent_items (double pixel_width)
 void
 CrossfadeView::set_height (double height)
 {
+       double h = 0;
        if (height <= TimeAxisView::hSmaller) {
-               TimeAxisViewItem::set_height (height - 3);
+               h = height - 3;
        } else {
-               TimeAxisViewItem::set_height (height - NAME_HIGHLIGHT_SIZE - 3 );
+               h = height - NAME_HIGHLIGHT_SIZE - 3;
        }
 
+       TimeAxisViewItem::set_height (h);
+
+       _height = h;
        redraw_curves ();
 }
 
@@ -150,7 +154,6 @@ CrossfadeView::redraw_curves ()
        Points* points; 
        int32_t npoints;
        float* vec;
-       double h;
 
        if (!crossfade->following_overlap()) {
                /* curves should not be visible */
@@ -159,20 +162,7 @@ CrossfadeView::redraw_curves ()
                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.
-        */
-
-       double tav_height = get_time_axis_view().current_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) {
+       if (_height < 0) {
                /* no space allocated yet */
                return;
        }
@@ -197,7 +187,7 @@ 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 + h - (h * vec[i]));
+               p.set_y(2.0 + _height - (_height * vec[i]));
        }
        fade_in->property_points() = *points;
 
@@ -205,7 +195,7 @@ 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 + h - (h * vec[i]));
+               p.set_y(2.0 + _height - (_height * vec[i]));
        }
        fade_out->property_points() = *points;
 
index fc41f7f7219278bf755b12d8e1bf155197996f0b..2d9c5e4b2df4af623ea61246637dc3c68bbaaa52 100644 (file)
@@ -77,7 +77,7 @@ struct CrossfadeView : public TimeAxisViewItem
 
     void crossfade_changed (ARDOUR::Change);
     void active_changed ();
-    void redraw_curves ();
+       void redraw_curves ();
        void color_handler ();
 };