-AudioStreamView::remove_region_view (boost::weak_ptr<Region> weak_r)
-{
- ENSURE_GUI_THREAD (bind (mem_fun (*this, &AudioStreamView::remove_region_view), weak_r));
-
- boost::shared_ptr<Region> r (weak_r.lock());
-
- if (!r) {
- return;
- }
-
- if (!_trackview.session().deletion_in_progress()) {
-
- for (CrossfadeViewList::iterator i = crossfade_views.begin(); i != crossfade_views.end();) {
- CrossfadeViewList::iterator tmp;
-
- tmp = i;
- ++tmp;
-
- boost::shared_ptr<AudioRegion> ar = boost::dynamic_pointer_cast<AudioRegion>(r);
- if (ar && i->second->crossfade->involves (ar)) {
- delete i->second;
- crossfade_views.erase (i);
- }
-
- i = tmp;
- }
- }
-
- StreamView::remove_region_view(r);
-}
-
-void
-AudioStreamView::undisplay_diskstream ()
-{
- StreamView::undisplay_diskstream();
-
- for (CrossfadeViewList::iterator i = crossfade_views.begin(); i != crossfade_views.end(); ++i) {
- delete i->second;
- }
-
- crossfade_views.clear ();
-}
-
-void
-AudioStreamView::playlist_modified_weak (boost::weak_ptr<Diskstream> ds)
-{
- boost::shared_ptr<Diskstream> sp (ds.lock());
- if (sp) {
- playlist_modified (sp);
- }
-}
-
-void
-AudioStreamView::playlist_modified (boost::shared_ptr<Diskstream> ds)
-{
- /* we do not allow shared_ptr<T> to be bound to slots */
- ENSURE_GUI_THREAD (bind (mem_fun (*this, &AudioStreamView::playlist_modified_weak), ds));
-
- StreamView::playlist_modified (ds);
-
- /* make sure xfades are on top and all the regionviews are stacked correctly. */
-
- for (CrossfadeViewList::iterator i = crossfade_views.begin(); i != crossfade_views.end(); ++i) {
- i->second->get_canvas_group()->raise_to_top();
- }
-}
-
-void
-AudioStreamView::playlist_changed_weak (boost::weak_ptr<Diskstream> ds)
-{
- boost::shared_ptr<Diskstream> sp (ds.lock());
- if (sp) {
- playlist_changed (sp);
- }
-}
-
-void
-AudioStreamView::playlist_changed (boost::shared_ptr<Diskstream> ds)
-{
- ENSURE_GUI_THREAD (bind (
- mem_fun (*this, &AudioStreamView::playlist_changed_weak),
- boost::weak_ptr<Diskstream> (ds)));
-
- StreamView::playlist_changed(ds);
-
- boost::shared_ptr<AudioPlaylist> apl = boost::dynamic_pointer_cast<AudioPlaylist>(ds->playlist());
- if (apl) {
- playlist_connections.push_back (apl->NewCrossfade.connect (
- mem_fun (*this, &AudioStreamView::add_crossfade)));
- }
-}
-
-void
-AudioStreamView::add_crossfade_weak (boost::weak_ptr<Crossfade> crossfade)
-{
- boost::shared_ptr<Crossfade> sp (crossfade.lock());
-
- if (!sp) {
- return;
- }
-
- add_crossfade (sp);
-}
-
-void
-AudioStreamView::add_crossfade (boost::shared_ptr<Crossfade> crossfade)
-{
- AudioRegionView* lview = 0;
- AudioRegionView* rview = 0;
-
- /* we do not allow shared_ptr<T> to be bound to slots */
-
- ENSURE_GUI_THREAD (bind (mem_fun (*this, &AudioStreamView::add_crossfade_weak), boost::weak_ptr<Crossfade> (crossfade)));
-
- /* first see if we already have a CrossfadeView for this Crossfade */
-
- CrossfadeViewList::iterator i = crossfade_views.find (crossfade);
- if (i != crossfade_views.end()) {
- if (!crossfades_visible || _layer_display == Stacked) {
- i->second->hide();
- } else {
- i->second->show ();
- }
- i->second->set_valid (true);
- return;
- }
-
- /* create a new one */
-
- for (list<RegionView *>::iterator i = region_views.begin(); i != region_views.end(); ++i) {
- AudioRegionView* arv = dynamic_cast<AudioRegionView*>(*i);
-
- if (!lview && arv && (arv->region() == crossfade->out())) {
- lview = arv;
- }
- if (!rview && arv && (arv->region() == crossfade->in())) {
- rview = arv;
- }
- }
-
- CrossfadeView *cv = new CrossfadeView (_trackview.canvas_display (),
- _trackview,
- crossfade,
- _samples_per_unit,
- region_color,
- *lview, *rview);
- 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) {
- cv->hide ();
- }
-}
-
-void
-AudioStreamView::remove_crossfade (boost::shared_ptr<Region> r)
-{
- ENSURE_GUI_THREAD (bind (mem_fun (*this, &AudioStreamView::remove_crossfade), r));
-
- boost::shared_ptr<Crossfade> xfade = boost::dynamic_pointer_cast<Crossfade> (r);
-
- for (CrossfadeViewList::iterator i = crossfade_views.begin(); i != crossfade_views.end(); ++i) {
- if (i->second->crossfade == xfade) {
- delete i->second;
- crossfade_views.erase (i);
- break;
- }
- }
-}
-
-void
-AudioStreamView::redisplay_diskstream ()