now that regions and range selections are exclusive, the separate actions to set ranges or zoom to selections are redundant. save some menu entries and keybindings by consolidating them. also consolidate some code with new function get_selection_extents(). as a side-effect, this checkin fixes the assert failure in play_with_preroll

This commit is contained in:
Ben Loftis 2015-01-07 15:31:05 -06:00
parent 915a840119
commit a4f7c21ec3
7 changed files with 91 additions and 143 deletions

View File

@ -51,8 +51,6 @@
<menu name='Transport' action='Transport'>
<menuitem action='ToggleRoll'/>
<menu action="PlayMenu">
<menuitem action='main-menu-play-selected-regions'/>
<menuitem action='play-edit-range'/>
<menuitem action='PlaySelection'/>
<menuitem action='PlayPreroll'/>
<menuitem action='play-from-edit-point-and-return'/>
@ -65,14 +63,8 @@
#if 0
<menuitem action='toggle-skip-playback'/>
#endif
<menu action="SetLoopMenu">
<menuitem action='set-loop-from-edit-range'/>
<menuitem action='set-loop-from-region'/>
</menu>
<menu action="SetPunchMenu">
<menuitem action='set-punch-from-edit-range'/>
<menuitem action='set-punch-from-region'/>
</menu>
<menuitem action='set-loop-from-edit-range'/>
<menuitem action='set-punch-from-edit-range'/>
<separator/>
<menuitem action='Forward'/>

View File

@ -267,7 +267,7 @@ if (Profile->get_mixbus())
act = ActionManager::register_action (transport_actions, X_("Loop"), _("Play Loop Range"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_session_auto_loop));
ActionManager::session_sensitive_actions.push_back (act);
ActionManager::transport_sensitive_actions.push_back (act);
act = ActionManager::register_action (transport_actions, X_("PlaySelection"), _("Play Selected Range"), sigc::mem_fun(*this, &ARDOUR_UI::transport_play_selection));
act = ActionManager::register_action (transport_actions, X_("PlaySelection"), _("Play Selection"), sigc::mem_fun(*this, &ARDOUR_UI::transport_play_selection));
ActionManager::session_sensitive_actions.push_back (act);
ActionManager::transport_sensitive_actions.push_back (act);
act = ActionManager::register_action (transport_actions, X_("PlayPreroll"), _("Play Selection w/Preroll"), sigc::mem_fun(*this, &ARDOUR_UI::transport_play_preroll));

View File

