diff options
author | Robin Gareus <robin@gareus.org> | 2019-03-27 23:23:33 +0100 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2019-03-27 23:25:28 +0100 |
commit | 0ee6b03144f7f40792aced150ddf6971659fb171 (patch) | |
tree | 2f7391041f81d83271e972437f90849e93e41526 | |
parent | 94271ee862ce9c1209923e141f491f87bb3b1147 (diff) |
Implement multi-region AutomationRange drag/drop
-rw-r--r-- | gtk2_ardour/editor_drag.cc | 29 | ||||
-rw-r--r-- | gtk2_ardour/editor_drag.h | 2 | ||||
-rw-r--r-- | gtk2_ardour/editor_mouse.cc | 30 |
3 files changed, 47 insertions, 14 deletions
diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index ebc5d97bb7..a2cc145ad0 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -6223,7 +6223,7 @@ AutomationRangeDrag::AutomationRangeDrag (Editor* editor, AutomationTimeAxisView } /** Make an AutomationRangeDrag for region gain lines or MIDI controller regions */ -AutomationRangeDrag::AutomationRangeDrag (Editor* editor, RegionView* rv, list<AudioRange> const & r) +AutomationRangeDrag::AutomationRangeDrag (Editor* editor, RegionView* rv, list<RegionView*> const & v, list<AudioRange> const & r) : Drag (editor, rv->get_canvas_group ()) , _ranges (r) , _y_origin (rv->get_time_axis_view().y_position()) @@ -6234,17 +6234,21 @@ AutomationRangeDrag::AutomationRangeDrag (Editor* editor, RegionView* rv, list<A list<boost::shared_ptr<AutomationLine> > lines; - AudioRegionView* audio_view; - AutomationRegionView* automation_view; - if ((audio_view = dynamic_cast<AudioRegionView*>(rv))) { - lines.push_back (audio_view->get_gain_line ()); - } else if ((automation_view = dynamic_cast<AutomationRegionView*>(rv))) { - lines.push_back (automation_view->line ()); - _integral = true; - } else { - error << _("Automation range drag created for invalid region type") << endmsg; + bool found_primary = false; + for (list<RegionView*>::const_iterator i = v.begin(); i != v.end(); ++i) { + if (*i == rv) { + found_primary = true; + } + if (AudioRegionView* audio_view = dynamic_cast<AudioRegionView*>(*i)) { + lines.push_back (audio_view->get_gain_line ()); + } else if (AutomationRegionView* automation_view = dynamic_cast<AutomationRegionView*>(*i)) { + lines.push_back (automation_view->line ()); + _integral = true; + } else { + error << _("Automation range drag created for invalid region type") << endmsg; + } } - + assert (found_primary); setup (lines); } @@ -6254,6 +6258,7 @@ AutomationRangeDrag::AutomationRangeDrag (Editor* editor, RegionView* rv, list<A void AutomationRangeDrag::setup (list<boost::shared_ptr<AutomationLine> > const & lines) { + printf ("AutomationRangeDrag::setup %d lines\n", lines.size()); /* find the lines that overlap the ranges being dragged */ list<boost::shared_ptr<AutomationLine> >::const_iterator i = lines.begin (); while (i != lines.end ()) { @@ -6344,7 +6349,7 @@ AutomationRangeDrag::motion (GdkEvent*, bool first_move) } if (first_move) { - _editor->begin_reversible_command (_("automation range move")); + _editor->begin_reversible_command (_("automation range move")); // XXX if (!_ranges.empty()) { diff --git a/gtk2_ardour/editor_drag.h b/gtk2_ardour/editor_drag.h index 7ffb7ef57e..498488cb50 100644 --- a/gtk2_ardour/editor_drag.h +++ b/gtk2_ardour/editor_drag.h @@ -1244,7 +1244,7 @@ class AutomationRangeDrag : public Drag { public: AutomationRangeDrag (Editor *, AutomationTimeAxisView *, std::list<ARDOUR::AudioRange> const &); - AutomationRangeDrag (Editor *, RegionView *, std::list<ARDOUR::AudioRange> const &); + AutomationRangeDrag (Editor *, RegionView *, std::list<RegionView*> const &, std::list<ARDOUR::AudioRange> const &); void start_grab (GdkEvent *, Gdk::Cursor* c = 0); void motion (GdkEvent *, bool); diff --git a/gtk2_ardour/editor_mouse.cc b/gtk2_ardour/editor_mouse.cc index 0e4d6bd322..38db9bcc3a 100644 --- a/gtk2_ardour/editor_mouse.cc +++ b/gtk2_ardour/editor_mouse.cc @@ -1119,7 +1119,35 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT { if (dynamic_cast<AudioRegionView*>(clicked_regionview) || dynamic_cast<AutomationRegionView*>(clicked_regionview)) { - _drags->set (new AutomationRangeDrag (this, clicked_regionview, selection->time), + + /* collect all regions-views in the given range selection + * perhaps this should be a dedicated method: + * Editor::get_region_views_from_range_selection() ? + * except <RegionView*> c-pointer list is not very reliable. + */ + list<RegionView*> rvl; + TrackViewList ts = selection->tracks.filter_to_unique_playlists (); + for (TrackViewList::iterator i = ts.begin(); i != ts.end(); ++i) { + RouteTimeAxisView* tatv; + boost::shared_ptr<Playlist> playlist; + if ((tatv = dynamic_cast<RouteTimeAxisView*> (*i)) == 0) { + continue; + } + if ((playlist = (*i)->playlist()) == 0) { + continue; + } + for (list<AudioRange>::const_iterator j = selection->time.begin(); j != selection->time.end(); ++j) { + boost::shared_ptr<RegionList> rl = playlist->regions_touched (j->start, j->end); + for (RegionList::iterator ir = rl->begin(); ir != rl->end(); ++ir) { + RegionView* rv; + if ((rv = tatv->view()->find_view (*ir)) != 0) { + rvl.push_back (rv); + } + } + } + } + + _drags->set (new AutomationRangeDrag (this, clicked_regionview, rvl, selection->time), event, _cursors->up_down); } else { double const y = event->button.y; |