From fd62d7aa3c2df966e4284cad7dcee2acb57f4009 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 16 Jan 2008 23:49:33 +0000 Subject: [PATCH] ctrl-click on nudge buttons only moves playhead git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@2926 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/editor.cc | 8 ++++---- gtk2_ardour/editor.h | 7 +++++-- gtk2_ardour/editor_actions.cc | 8 ++++---- gtk2_ardour/editor_ops.cc | 35 +++++++++++++++++++++++++++++------ 4 files changed, 42 insertions(+), 16 deletions(-) diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index 3056ebb8e0..9e3cc60466 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -1821,8 +1821,8 @@ Editor::add_region_context_items (AudioStreamView* sv, boost::shared_ptr MenuList& nudge_items = nudge_menu->items(); nudge_menu->set_name ("ArdourContextMenu"); - nudge_items.push_back (MenuElem (_("Nudge fwd"), (bind (mem_fun(*this, &Editor::nudge_forward), false)))); - nudge_items.push_back (MenuElem (_("Nudge bwd"), (bind (mem_fun(*this, &Editor::nudge_backward), false)))); + nudge_items.push_back (MenuElem (_("Nudge fwd"), (bind (mem_fun(*this, &Editor::nudge_forward), false, false)))); + nudge_items.push_back (MenuElem (_("Nudge bwd"), (bind (mem_fun(*this, &Editor::nudge_backward), false, false)))); nudge_items.push_back (MenuElem (_("Nudge fwd by capture offset"), (mem_fun(*this, &Editor::nudge_forward_capture_offset)))); nudge_items.push_back (MenuElem (_("Nudge bwd by capture offset"), (mem_fun(*this, &Editor::nudge_backward_capture_offset)))); @@ -2775,8 +2775,8 @@ Editor::setup_toolbar () nudge_box->set_spacing(1); nudge_box->set_border_width (2); - nudge_forward_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::nudge_forward), false)); - nudge_backward_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::nudge_backward), false)); + nudge_forward_button.signal_button_release_event().connect (mem_fun(*this, &Editor::nudge_forward_release), false); + nudge_backward_button.signal_button_release_event().connect (mem_fun(*this, &Editor::nudge_backward_release), false); nudge_box->pack_start (nudge_backward_button, false, false); nudge_box->pack_start (nudge_forward_button, false, false); diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index c0f532879b..4deaf7161f 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -286,8 +286,8 @@ class Editor : public PublicEditor /* nudge is initiated by transport controls owned by ARDOUR_UI */ - void nudge_forward (bool next); - void nudge_backward (bool next); + void nudge_forward (bool next, bool force_playhead); + void nudge_backward (bool next, bool force_playhead); /* nudge initiated from context menu */ @@ -1960,6 +1960,9 @@ class Editor : public PublicEditor AudioClock nudge_clock; nframes_t get_nudge_distance (nframes_t pos, nframes_t& next); + + bool nudge_forward_release (GdkEventButton*); + bool nudge_backward_release (GdkEventButton*); /* audio filters */ diff --git a/gtk2_ardour/editor_actions.cc b/gtk2_ardour/editor_actions.cc index 862659f893..d3f32f1646 100644 --- a/gtk2_ardour/editor_actions.cc +++ b/gtk2_ardour/editor_actions.cc @@ -194,13 +194,13 @@ Editor::register_actions () act = ActionManager::register_action (editor_actions, "add-location-from-playhead", _("Add Mark from Playhead"), mem_fun(*this, &Editor::add_location_from_playhead_cursor)); ActionManager::session_sensitive_actions.push_back (act); - act = ActionManager::register_action (editor_actions, "nudge-forward", _("Nudge Forward"), bind (mem_fun(*this, &Editor::nudge_forward), false)); + act = ActionManager::register_action (editor_actions, "nudge-forward", _("Nudge Forward"), bind (mem_fun(*this, &Editor::nudge_forward), false, false)); ActionManager::session_sensitive_actions.push_back (act); - act = ActionManager::register_action (editor_actions, "nudge-next-forward", _("Nudge Next Forward"), bind (mem_fun(*this, &Editor::nudge_forward), true)); + act = ActionManager::register_action (editor_actions, "nudge-next-forward", _("Nudge Next Forward"), bind (mem_fun(*this, &Editor::nudge_forward), true, false)); ActionManager::session_sensitive_actions.push_back (act); - act = ActionManager::register_action (editor_actions, "nudge-backward", _("Nudge Backward"), bind (mem_fun(*this, &Editor::nudge_backward), false)); + act = ActionManager::register_action (editor_actions, "nudge-backward", _("Nudge Backward"), bind (mem_fun(*this, &Editor::nudge_backward), false, false)); ActionManager::session_sensitive_actions.push_back (act); - act = ActionManager::register_action (editor_actions, "nudge-next-backward", _("Nudge Next Backward"), bind (mem_fun(*this, &Editor::nudge_backward), true)); + act = ActionManager::register_action (editor_actions, "nudge-next-backward", _("Nudge Next Backward"), bind (mem_fun(*this, &Editor::nudge_backward), true, false)); ActionManager::session_sensitive_actions.push_back (act); diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index 46a2ac53d0..eba74abe60 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -61,6 +61,7 @@ #include "editing.h" #include "gtk-custom-hruler.h" #include "gui_thread.h" +#include "keyboard.h" #include "i18n.h" @@ -327,16 +328,38 @@ Editor::extend_selection_to_start_of_region (bool previous) commit_reversible_command (); } +bool +Editor::nudge_forward_release (GdkEventButton* ev) +{ + if (ev->state & Keyboard::PrimaryModifier) { + nudge_forward (false, true); + } else { + nudge_forward (false, false); + } + return false; +} + +bool +Editor::nudge_backward_release (GdkEventButton* ev) +{ + if (ev->state & Keyboard::PrimaryModifier) { + nudge_backward (false, true); + } else { + nudge_backward (false, false); + } + return false; +} + void -Editor::nudge_forward (bool next) +Editor::nudge_forward (bool next, bool force_playhead) { nframes_t distance; nframes_t next_distance; if (!session) return; - if (!selection->regions.empty()) { + if (!force_playhead && !selection->regions.empty()) { begin_reversible_command (_("nudge regions forward")); @@ -358,7 +381,7 @@ Editor::nudge_forward (bool next) commit_reversible_command (); - } else if (!selection->markers.empty()) { + } else if (!force_playhead && !selection->markers.empty()) { bool is_start; Location* loc = find_location_from_marker (selection->markers.front(), is_start); @@ -402,14 +425,14 @@ Editor::nudge_forward (bool next) } void -Editor::nudge_backward (bool next) +Editor::nudge_backward (bool next, bool force_playhead) { nframes_t distance; nframes_t next_distance; if (!session) return; - if (!selection->regions.empty()) { + if (!force_playhead && !selection->regions.empty()) { begin_reversible_command (_("nudge regions backward")); @@ -435,7 +458,7 @@ Editor::nudge_backward (bool next) commit_reversible_command (); - } else if (!selection->markers.empty()) { + } else if (!force_playhead && !selection->markers.empty()) { bool is_start; Location* loc = find_location_from_marker (selection->markers.front(), is_start);