View Issue Details

IDProjectCategoryView StatusLast Update
0005635ardourfeaturespublic2013-08-15 16:02
Reportertom_ Assigned To 
PrioritynormalSeverityfeatureReproducibilityN/A
Status closedResolutionwon't fix 
Product Version3.0 
Summary0005635: Add Action to put a Selection of Regions into a contiguous Sequence
Description
consider a track/region situation:

track1 |region a|----|region b|---|region c|-
track2 -------|region d|---------------------

when all regions a-d are selected and action 'Sequence Regions' is called, the positions will be changed as follows:

track1 |region a|--------|region b|region c|-
track2 ---------|region d|-------------------

all regions will be placed after the region that appears first on the timeline.
Additional Information
the attached patch inserts menu action in

-context menu on region:
   Selected Regions -> Position -> Sequence Regions

-top level menu:
   Region -> Position -> Sequence Regions
TagsNo tags attached.

Activities

2013-08-07 14:59

 

add_editor_action_sequence-regions.patch (3,909 bytes)   
From f78cd9fe34019911e797cbfe302134287727dc9a Mon Sep 17 00:00:00 2001
From: Thomas Brand <tom@trellis.ch>
Date: Wed, 7 Aug 2013 16:51:04 +0200
Subject: [PATCH] new editor action sequence_regions

---
 gtk2_ardour/ardour.menus.in   |    2 ++
 gtk2_ardour/editor.h          |    2 ++
 gtk2_ardour/editor_actions.cc |    2 ++
 gtk2_ardour/editor_ops.cc     |   59 +++++++++++++++++++++++++++++++++++++++++
 4 files changed, 65 insertions(+)

diff --git a/gtk2_ardour/ardour.menus.in b/gtk2_ardour/ardour.menus.in
index 15f1bde..b920eaf 100644
--- a/gtk2_ardour/ardour.menus.in
+++ b/gtk2_ardour/ardour.menus.in
@@ -291,6 +291,7 @@
         <menuitem action='nudge-backward'/>
         <menuitem action='nudge-forward-by-capture-offset'/>
         <menuitem action='nudge-backward-by-capture-offset'/>
+	<menuitem action='sequence-regions'/>
       </menu>
       <menu action='RegionMenuTrim'>
         <menuitem action='trim-front'/>
@@ -667,6 +668,7 @@
       <menuitem action='nudge-backward'/>
       <menuitem action='nudge-forward-by-capture-offset'/>
       <menuitem action='nudge-backward-by-capture-offset'/>
+      <menuitem action='sequence-regions'/>
     </menu>
     <menu action='RegionMenuTrim'>
       <menuitem action='trim-front'/>
diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h
index 033888c..9474f4c 100644
--- a/gtk2_ardour/editor.h
+++ b/gtk2_ardour/editor.h
@@ -342,6 +342,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
 	void nudge_forward_capture_offset ();
 	void nudge_backward_capture_offset ();
 
+	void sequence_regions ();
+
 	/* playhead/screen stuff */
 
 	void set_stationary_playhead (bool yn);
diff --git a/gtk2_ardour/editor_actions.cc b/gtk2_ardour/editor_actions.cc
index a5e2e8a..6d84b9b 100644
--- a/gtk2_ardour/editor_actions.cc
+++ b/gtk2_ardour/editor_actions.cc
@@ -1892,6 +1892,8 @@ Editor::register_region_actions ()
 	reg_sens (_region_actions, "nudge-forward", _("Nudge Later"), sigc::bind (sigc::mem_fun (*this, &Editor::nudge_forward), false, false));
 	reg_sens (_region_actions, "nudge-backward", _("Nudge Earlier"), sigc::bind (sigc::mem_fun (*this, &Editor::nudge_backward), false, false));
 
+	reg_sens (_region_actions, "sequence-regions", _("Sequence Regions"), sigc::mem_fun (*this, &Editor::sequence_regions));
+
 	reg_sens (
 		_region_actions,
 		"nudge-forward-by-capture-offset",
diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc
index 93a53dd..d6096f1 100644
--- a/gtk2_ardour/editor_ops.cc
+++ b/gtk2_ardour/editor_ops.cc
@@ -509,6 +509,65 @@ Editor::nudge_backward_capture_offset ()
 	commit_reversible_command ();
 }
 
+struct RegionSelectionPositionSorter {
+        bool operator() (RegionView* a, RegionView* b) {
+                return a->region()->position() < b->region()->position();
+        }
+};
+
+void
+Editor::sequence_regions ()
+{
+	framepos_t r_end;
+	framepos_t r_end_prev;
+
+	int iCount=0;
+
+	if (!_session) {
+		return;
+	}
+
+	RegionSelection rs = get_regions_from_selection_and_entered ();
+	rs.sort(RegionSelectionPositionSorter());
+
+	if (!rs.empty()) {
+
+		begin_reversible_command (_("sequence regions"));
+
+		for (RegionSelection::iterator i = rs.begin(); i != rs.end(); ++i) {
+			boost::shared_ptr<Region> r ((*i)->region());
+
+			r->clear_changes();
+
+			if(r->locked())
+			{
+				continue;
+			}
+			if(r->position_locked())
+			{
+				continue;
+			}
+/*
+			cerr << "START POSITION " << r->position() << " # " << iCount << "\n";
+			cerr << "LENGTH " << r->length() << "\n";
+			cerr << "END " << (r->position() + r->length()) << "\n";
+*/
+			if(iCount>0)
+			{
+				r_end_prev=r_end;
+				r->set_position(r_end_prev);
+			}
+
+			_session->add_command (new StatefulDiffCommand (r));
+
+			r_end=r->position() + r->length();
+
+			iCount++;
+		}
+		commit_reversible_command ();
+	} 
+} 
+
 /* DISPLAY MOTION */
 
 void
-- 
1.7.9.5

tom_

2013-08-15 16:02

reporter   ~0015264

handling via github / pull requests to keep current

Issue History

Date Modified Username Field Change
2013-08-07 14:59 tom_ New Issue
2013-08-07 14:59 tom_ File Added: add_editor_action_sequence-regions.patch
2013-08-15 16:02 tom_ Note Added: 0015264
2013-08-15 16:02 tom_ Status new => closed
2013-08-15 16:02 tom_ Resolution open => won't fix