X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Feditor_keyboard.cc;h=e6936232cddcfa9d998dd8a216d335ee55888edc;hb=5c144432adbb791ce9d2a2cbd7471da0499b6ea7;hp=e9ccd26f46d91dc98f6a9b1c7a5eaead1e2e66d3;hpb=82232f06ba3eea4a2b4342ad91fab552f4044402;p=ardour.git diff --git a/gtk2_ardour/editor_keyboard.cc b/gtk2_ardour/editor_keyboard.cc index e9ccd26f46..e6936232cd 100644 --- a/gtk2_ardour/editor_keyboard.cc +++ b/gtk2_ardour/editor_keyboard.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2004 Paul Davis + Copyright (C) 2004 Paul Davis This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -15,19 +15,27 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id$ */ -#include -#include -#include +#include "pbd/memento_command.h" +#include "pbd/stateful_diff_command.h" + +#include "ardour/audioregion.h" +#include "ardour/playlist.h" +#include "ardour/session.h" +#include "ardour/location.h" #include "editor.h" #include "region_view.h" #include "selection.h" +#include "keyboard.h" +#include "editor_drag.h" #include "i18n.h" +using namespace ARDOUR; +using namespace PBD; + void Editor::kbd_driver (sigc::slot theslot, bool use_track_canvas, bool use_time_canvas, bool can_select) { @@ -35,7 +43,7 @@ Editor::kbd_driver (sigc::slot theslot, bool use_track_canvas, b double worldx, worldy; GdkEvent ev; Gdk::ModifierType mask; - Glib::RefPtr evw = track_canvas.get_window()->get_pointer (x, y, mask); + Glib::RefPtr evw = track_canvas->get_window()->get_pointer (x, y, mask); bool doit = false; if (use_track_canvas && track_canvas_event_box.get_window()->get_pointer(x, y, mask) != 0) { @@ -44,13 +52,20 @@ Editor::kbd_driver (sigc::slot theslot, bool use_track_canvas, b doit = true; } + /* any use of "keyboard mouse buttons" invalidates an existing grab + */ + + if (_drags->active ()) { + _drags->abort (); + } + if (doit) { if (entered_regionview && can_select) { selection->set (entered_regionview); } - track_canvas.window_to_world (x, y, worldx, worldy); + track_canvas->window_to_world (x, y, worldx, worldy); worldx += horizontal_adjustment.get_value(); worldy += vertical_adjustment.get_value(); @@ -64,96 +79,37 @@ Editor::kbd_driver (sigc::slot theslot, bool use_track_canvas, b } void -Editor::kbd_set_playhead_cursor () +Editor::kbd_mute_unmute_region () { - kbd_driver (mem_fun(*this, &Editor::set_playhead_cursor), true, true, false); -} + if (!selection->regions.empty ()) { -void -Editor::kbd_set_edit_cursor () -{ - kbd_driver (mem_fun(*this, &Editor::set_edit_cursor), true, true, false); -} + if (selection->regions.size() > 1) { + begin_reversible_command (_("mute regions")); + } else { + begin_reversible_command (_("mute region")); + } + for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) { -void -Editor::kbd_do_split (GdkEvent* ev) -{ - jack_nframes_t where = event_frame (ev); + (*i)->region()->playlist()->clear_history (); + (*i)->region()->set_muted (!(*i)->region()->muted ()); + _session->add_command (new StatefulDiffCommand ((*i)->region()->playlist())); - if (entered_regionview) { - if (selection->regions.find (entered_regionview) != selection->regions.end()) { - split_regions_at (where, selection->regions); - } else { - RegionSelection s; - s.add (entered_regionview); - split_regions_at (where, s); } - } -} -void -Editor::kbd_split () -{ - kbd_driver (mem_fun(*this, &Editor::kbd_do_split), true, true, false); -} + commit_reversible_command (); + + } else if (entered_regionview) { -void -Editor::kbd_mute_unmute_region () -{ - if (entered_regionview) { begin_reversible_command (_("mute region")); - XMLNode &before = entered_regionview->region()->playlist()->get_state(); - + entered_regionview->region()->playlist()->clear_history (); entered_regionview->region()->set_muted (!entered_regionview->region()->muted()); - - XMLNode &after = entered_regionview->region()->playlist()->get_state(); - session->add_command (new MementoCommand(*(entered_regionview->region()->playlist()), &before, &after)); + _session->add_command (new StatefulDiffCommand (entered_regionview->region()->playlist())); commit_reversible_command(); - } -} - -void -Editor::kbd_set_sync_position () -{ - kbd_driver (mem_fun(*this, &Editor::kbd_do_set_sync_position), true, true, false); -} -void -Editor::kbd_do_set_sync_position (GdkEvent* ev) -{ - jack_nframes_t where = event_frame (ev); - snap_to (where); - - if (entered_regionview) { - set_a_regions_sync_position (entered_regionview->region(), where); } } -void -Editor::kbd_do_align (GdkEvent* ev, ARDOUR::RegionPoint what) -{ - align (what); -} - -void -Editor::kbd_align (ARDOUR::RegionPoint what) -{ - kbd_driver (bind (mem_fun(*this, &Editor::kbd_do_align), what)); -} - -void -Editor::kbd_do_align_relative (GdkEvent* ev, ARDOUR::RegionPoint what) -{ - align (what); -} - -void -Editor::kbd_align_relative (ARDOUR::RegionPoint what) -{ - kbd_driver (bind (mem_fun(*this, &Editor::kbd_do_align), what), true, true, false); -} - void Editor::kbd_do_brush (GdkEvent *ev) { @@ -163,17 +119,6 @@ Editor::kbd_do_brush (GdkEvent *ev) void Editor::kbd_brush () { - kbd_driver (mem_fun(*this, &Editor::kbd_do_brush), true, true, false); + kbd_driver (sigc::mem_fun(*this, &Editor::kbd_do_brush), true, true, false); } -void -Editor::kbd_do_audition (GdkEvent *ignored) -{ - audition_selected_region (); -} - -void -Editor::kbd_audition () -{ - kbd_driver (mem_fun(*this, &Editor::kbd_do_audition), true, false, true); -}