X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Feditor_keyboard.cc;h=da6fadfe16bb4db7b5e93a3502669b087ca61b71;hb=5b520324ceab2559723b4ef5127301fa61ff4846;hp=c0a4f3e0853589c49904d9053a0f307d72c725cd;hpb=b0686e90563e5420736d61238948f3517fd30ebd;p=ardour.git diff --git a/gtk2_ardour/editor_keyboard.cc b/gtk2_ardour/editor_keyboard.cc index c0a4f3e085..da6fadfe16 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,14 +15,26 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id$ */ -#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 "regionview.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) @@ -31,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) { @@ -40,14 +52,21 @@ 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); - worldx += horizontal_adjustment.get_value(); + track_canvas->window_to_world (x, y, worldx, worldy); + worldx += horizontal_position(); worldy += vertical_adjustment.get_value(); ev.type = GDK_BUTTON_PRESS; @@ -60,80 +79,35 @@ 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); -} - - -void -Editor::kbd_do_split (GdkEvent* ev) -{ - jack_nframes_t where = event_frame (ev); - - if (entered_regionview) { - if (selection->audio_regions.find (entered_regionview) != selection->audio_regions.end()) { - split_regions_at (where, selection->audio_regions); + if (selection->regions.size() > 1) { + begin_reversible_command (_("mute regions")); } else { - AudioRegionSelection s; - s.add (entered_regionview); - split_regions_at (where, s); + begin_reversible_command (_("mute region")); } - } -} - -void -Editor::kbd_split () -{ - kbd_driver (mem_fun(*this, &Editor::kbd_do_split), true, true, false); -} + for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) { -void -Editor::kbd_set_sync_position () -{ - kbd_driver (mem_fun(*this, &Editor::kbd_do_set_sync_position), true, true, false); -} + (*i)->region()->playlist()->clear_history (); + (*i)->region()->set_muted (!(*i)->region()->muted ()); + _session->add_command (new StatefulDiffCommand ((*i)->region()->playlist())); -void -Editor::kbd_do_set_sync_position (GdkEvent* ev) -{ - jack_nframes_t where = event_frame (ev); - snap_to (where); - - if (entered_regionview) { - entered_regionview->region.set_sync_position (where); - } -} + } -void -Editor::kbd_do_align (GdkEvent* ev, ARDOUR::RegionPoint what) -{ - align (what); -} + commit_reversible_command (); -void -Editor::kbd_align (ARDOUR::RegionPoint what) -{ - kbd_driver (bind (mem_fun(*this, &Editor::kbd_do_align), what)); -} + } else if (entered_regionview) { -void -Editor::kbd_do_align_relative (GdkEvent* ev, ARDOUR::RegionPoint what) -{ - align (what); -} + begin_reversible_command (_("mute region")); + entered_regionview->region()->playlist()->clear_history (); + entered_regionview->region()->set_muted (!entered_regionview->region()->muted()); + _session->add_command (new StatefulDiffCommand (entered_regionview->region()->playlist())); + commit_reversible_command(); -void -Editor::kbd_align_relative (ARDOUR::RegionPoint what) -{ - kbd_driver (bind (mem_fun(*this, &Editor::kbd_do_align), what), true, true, false); + } } void @@ -145,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); -} - -void -Editor::kbd_do_audition (GdkEvent *ignored) -{ - audition_selected_region (); + kbd_driver (sigc::mem_fun(*this, &Editor::kbd_do_brush), true, true, false); } -void -Editor::kbd_audition () -{ - kbd_driver (mem_fun(*this, &Editor::kbd_do_audition), true, false, true); -}