diff options
author | nick_m <mainsbridge@gmail.com> | 2016-05-28 06:50:22 +1000 |
---|---|---|
committer | nick_m <mainsbridge@gmail.com> | 2016-05-28 06:50:22 +1000 |
commit | a924e938aa282a03d7ce146419652187d5e92774 (patch) | |
tree | 0c33cb190870cbcdbd4c9214e928daf202fd2add /gtk2_ardour/editor_drag.cc | |
parent | 0d17c21410bc4b4333ec4d8e50d603dde692dce9 (diff) |
Allow non-musical snap when dragging bbt ruler.
- probably not what the user wants,
unless snapping beats to timecode frames.
Diffstat (limited to 'gtk2_ardour/editor_drag.cc')
-rw-r--r-- | gtk2_ardour/editor_drag.cc | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index ca07c5ffbb..f209aed59d 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -3415,7 +3415,6 @@ TempoMarkerDrag::aborted (bool moved) BBTRulerDrag::BBTRulerDrag (Editor* e, ArdourCanvas::Item* i) : Drag (e, i) , _pulse (0.0) - , _beat (0.0) , _tempo (0) , before_state (0) { @@ -3427,11 +3426,10 @@ void BBTRulerDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor) { Drag::start_grab (event, cursor); - TempoMap& map (_editor->session()->tempo_map()); + _tempo = const_cast<TempoSection*> (&map.tempo_section_at_frame (raw_grab_frame())); ostringstream sstr; - _tempo = const_cast<TempoSection*> (&map.tempo_section_at_frame (raw_grab_frame())); sstr << "^" << fixed << setprecision(3) << map.tempo_at_frame (adjusted_current_frame (event)).beats_per_minute() << "\n"; sstr << "<" << fixed << setprecision(3) << _tempo->beats_per_minute(); show_verbose_cursor_text (sstr.str()); @@ -3444,17 +3442,22 @@ BBTRulerDrag::setup_pointer_frame_offset () TempoMap& map (_editor->session()->tempo_map()); const double beat_at_frame = map.beat_at_frame (raw_grab_frame()); const uint32_t divisions = _editor->get_grid_beat_divisions (0); + double beat = 0.0; + if (divisions > 0) { - _beat = floor (beat_at_frame) + (floor (((beat_at_frame - floor (beat_at_frame)) * divisions)) / divisions); + beat = floor (beat_at_frame) + (floor (((beat_at_frame - floor (beat_at_frame)) * divisions)) / divisions); } else { /* while it makes some sense for the user to determine the division to 'grab', grabbing a bar often leads to confusing results wrt the actual tempo section being altered and the result over steep tempo curves. Use sixteenths. */ - _beat = floor (beat_at_frame) + (floor (((beat_at_frame - floor (beat_at_frame)) * 4)) / 4); + beat = floor (beat_at_frame) + (floor (((beat_at_frame - floor (beat_at_frame)) * 4)) / 4); } - _pulse = map.pulse_at_beat (_beat); - _pointer_frame_offset = raw_grab_frame() - map.frame_at_beat (_beat); + + _pulse = map.pulse_at_beat (beat); + + _pointer_frame_offset = raw_grab_frame() - map.frame_at_pulse (_pulse); + } void @@ -3468,7 +3471,13 @@ BBTRulerDrag::motion (GdkEvent* event, bool first_move) _editor->begin_reversible_command (_("dilate tempo")); } - framepos_t const pf = adjusted_current_frame (event, false); + framepos_t pf; + + if (_editor->snap_musical()) { + pf = adjusted_current_frame (event, false); + } else { + pf = adjusted_current_frame (event); + } if (Keyboard::modifier_state_contains (event->button.state, ArdourKeyboard::constraint_modifier())) { /* adjust previous tempo to match pointer frame */ |