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)));
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 ();
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));
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 ()
{
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; }
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)
{