diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2016-08-27 19:57:40 -0400 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2016-08-27 19:57:40 -0400 |
commit | 400f38c7218049f71138a80a50e37ee38de6cd12 (patch) | |
tree | 1f526ce1770e56ccc98562d1e6ec4749590ca3e3 /gtk2_ardour/editor_ops.cc | |
parent | 3a5d394a8ccab28a60ec870a16baa9866c173287 (diff) |
single action punch in5.2
Consecutive execution (e.g. from a control surface button) engages punch in, then punch out, then clears both.
Patch by Nathan Stewart
Diffstat (limited to 'gtk2_ardour/editor_ops.cc')
-rw-r--r-- | gtk2_ardour/editor_ops.cc | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index f7bbf2a166..35415c8f2e 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -6359,6 +6359,59 @@ Editor::set_punch_from_selection () } void +Editor::set_auto_punch_range () +{ + // auto punch in/out button from a single button + // If Punch In is unset, set punch range from playhead to end, enable punch in + // If Punch In is set, the next punch sets Punch Out, unless the playhead has been + // rewound beyond the Punch In marker, in which case that marker will be moved back + // to the current playhead position. + // If punch out is set, it clears the punch range and Punch In/Out buttons + + if (_session == 0) { + return; + } + + Location* tpl = transport_punch_location(); + framepos_t now = playhead_cursor->current_frame(); + framepos_t begin = now; + framepos_t end = _session->current_end_frame(); + + if (!_session->config.get_punch_in()) { + // First Press - set punch in and create range from here to eternity + set_punch_range (begin, end, _("Auto Punch In")); + _session->config.set_punch_in(true); + } else if (tpl && !_session->config.get_punch_out()) { + // Second press - update end range marker and set punch_out + if (now < tpl->start()) { + // playhead has been rewound - move start back and pretend nothing happened + begin = now; + set_punch_range (begin, end, _("Auto Punch In/Out")); + } else { + // normal case for 2nd press - set the punch out + end = playhead_cursor->current_frame (); + set_punch_range (tpl->start(), now, _("Auto Punch In/Out")); + _session->config.set_punch_out(true); + } + } else { + if (_session->config.get_punch_out()) { + _session->config.set_punch_out(false); + } + + if (_session->config.get_punch_in()) { + _session->config.set_punch_in(false); + } + + if (tpl) + { + // third press - unset punch in/out and remove range + _session->locations()->remove(tpl); + } + } + +} + +void Editor::set_session_extents_from_selection () { if (_session == 0) { |