@ -1860,9 +1860,9 @@ Editor::add_selection_context_items (Menu_Helpers::MenuList& edit_items)
edit_items.push_back (MenuElem (_("Select All in Range"), sigc::mem_fun(*this, &Editor::select_all_selectables_using_time_selection)));
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 (MenuElem (_("Set Loop from Selection"), sigc::bind (sigc::mem_fun(*this, &Editor::set_loop_from_selection), false)));
edit_items.push_back (MenuElem (_("Set Punch from Selection"), sigc::mem_fun(*this, &Editor::set_punch_from_selection)));
edit_items.push_back (MenuElem (_("Set Session Start/End from Selection"), 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

@ -242,6 +242,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
/* selection */
Selection& get_selection() const { return *selection; }
bool get_selection_extents ( framepos_t &start, framepos_t &end ); // the time extents of the current selection, whether Range, Region(s), Control Points, or Notes
Selection& get_cut_buffer() const { return *cut_buffer; }
void track_mixer_selection ();
@ -1425,9 +1426,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
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 ();
void set_loop_range (framepos_t start, framepos_t end, std::string cmd);
void set_punch_range (framepos_t start, framepos_t end, std::string cmd);

View File

@ -295,9 +295,9 @@ Editor::register_actions ()
toggle_reg_sens (editor_actions, "toggle-skip-playback", _("Use Skip Ranges"), sigc::mem_fun(*this, &Editor::toggle_skip_playback));
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));
reg_sens (editor_actions, "set-loop-from-edit-range", _("Set Loop from Selection"), sigc::bind (sigc::mem_fun(*this, &Editor::set_loop_from_selection), false));
reg_sens (editor_actions, "set-punch-from-edit-range", _("Set Punch from Selection"), sigc::mem_fun(*this, &Editor::set_punch_from_selection));
reg_sens (editor_actions, "set-session-from-edit-range", _("Set Session Start/End from Selection"), 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

@ -1712,29 +1712,9 @@ Editor::temporal_zoom_region (bool both_axes)
framepos_t end = 0;
set<TimeAxisView*> tracks;
RegionSelection rs = get_regions_from_selection_and_entered ();
if (rs.empty()) {
if ( !get_selection_extents(start, end) )
return;
}
for (RegionSelection::iterator i = rs.begin(); i != rs.end(); ++i) {
if ((*i)->region()->position() < start) {
start = (*i)->region()->position();
}
if ((*i)->region()->last_frame() + 1 > end) {
end = (*i)->region()->last_frame() + 1;
}
tracks.insert (&((*i)->get_time_axis_view()));
}
if ((start == 0 && end == 0) || end < start) {
return;
}
calc_extra_zoom_edges (start, end);
/* if we're zooming on both axes we need to save track heights etc.
@ -1772,6 +1752,46 @@ Editor::temporal_zoom_region (bool both_axes)
}
bool
Editor::get_selection_extents ( framepos_t &start, framepos_t &end )
{
start = max_framepos;
end = 0;
bool ret = true;
//ToDo: if notes are selected, set extents to that selection
//ToDo: if control points are selected, set extents to that selection
if ( !selection->regions.empty() ) {
RegionSelection rs = get_regions_from_selection_and_entered ();
for (RegionSelection::iterator i = rs.begin(); i != rs.end(); ++i) {
if ((*i)->region()->position() < start) {
start = (*i)->region()->position();
}
if ((*i)->region()->last_frame() + 1 > end) {
end = (*i)->region()->last_frame() + 1;
}
}
} else if (!selection->time.empty()) {
start = selection->time.start();
end = selection->time.end_frame();
} else
ret = false; //no selection found
//range check
if ((start == 0 && end == 0) || end < start) {
ret = false;
}
return ret;
}
void
Editor::temporal_zoom_selection (bool both_axes)
{
@ -1788,16 +1808,14 @@ Editor::temporal_zoom_selection (bool both_axes)
//if a range is selected, zoom to that
if (!selection->time.empty()) {
framepos_t start = selection->time.start();
framepos_t end = selection->time.end_frame();
calc_extra_zoom_edges(start, end);
temporal_zoom_by_frame (start, end);
framepos_t start, end;
if (get_selection_extents (start, end)) {
calc_extra_zoom_edges(start, end);
temporal_zoom_by_frame (start, end);
}
if (both_axes)
fit_selected_tracks();
}
}
@ -2342,11 +2360,15 @@ Editor::play_from_edit_point_and_return ()
void
Editor::play_selection ()
{
if (selection->time.empty()) {
framepos_t start, end;
if (!get_selection_extents ( start, end))
return;
}
_session->request_play_range (&selection->time, true);
AudioRange ar (start, end, 0);
list<AudioRange> lar;
lar.push_back (ar);
_session->request_play_range (&lar, true);
}
framepos_t
@ -2379,16 +2401,17 @@ Editor::maybe_locate_with_edit_preroll ( framepos_t location )
void
Editor::play_with_preroll ()
{
if (selection->time.empty()) {
return;
} else {
{
framepos_t preroll = get_preroll();
framepos_t start = 0;
if (selection->time[clicked_selection].start > preroll)
start = selection->time[clicked_selection].start - preroll;
framepos_t start, end;
if (!get_selection_extents ( start, end))
return;
if (start > preroll)
start = start - preroll;
framepos_t end = selection->time[clicked_selection].end + preroll;
end = end + preroll; //"post-roll"
AudioRange ar (start, end, 0);
list<AudioRange> lar;
@ -5859,12 +5882,13 @@ Editor::select_prev_route()
void
Editor::set_loop_from_selection (bool play)
{
if (_session == 0 || selection->time.empty()) {
if (_session == 0) {
return;
}
framepos_t start = selection->time[clicked_selection].start;
framepos_t end = selection->time[clicked_selection].end;
framepos_t start, end;
if (!get_selection_extents ( start, end))
return;
set_loop_range (start, end, _("set loop range from selection"));
@ -5874,48 +5898,12 @@ Editor::set_loop_from_selection (bool play)
}
}
void
Editor::set_loop_from_edit_range (bool play)
{
if (_session == 0) {
return;
}
framepos_t start;
framepos_t end;
if (!get_edit_op_range (start, end)) {
return;
}
set_loop_range (start, end, _("set loop range from edit range"));
if (play) {
_session->request_locate (start, true);
_session->request_play_loop (true);
}
}
void
Editor::set_loop_from_region (bool play)
{
framepos_t start = max_framepos;
framepos_t end = 0;
RegionSelection rs = get_regions_from_selection_and_entered ();
if (rs.empty()) {
framepos_t start, end;
if (!get_selection_extents ( start, end))
return;
}
for (RegionSelection::iterator i = rs.begin(); i != rs.end(); ++i) {
if ((*i)->region()->position() < start) {
start = (*i)->region()->position();
}
if ((*i)->region()->last_frame() + 1 > end) {
end = (*i)->region()->last_frame() + 1;
}
}
set_loop_range (start, end, _("set loop range from region"));
@ -5928,12 +5916,13 @@ Editor::set_loop_from_region (bool play)
void
Editor::set_punch_from_selection ()
{
if (_session == 0 || selection->time.empty()) {
if (_session == 0) {
return;
}
framepos_t start = selection->time[clicked_selection].start;
framepos_t end = selection->time[clicked_selection].end;
framepos_t start, end;
if (!get_selection_extents ( start, end))
return;
set_punch_range (start, end, _("set punch range from selection"));
}
@ -5941,15 +5930,16 @@ Editor::set_punch_from_selection ()
void
Editor::set_session_extents_from_selection ()
{
if (_session == 0 || selection->time.empty()) {
if (_session == 0) {
return;
}
framepos_t start, end;
if (!get_selection_extents ( start, end))
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
@ -5966,43 +5956,12 @@ Editor::set_session_extents_from_selection ()
}
}
void
Editor::set_punch_from_edit_range ()
{
if (_session == 0) {
return;
}
framepos_t start;
framepos_t end;
if (!get_edit_op_range (start, end)) {
return;
}
set_punch_range (start, end, _("set punch range from edit range"));
}
void
Editor::set_punch_from_region ()
{
framepos_t start = max_framepos;
framepos_t end = 0;
RegionSelection rs = get_regions_from_selection_and_entered ();
if (rs.empty()) {
framepos_t start, end;
if (!get_selection_extents ( start, end))
return;
}
for (RegionSelection::iterator i = rs.begin(); i != rs.end(); ++i) {
if ((*i)->region()->position() < start) {
start = (*i)->region()->position();
}
if ((*i)->region()->last_frame() + 1 > end) {
end = (*i)->region()->last_frame() + 1;
}
}
set_punch_range (start, end, _("set punch range from region"));
}

View File

@ -98,7 +98,7 @@ This mode provides many different operations on both regions and control points,
@eep|Editor/cycle-edit-point-with-marker|<@PRIMARY@>grave|next EP w/marker
@trans|Transport/ToggleRoll|space|toggle roll
@epp|Editor/play-edit-range|<@SECONDARY@>space|play edit range
@epp|Editor/PlaySelection|<@SECONDARY@>space|play edit range
@epp|Editor/play-from-edit-point-and-return|<@LEVEL4@>space|play from EP \& return
@trans|Transport/ToggleRollMaybe|<@PRIMARY@><@SECONDARY@>space|stop (keep loop/range play)
@trans|Transport/ToggleRollForgetCapture|<@PRIMARY@>space|stop and destroy
@ -119,10 +119,8 @@ This mode provides many different operations on both regions and control points,
@eep|Editor/trim-to-next-region|<@PRIMARY@>k|trim region to start of next region
@ranges|Editor/set-loop-from-edit-range|bracketright|set loop range from edit range
@ranges|Region/set-loop-from-region|<@SECONDARY@>bracketright|set loop range from region(s)
@ranges|Editor/set-punch-from-edit-range|bracketleft|set punch range from edit range
@ranges|Region/set-punch-from-region|<@SECONDARY@>bracketleft|set punch range from region(s)
@rop|Region/boost-region-gain|asciicircum|increase region gain
@rop|Region/cut-region-gain|ampersand|reduce region gain