add set-session-extents-from-edit-range

This commit is contained in:
Ben Loftis 2014-12-09 16:17:47 -06:00
parent 1e0c1751a5
commit e66752cec1
6 changed files with 52 additions and 0 deletions

View 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)));

View 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 ();

View 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));

View 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 ()
{

View 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; }

View 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)
{