add set-session-extents-from-edit-range
authorBen Loftis <ben@harrisonconsoles.com>
Tue, 9 Dec 2014 22:17:47 +0000 (16:17 -0600)
committerBen Loftis <ben@harrisonconsoles.com>
Tue, 9 Dec 2014 22:18:47 +0000 (16:18 -0600)
gtk2_ardour/editor.cc
gtk2_ardour/editor.h
gtk2_ardour/editor_actions.cc
gtk2_ardour/editor_ops.cc
libs/ardour/ardour/session.h
libs/ardour/session.cc

index 0b2f091fa496d66ae431c09a1cd86f8c1bdd99aa..13d6f904983017ba8438a59449c7086f88975e72 100644 (file)
@@ -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)));
index 5147749ae9f18cdbca7fdb1842aa7ee8416e4741..f4c8dd51cba1d72923ef81acf8314907a5f9ab73 100644 (file)
@@ -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 ();
index 817d69be7b54b0409b6b176503a5ff06861a1781..befd2fa1ae50c5ac955564c3bdd11f4bb83d4d2a 100644 (file)
@@ -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));
index f975c8df7ff29ca8c8a4a7b5879b7844ee3954f7..aa0f316467b45d1d87fb7a48a67d3815aac6a9e6 100644 (file)
@@ -5901,6 +5901,34 @@ Editor::set_punch_from_selection ()
        set_punch_range (start, end,  _("set punch range 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 ()
 {
index 86d8c6659388d9ca16f10d74cf5dc1bee6f0105c..9af744e2ec464a75f8423b530e71052d4cee2ff5 100644 (file)
@@ -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; }
index 9c5b6fdccf242b0861f6e3f0ba54fd9770d4d689..4710ea1534dfadfaa8b11f8aef33b46c22bcb924 100644 (file)
@@ -1246,6 +1246,25 @@ Session::set_auto_punch_location (Location* location)
        auto_punch_location_changed (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)
 {