summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk2_ardour/editor.cc1
-rw-r--r--gtk2_ardour/editor.h2
-rw-r--r--gtk2_ardour/editor_actions.cc1
-rw-r--r--gtk2_ardour/editor_ops.cc28
-rw-r--r--libs/ardour/ardour/session.h1
-rw-r--r--libs/ardour/session.cc19
6 files changed, 52 insertions, 0 deletions
diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc
index 0b2f091fa4..13d6f90498 100644
--- a/gtk2_ardour/editor.cc
+++ b/gtk2_ardour/editor.cc
@@ -1845,6 +1845,7 @@ Editor::add_selection_context_items (Menu_Helpers::MenuList& edit_items)
edit_items.push_back (SeparatorElem());
edit_items.push_back (MenuElem (_("Set Loop from Range"), sigc::bind (sigc::mem_fun(*this, &Editor::set_loop_from_selection), false)));
edit_items.push_back (MenuElem (_("Set Punch from Range"), sigc::mem_fun(*this, &Editor::set_punch_from_selection)));
+ edit_items.push_back (MenuElem (_("Set Session Start/End from Range"), sigc::mem_fun(*this, &Editor::set_session_extents_from_selection)));
edit_items.push_back (SeparatorElem());
edit_items.push_back (MenuElem (_("Add Range Markers"), sigc::mem_fun (*this, &Editor::add_location_from_selection)));
diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h
index 5147749ae9..f4c8dd51cb 100644
--- a/gtk2_ardour/editor.h
+++ b/gtk2_ardour/editor.h
@@ -1347,6 +1347,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
void set_punch_from_selection ();
void set_punch_from_region ();
+ void set_session_extents_from_selection ();
+
void set_loop_from_edit_range (bool play);
void set_loop_from_region (bool play);
void set_punch_from_edit_range ();
diff --git a/gtk2_ardour/editor_actions.cc b/gtk2_ardour/editor_actions.cc
index 817d69be7b..befd2fa1ae 100644
--- a/gtk2_ardour/editor_actions.cc
+++ b/gtk2_ardour/editor_actions.cc
@@ -299,6 +299,7 @@ Editor::register_actions ()
reg_sens (editor_actions, "set-loop-from-edit-range", _("Set Loop from Edit Range"), sigc::bind (sigc::mem_fun(*this, &Editor::set_loop_from_edit_range), false));
reg_sens (editor_actions, "set-punch-from-edit-range", _("Set Punch from Edit Range"), sigc::mem_fun(*this, &Editor::set_punch_from_edit_range));
+ reg_sens (editor_actions, "set-session-from-edit-range", _("Set Session Start/End from Edit Range"), sigc::mem_fun(*this, &Editor::set_session_extents_from_selection));
/* this is a duplicated action so that the main menu can use a different label */
reg_sens (editor_actions, "main-menu-play-selected-regions", _("Play Selected Regions"), sigc::mem_fun (*this, &Editor::play_selected_region));
diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc
index f975c8df7f..aa0f316467 100644
--- a/gtk2_ardour/editor_ops.cc
+++ b/gtk2_ardour/editor_ops.cc
@@ -5902,6 +5902,34 @@ Editor::set_punch_from_selection ()
}
void
+Editor::set_session_extents_from_selection ()
+{
+ if (_session == 0 || selection->time.empty()) {
+ return;
+ }
+
+ begin_reversible_command (_("set session start/stop from selection"));
+
+ framepos_t start = selection->time[clicked_selection].start;
+ framepos_t end = selection->time[clicked_selection].end;
+
+ Location* loc;
+ if ((loc = _session->locations()->session_range_location()) == 0) {
+ _session->set_session_extents ( start, end ); // this will create a new session range; no need for UNDO
+ } else {
+ XMLNode &before = loc->get_state();
+
+ _session->set_session_extents ( start, end );
+
+ XMLNode &after = loc->get_state();
+
+ _session->add_command (new MementoCommand<Location>(*loc, &before, &after));
+
+ commit_reversible_command ();
+ }
+}
+
+void
Editor::set_punch_from_edit_range ()
{
if (_session == 0) {
diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h
index 86d8c66593..9af744e2ec 100644
--- a/libs/ardour/ardour/session.h
+++ b/libs/ardour/ardour/session.h
@@ -384,6 +384,7 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
void set_auto_punch_location (Location *);
void set_auto_loop_location (Location *);
+ void set_session_extents (framepos_t start, framepos_t end);
int location_name(std::string& result, std::string base = std::string(""));
pframes_t get_block_size() const { return current_block_size; }
diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc
index 9c5b6fdccf..4710ea1534 100644
--- a/libs/ardour/session.cc
+++ b/libs/ardour/session.cc
@@ -1247,6 +1247,25 @@ Session::set_auto_punch_location (Location* location)
}
void
+Session::set_session_extents (framepos_t start, framepos_t end)
+{
+ Location* existing;
+ if ((existing = _locations->session_range_location()) == 0) {
+ //if there is no existing session, we need to make a new session location (should never happen)
+ existing = new Location (*this, 0, 0, _("session"), Location::IsSessionRange);
+ }
+
+ if (end <= start) {
+ error << _("Session: you can't use that location for session start/end)") << endmsg;
+ return;
+ }
+
+ existing->set( start, end );
+
+ set_dirty();
+}
+
+void
Session::set_auto_loop_location (Location* location)
{
Location* existing;