From 146e5baec26ad659f7f84f648fcdd7b876d138bb Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Fri, 21 Dec 2007 16:00:32 +0000 Subject: [PATCH] fix up nudge for marker motion; make keyboard handling do the right thing when numlock is pressed and an un-modified key press event occurs git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@2807 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/editor_ops.cc | 77 ++++++++++++++++++++++++++++++++++++--- gtk2_ardour/utils.cc | 13 +++---- 2 files changed, 77 insertions(+), 13 deletions(-) diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index 5ec2d5da6f..d5e47c42e3 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -338,7 +338,7 @@ Editor::nudge_forward (bool next) if (!selection->regions.empty()) { - begin_reversible_command (_("nudge forward")); + begin_reversible_command (_("nudge regions forward")); for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) { boost::shared_ptr r ((*i)->region()); @@ -360,12 +360,39 @@ Editor::nudge_forward (bool next) } else if (!selection->markers.empty()) { - bool ignored; - Location* loc = find_location_from_marker (selection->markers.front(), ignored); + bool is_start; + Location* loc = find_location_from_marker (selection->markers.front(), is_start); if (loc) { - distance = get_nudge_distance (loc->start(), next_distance); - loc->set_start (loc->start() + distance); + + begin_reversible_command (_("nudge location forward")); + + XMLNode& before (loc->get_state()); + + if (is_start) { + distance = get_nudge_distance (loc->start(), next_distance); + if (next) { + distance = next_distance; + } + if (max_frames - distance > loc->start() + loc->length()) { + loc->set_start (loc->start() + distance); + } else { + loc->set_start (max_frames - loc->length()); + } + } else { + distance = get_nudge_distance (loc->end(), next_distance); + if (next) { + distance = next_distance; + } + if (max_frames - distance > loc->end()) { + loc->set_end (loc->end() + distance); + } else { + loc->set_end (max_frames); + } + } + XMLNode& after (loc->get_state()); + session->add_command (new MementoCommand(*loc, &before, &after)); + commit_reversible_command (); } } else { @@ -384,7 +411,7 @@ Editor::nudge_backward (bool next) if (!selection->regions.empty()) { - begin_reversible_command (_("nudge forward")); + begin_reversible_command (_("nudge regions backward")); for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) { boost::shared_ptr r ((*i)->region()); @@ -408,6 +435,44 @@ Editor::nudge_backward (bool next) commit_reversible_command (); + } else if (!selection->markers.empty()) { + + bool is_start; + Location* loc = find_location_from_marker (selection->markers.front(), is_start); + + if (loc) { + + begin_reversible_command (_("nudge location forward")); + XMLNode& before (loc->get_state()); + + if (is_start) { + distance = get_nudge_distance (loc->start(), next_distance); + if (next) { + distance = next_distance; + } + if (distance < loc->start()) { + loc->set_start (loc->start() - distance); + } else { + loc->set_start (0); + } + } else { + distance = get_nudge_distance (loc->end(), next_distance); + + if (next) { + distance = next_distance; + } + + if (distance < loc->end() - loc->length()) { + loc->set_end (loc->end() - distance); + } else { + loc->set_end (loc->length()); + } + } + + XMLNode& after (loc->get_state()); + session->add_command (new MementoCommand(*loc, &before, &after)); + } + } else { distance = get_nudge_distance (playhead_cursor->current_frame, next_distance); diff --git a/gtk2_ardour/utils.cc b/gtk2_ardour/utils.cc index 8a9325a940..991f31b74d 100644 --- a/gtk2_ardour/utils.cc +++ b/gtk2_ardour/utils.cc @@ -403,7 +403,7 @@ key_press_focus_accelerator_handler (Gtk::Window& window, GdkEventKey* ev) GtkWidget* focus = gtk_window_get_focus (win); bool special_handling_of_unmodified_accelerators = false; -#undef DEBUG_ACCELERATOR_HANDLING +#undef DEBUG_ACCELERATOR_HANDLING #ifdef DEBUG_ACCELERATOR_HANDLING bool debug = (getenv ("ARDOUR_DEBUG_ACCELERATOR_HANDLING") != 0); #endif @@ -488,12 +488,11 @@ key_press_focus_accelerator_handler (Gtk::Window& window, GdkEventKey* ev) } } - if (!special_handling_of_unmodified_accelerators || - ev->state & (Gdk::MOD1_MASK| - Gdk::MOD3_MASK| - Gdk::MOD4_MASK| - Gdk::MOD5_MASK| - Gdk::CONTROL_MASK)) { + /* consider all relevant modifiers but not LOCK or SHIFT */ + + guint mask = (Keyboard::RelevantModifierKeyMask & ~(Gdk::SHIFT_MASK|Gdk::LOCK_MASK)); + + if (!special_handling_of_unmodified_accelerators || (ev->state & mask)) { /* no special handling or there are modifiers in effect: accelerate first */