From 8934ff78678cafeb03c398e7add299f2bc1a730d Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 26 Aug 2009 01:49:08 +0000 Subject: [PATCH] Reintroduce crossfade views for tracks in stacked region mode. git-svn-id: svn://localhost/ardour2/branches/3.0@5594 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/audio_streamview.cc | 45 +++++++++++++++++++++++++-------- gtk2_ardour/audio_streamview.h | 1 + gtk2_ardour/crossfade_view.cc | 28 +++++++------------- gtk2_ardour/crossfade_view.h | 2 +- 4 files changed, 45 insertions(+), 31 deletions(-) diff --git a/gtk2_ardour/audio_streamview.cc b/gtk2_ardour/audio_streamview.cc index 99755d6a97..901828bb4e 100644 --- a/gtk2_ardour/audio_streamview.cc +++ b/gtk2_ardour/audio_streamview.cc @@ -313,7 +313,7 @@ AudioStreamView::add_crossfade (boost::shared_ptr 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) 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); + } } diff --git a/gtk2_ardour/audio_streamview.h b/gtk2_ardour/audio_streamview.h index 19254c0312..8173e9bfb7 100644 --- a/gtk2_ardour/audio_streamview.h +++ b/gtk2_ardour/audio_streamview.h @@ -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); diff --git a/gtk2_ardour/crossfade_view.cc b/gtk2_ardour/crossfade_view.cc index 521c33240a..152e1bf5c0 100644 --- a/gtk2_ardour/crossfade_view.cc +++ b/gtk2_ardour/crossfade_view.cc @@ -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; diff --git a/gtk2_ardour/crossfade_view.h b/gtk2_ardour/crossfade_view.h index fc41f7f721..2d9c5e4b2d 100644 --- a/gtk2_ardour/crossfade_view.h +++ b/gtk2_ardour/crossfade_view.h @@ -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 (); }; -- 2.30.2