From eaf49f02ff92f22cbfa214ae89ec0a2fc3861d29 Mon Sep 17 00:00:00 2001 From: nick_m Date: Fri, 22 May 2015 02:12:58 +1000 Subject: Fix up modifier behaviour - its now possible to use snap modifiers in combination with others afaict this hasn't worked for some time. - use "contains" rather than "equals" during drag. Still uncertain about this wrt beginning a drag. for now they are all "equals". - probably solve the "snap modifier modifier" problem using ArdourKeyboard::indicates_snap () and friend. --- gtk2_ardour/editor.cc | 2 +- gtk2_ardour/editor_drag.cc | 16 ++++++++-------- gtk2_ardour/keyboard.cc | 24 ++++++++++++++++++++++-- gtk2_ardour/keyboard.h | 3 +++ gtk2_ardour/rc_option_editor.cc | 2 +- 5 files changed, 35 insertions(+), 12 deletions(-) (limited to 'gtk2_ardour') diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index ff9d480a35..05f9b0ca93 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -2597,7 +2597,7 @@ Editor::snap_to_with_modifier (framepos_t& start, GdkEvent const * event, RoundM return; } - if (Keyboard::modifier_state_contains (event->button.state, Keyboard::snap_modifier())) { + if (ArdourKeyboard::indicates_snap (event->button.state)) { if (_snap_mode == SnapOff) { snap_to_internal (start, direction, for_mark); } diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index a34c45545c..570ea1d31f 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -339,11 +339,11 @@ Drag::adjusted_current_frame (GdkEvent const * event, bool snap) const frameoffset_t Drag::snap_delta (GdkEvent const * event) const { - if (Keyboard::modifier_state_equals (event->button.state, Keyboard::snap_delta_modifier())) { + if (ArdourKeyboard::indicates_snap_delta (event->button.state)) { return 0; - } else { - return _snap_delta; } + + return _snap_delta; } double @@ -2394,7 +2394,7 @@ NoteResizeDrag::motion (GdkEvent* event, bool /*first_move*/) MidiRegionView* mrv = dynamic_cast(*r); if (mrv) { double sd = 0.0; - if (!Keyboard::modifier_state_equals (event->button.state, Keyboard::snap_delta_modifier())) { + if (!ArdourKeyboard::indicates_snap_delta (event->button.state)) { sd = _snap_delta; } mrv->update_resizing (nb, at_front, _drags->current_pointer_x() - grab_x(), relative, sd); @@ -2411,7 +2411,7 @@ NoteResizeDrag::finished (GdkEvent* event, bool /*movement_occurred*/) assert (nb); MidiRegionView* mrv = dynamic_cast(*r); double sd = 0.0; - if (!Keyboard::modifier_state_equals (event->button.state, Keyboard::snap_delta_modifier())) { + if (!ArdourKeyboard::indicates_snap_delta (event->button.state)) { sd = _snap_delta; } if (mrv) { @@ -2726,7 +2726,7 @@ TrimDrag::motion (GdkEvent* event, bool first_move) bool non_overlap_trim = false; - if (event && Keyboard::modifier_state_equals (event->button.state, ArdourKeyboard::trim_overlap_modifier ())) { + if (event && Keyboard::modifier_state_contains (event->button.state, ArdourKeyboard::trim_overlap_modifier ())) { non_overlap_trim = true; } @@ -3736,7 +3736,7 @@ MarkerDrag::motion (GdkEvent* event, bool) framepos_t const newframe = adjusted_current_frame (event); framepos_t next = newframe; - if (Keyboard::modifier_state_equals (event->button.state, ArdourKeyboard::push_points_modifier ())) { + if (Keyboard::modifier_state_contains (event->button.state, ArdourKeyboard::push_points_modifier ())) { move_both = true; } @@ -4003,7 +4003,7 @@ ControlPointDrag::start_grab (GdkEvent* event, Gdk::Cursor* /*cursor*/) show_verbose_cursor_text (_point->line().get_verbose_cursor_string (fraction)); - _pushing = Keyboard::modifier_state_contains (event->button.state, ArdourKeyboard::push_points_modifier ()); + _pushing = Keyboard::modifier_state_equals (event->button.state, ArdourKeyboard::push_points_modifier ()); if (!_point->can_slide ()) { _x_constrained = true; diff --git a/gtk2_ardour/keyboard.cc b/gtk2_ardour/keyboard.cc index 2eac66af88..72b9ff1ba4 100644 --- a/gtk2_ardour/keyboard.cc +++ b/gtk2_ardour/keyboard.cc @@ -235,6 +235,28 @@ ArdourKeyboard::set_state (const XMLNode& node, int version) return Keyboard::set_state (node, version); } +bool +ArdourKeyboard::indicates_snap (guint state) +{ + bool contains_s = Keyboard::modifier_state_contains (state, Keyboard::snap_modifier()); + bool equals_s = Keyboard::modifier_state_equals (state, Keyboard::snap_modifier()); + bool contains_d = Keyboard::modifier_state_contains (state, Keyboard::snap_delta_modifier()); + bool equals_d = Keyboard::modifier_state_equals (state, Keyboard::snap_delta_modifier()); + + return (equals_s || (contains_s && ((contains_d && !equals_d) || !contains_d))); +} + +bool +ArdourKeyboard::indicates_snap_delta (guint state) +{ + bool contains_d = Keyboard::modifier_state_contains (state, Keyboard::snap_delta_modifier()); + bool equals_d = Keyboard::modifier_state_equals (state, Keyboard::snap_delta_modifier()); + bool contains_s = Keyboard::modifier_state_contains (state, Keyboard::snap_modifier()); + bool equals_s = Keyboard::modifier_state_equals (state, Keyboard::snap_modifier()); + + return (equals_d || (contains_d && ((contains_s && !equals_s) || !contains_s))); +} + void ArdourKeyboard::set_trim_contents_modifier (guint mod) { @@ -296,5 +318,3 @@ ArdourKeyboard::selection_type (guint state) return Selection::Set; } } - - diff --git a/gtk2_ardour/keyboard.h b/gtk2_ardour/keyboard.h index 95e40f6e3e..8ed30efb72 100644 --- a/gtk2_ardour/keyboard.h +++ b/gtk2_ardour/keyboard.h @@ -41,6 +41,9 @@ class ArdourKeyboard : public Gtkmm2ext::Keyboard ARDOUR_UI& ui; + static bool indicates_snap (guint state); + static bool indicates_snap_delta (guint state); + static void set_trim_contents_modifier (guint); /** @return Modifier mask to move contents rather than region bounds during trim; */ diff --git a/gtk2_ardour/rc_option_editor.cc b/gtk2_ardour/rc_option_editor.cc index 406b0401f1..a5f4b6e6f1 100644 --- a/gtk2_ardour/rc_option_editor.cc +++ b/gtk2_ardour/rc_option_editor.cc @@ -563,7 +563,7 @@ public: } } - l = manage (left_aligned_label (_("Ignore snap by including:"))); + l = manage (left_aligned_label (_("Ignore snap using:"))); l->set_name ("OptionsLabel"); t->attach (*l, col, col + 1, row, row + 1, FILL | EXPAND, FILL); -- cgit v1.2.3