mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-07 22:25:46 +01:00
[Summary] Made correct region to be cut, when multiple rage selection are present.
This commit is contained in:
parent
6a7c5b40a5
commit
ea7ba3ed57
3 changed files with 73 additions and 34 deletions
|
|
@ -1195,8 +1195,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
|
|||
void keyboard_paste ();
|
||||
|
||||
void region_from_selection ();
|
||||
void create_region_from_selection (std::vector<boost::shared_ptr<ARDOUR::Region> >&);
|
||||
void cut_region_from_selection (std::vector<boost::shared_ptr<ARDOUR::Region> >&);
|
||||
void create_region_from_selection (std::vector<boost::shared_ptr<ARDOUR::Region> >&, RouteTimeAxisView*);
|
||||
void cut_region_from_selection (std::vector<boost::shared_ptr<ARDOUR::Region> >&, RouteTimeAxisView*);
|
||||
|
||||
void play_from_start ();
|
||||
void play_from_edit_point ();
|
||||
|
|
@ -1408,7 +1408,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
|
|||
void start_create_region_grab (ArdourCanvas::Item*, GdkEvent*);
|
||||
void add_region_copy_drag (ArdourCanvas::Item*, GdkEvent*, RegionView*);
|
||||
void add_region_brush_drag (ArdourCanvas::Item*, GdkEvent*, RegionView*);
|
||||
void start_selection_grab (ArdourCanvas::Item*, GdkEvent*, bool copy = false);
|
||||
void start_selection_grab (ArdourCanvas::Item*, RouteTimeAxisView*, GdkEvent*, bool copy = false);
|
||||
|
||||
void region_view_item_click (AudioRegionView&, GdkEventButton*);
|
||||
|
||||
|
|
|
|||
|
|
@ -761,7 +761,12 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT
|
|||
// of the ruler, timebar, loopbar, skipbar and markerbar
|
||||
double axis_view_offset = timebar_height + ruler_height +loopbar_height + marker_height + skipbar_height;
|
||||
pair<TimeAxisView*, int> tvp = trackview_by_y_position (y - axis_view_offset );
|
||||
if (get_smart_mode() && tvp.first) {
|
||||
|
||||
if (!tvp.first) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (get_smart_mode() ) {
|
||||
AutomationTimeAxisView* atv = dynamic_cast<AutomationTimeAxisView*> (tvp.first);
|
||||
if (atv) {
|
||||
/* smart "join" mode: drag automation */
|
||||
|
|
@ -775,7 +780,8 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT
|
|||
separate-drag the selection. Well actually, Igor@Waves
|
||||
decided this, so here it is.
|
||||
*/
|
||||
start_selection_grab (item, event, copy);
|
||||
RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (tvp.first);
|
||||
start_selection_grab (item, rtv, event, copy);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -2436,9 +2442,9 @@ Editor::add_region_brush_drag (ArdourCanvas::Item* item, GdkEvent*, RegionView*
|
|||
* the section of the clicked region that lies within the time range.
|
||||
*/
|
||||
void
|
||||
Editor::start_selection_grab (ArdourCanvas::Item* /*item*/, GdkEvent* event, bool copy/*=false*/)
|
||||
Editor::start_selection_grab (ArdourCanvas::Item* item, RouteTimeAxisView* rtv, GdkEvent* event, bool copy/*=false*/)
|
||||
{
|
||||
if (clicked_regionview == 0) {
|
||||
if (rtv == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -2448,9 +2454,9 @@ Editor::start_selection_grab (ArdourCanvas::Item* /*item*/, GdkEvent* event, boo
|
|||
|
||||
begin_reversible_command (_("new region for selection drag"));
|
||||
if (copy) {
|
||||
create_region_from_selection (new_regions);
|
||||
create_region_from_selection (new_regions, rtv);
|
||||
} else {
|
||||
cut_region_from_selection (new_regions);
|
||||
cut_region_from_selection (new_regions, rtv);
|
||||
}
|
||||
commit_reversible_command ();
|
||||
|
||||
|
|
@ -2469,7 +2475,7 @@ Editor::start_selection_grab (ArdourCanvas::Item* /*item*/, GdkEvent* event, boo
|
|||
*/
|
||||
|
||||
latest_regionviews.clear();
|
||||
sigc::connection c = clicked_routeview->view()->RegionViewAdded.connect (sigc::mem_fun(*this, &Editor::collect_new_region_view));
|
||||
sigc::connection c = rtv->view()->RegionViewAdded.connect (sigc::mem_fun(*this, &Editor::collect_new_region_view));
|
||||
|
||||
/* A selection grab currently creates two undo/redo operations, one for
|
||||
creating the new region and another for moving it.
|
||||
|
|
@ -2477,10 +2483,10 @@ Editor::start_selection_grab (ArdourCanvas::Item* /*item*/, GdkEvent* event, boo
|
|||
|
||||
begin_reversible_command (Operations::selection_grab);
|
||||
|
||||
boost::shared_ptr<Playlist> playlist = clicked_axisview->playlist();
|
||||
boost::shared_ptr<Playlist> playlist = rtv->playlist();
|
||||
|
||||
playlist->clear_changes ();
|
||||
clicked_routeview->playlist()->add_region (region, selection->time[clicked_selection].start);
|
||||
rtv->playlist()->add_region (region, selection->time[clicked_selection].start);
|
||||
_session->add_command(new StatefulDiffCommand (playlist));
|
||||
|
||||
commit_reversible_command ();
|
||||
|
|
|
|||
|
|
@ -2659,9 +2659,11 @@ Editor::region_from_selection ()
|
|||
}
|
||||
|
||||
void
|
||||
Editor::create_region_from_selection (vector<boost::shared_ptr<Region> >& new_regions)
|
||||
Editor::create_region_from_selection (vector<boost::shared_ptr<Region> >& new_regions, RouteTimeAxisView* rtv)
|
||||
{
|
||||
if (selection->time.empty() || selection->tracks.empty()) {
|
||||
new_regions.clear ();
|
||||
|
||||
if (selection->time.empty() || selection->tracks.empty() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -2671,51 +2673,82 @@ Editor::create_region_from_selection (vector<boost::shared_ptr<Region> >& new_re
|
|||
TrackViewList ts = selection->tracks.filter_to_unique_playlists ();
|
||||
sort_track_selection (ts);
|
||||
|
||||
for (TrackSelection::iterator i = ts.begin(); i != ts.end(); ++i) {
|
||||
boost::shared_ptr<Region> current;
|
||||
if (rtv) {
|
||||
boost::shared_ptr<Region> current;
|
||||
boost::shared_ptr<Playlist> playlist;
|
||||
framepos_t internal_start;
|
||||
string new_name;
|
||||
|
||||
if ((playlist = (*i)->playlist()) == 0) {
|
||||
continue;
|
||||
|
||||
if ((playlist = rtv->playlist()) == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if ((current = playlist->top_region_at(start)) == 0) {
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
internal_start = start - current->position();
|
||||
RegionFactory::region_name (new_name, current->name(), true);
|
||||
|
||||
|
||||
PropertyList plist;
|
||||
|
||||
|
||||
plist.add (ARDOUR::Properties::start, current->start() + internal_start);
|
||||
plist.add (ARDOUR::Properties::length, end - start + 1);
|
||||
plist.add (ARDOUR::Properties::name, new_name);
|
||||
|
||||
|
||||
new_regions.push_back (RegionFactory::create (current, plist));
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
for (TrackSelection::iterator i = ts.begin(); i != ts.end(); ++i) {
|
||||
boost::shared_ptr<Region> current;
|
||||
boost::shared_ptr<Playlist> playlist;
|
||||
framepos_t internal_start;
|
||||
string new_name;
|
||||
|
||||
if ((playlist = (*i)->playlist()) == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((current = playlist->top_region_at(start)) == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
internal_start = start - current->position();
|
||||
RegionFactory::region_name (new_name, current->name(), true);
|
||||
|
||||
PropertyList plist;
|
||||
|
||||
plist.add (ARDOUR::Properties::start, current->start() + internal_start);
|
||||
plist.add (ARDOUR::Properties::length, end - start + 1);
|
||||
plist.add (ARDOUR::Properties::name, new_name);
|
||||
|
||||
new_regions.push_back (RegionFactory::create (current, plist));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Editor::cut_region_from_selection (vector<boost::shared_ptr<Region> >& new_regions)
|
||||
Editor::cut_region_from_selection (vector<boost::shared_ptr<Region> >& new_regions, RouteTimeAxisView* rtv)
|
||||
{
|
||||
if (selection->time.empty() || selection->tracks.empty()) {
|
||||
new_regions.clear();
|
||||
|
||||
if (selection->time.empty() || selection->tracks.empty() || !rtv) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
AudioRange range = selection->time[clicked_selection];
|
||||
clicked_routeview->cut_range(range);
|
||||
clicked_routeview->paste(range.start, 1, *cut_buffer, 0);
|
||||
|
||||
rtv->cut_range(range);
|
||||
rtv->paste(range.start, 1, *cut_buffer, 0);
|
||||
|
||||
boost::shared_ptr<Region> current;
|
||||
boost::shared_ptr<ARDOUR::Playlist> playlist;
|
||||
if ((playlist = clicked_routeview->playlist()) == 0) {
|
||||
if ((playlist = rtv->playlist() ) == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((current = playlist->top_region_at(range.start)) == 0) {
|
||||
if ((current = playlist->top_region_at(range.start) ) == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -4514,7 +4547,7 @@ Editor::duplicate_selection (float times)
|
|||
vector<boost::shared_ptr<Region> > new_regions;
|
||||
vector<boost::shared_ptr<Region> >::iterator ri;
|
||||
|
||||
create_region_from_selection (new_regions);
|
||||
create_region_from_selection (new_regions, NULL);
|
||||
|
||||
if (new_regions.empty()) {
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue