summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk2_ardour/editor.cc41
-rw-r--r--gtk2_ardour/editor.h2
-rw-r--r--gtk2_ardour/editor_drag.cc12
-rw-r--r--gtk2_ardour/public_editor.h1
-rw-r--r--libs/ardour/tempo.cc18
5 files changed, 62 insertions, 12 deletions
diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc
index c0ab97d9a4..3e4097d134 100644
--- a/gtk2_ardour/editor.cc
+++ b/gtk2_ardour/editor.cc
@@ -4046,6 +4046,47 @@ Editor::get_grid_beat_divisions(framepos_t position)
return 0;
}
+/** returns the current musical grid divisiions using the supplied modifier mask from a GtkEvent.
+ if the grid is non-musical, returns 0.
+ if the grid is snapped to bars, returns -1.
+ @param event_state the current keyboard modifier mask.
+*/
+unsigned
+Editor::get_grid_music_divisions (uint32_t event_state)
+{
+ if (snap_mode() == Editing::SnapOff && !ArdourKeyboard::indicates_snap (event_state)) {
+ return 0;
+ }
+
+ if (snap_mode() != Editing::SnapOff && ArdourKeyboard::indicates_snap (event_state)) {
+ return 0;
+ }
+
+ switch (_snap_type) {
+ case SnapToBeatDiv128: return 128;
+ case SnapToBeatDiv64: return 64;
+ case SnapToBeatDiv32: return 32;
+ case SnapToBeatDiv28: return 28;
+ case SnapToBeatDiv24: return 24;
+ case SnapToBeatDiv20: return 20;
+ case SnapToBeatDiv16: return 16;
+ case SnapToBeatDiv14: return 14;
+ case SnapToBeatDiv12: return 12;
+ case SnapToBeatDiv10: return 10;
+ case SnapToBeatDiv8: return 8;
+ case SnapToBeatDiv7: return 7;
+ case SnapToBeatDiv6: return 6;
+ case SnapToBeatDiv5: return 5;
+ case SnapToBeatDiv4: return 4;
+ case SnapToBeatDiv3: return 3;
+ case SnapToBeatDiv2: return 2;
+ case SnapToBeat: return 1;
+ case SnapToBar : return -1;
+ default: return 0;
+ }
+ return 0;
+}
+
Evoral::Beats
Editor::get_grid_type_as_beats (bool& success, framepos_t position)
{
diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h
index ca46df0c1b..4fe892504f 100644
--- a/gtk2_ardour/editor.h
+++ b/gtk2_ardour/editor.h
@@ -330,6 +330,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
unsigned get_grid_beat_divisions(framepos_t position);
Evoral::Beats get_grid_type_as_beats (bool& success, framepos_t position);
+ unsigned get_grid_music_divisions (uint32_t event_state);
+
void nudge_forward (bool next, bool force_playhead);
void nudge_backward (bool next, bool force_playhead);
diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc
index 635a590b6a..d2fd96e685 100644
--- a/gtk2_ardour/editor_drag.cc
+++ b/gtk2_ardour/editor_drag.cc
@@ -3338,16 +3338,10 @@ TempoMarkerDrag::motion (GdkEvent* event, bool first_move)
const framepos_t pf = adjusted_current_frame (event);
TempoMap& map (_editor->session()->tempo_map());
- /* snap to beat is -2, snap to bar is -3 (sorry) */
- int sub_num = _editor->get_grid_beat_divisions (0);
+ /* snap to beat is 1, snap to bar is -1 (sorry) */
+ int sub_num = _editor->get_grid_music_divisions (event->button.state);
- if (_editor->snap_type() == SnapToBar) {
- sub_num = -3;
- } else if (_editor->snap_type() == SnapToBeat) {
- sub_num = -2;
- }
-
- map.gui_move_tempo (_real_section, pf, _editor->get_grid_beat_divisions (0));
+ map.gui_move_tempo (_real_section, pf, sub_num);
show_verbose_cursor_time (_real_section->frame());
}
diff --git a/gtk2_ardour/public_editor.h b/gtk2_ardour/public_editor.h
index c583ff67fb..836f849018 100644
--- a/gtk2_ardour/public_editor.h
+++ b/gtk2_ardour/public_editor.h
@@ -297,6 +297,7 @@ class PublicEditor : public Gtkmm2ext::Tabbable {
virtual framecnt_t get_paste_offset (framepos_t pos, unsigned paste_count, framecnt_t duration) = 0;
virtual unsigned get_grid_beat_divisions(framepos_t position) = 0;
virtual Evoral::Beats get_grid_type_as_beats (bool& success, framepos_t position) = 0;
+ virtual unsigned get_grid_music_divisions (uint32_t event_state) = 0;
virtual void edit_notes (MidiRegionView*) = 0;
virtual void queue_visual_videotimeline_update () = 0;
diff --git a/libs/ardour/tempo.cc b/libs/ardour/tempo.cc
index 15323751b4..0ed5a01459 100644
--- a/libs/ardour/tempo.cc
+++ b/libs/ardour/tempo.cc
@@ -2531,6 +2531,14 @@ void
TempoMap::gui_move_tempo (TempoSection* ts, const framepos_t& frame, const int& sub_num)
{
Metrics future_map;
+ bool was_musical = ts->position_lock_style() == MusicTime;
+
+ if (sub_num == 0 && was_musical) {
+ /* if we're not snapping to music,
+ AudioTime and MusicTime may be treated identically.
+ */
+ ts->set_position_lock_style (AudioTime);
+ }
if (ts->position_lock_style() == MusicTime) {
{
@@ -2539,16 +2547,16 @@ TempoMap::gui_move_tempo (TempoSection* ts, const framepos_t& frame, const int&
TempoSection* tempo_copy = copy_metrics_and_point (_metrics, future_map, ts);
double beat = beat_at_frame_locked (future_map, frame);
- if (sub_num > 0) {
+ if (sub_num > 1) {
beat = floor (beat) + (floor (((beat - floor (beat)) * (double) sub_num) + 0.5) / sub_num);
- } else if (sub_num == -2) {
+ } else if (sub_num == 1) {
/* snap to beat */
beat = floor (beat + 0.5);
}
double pulse = pulse_at_beat_locked (future_map, beat);
- if (sub_num == -3) {
+ if (sub_num == -1) {
/* snap to bar */
pulse = floor (pulse + 0.5);
}
@@ -2571,6 +2579,10 @@ TempoMap::gui_move_tempo (TempoSection* ts, const framepos_t& frame, const int&
}
}
+ if (sub_num == 0 && was_musical) {
+ ts->set_position_lock_style (MusicTime);
+ }
+
Metrics::const_iterator d = future_map.begin();
while (d != future_map.end()) {
delete (*d);