remove global LV2 external GUI list, always call LV2 UI cleanup method when appropria...
[ardour2.git] / gtk2_ardour / editor_keyboard.cc
blob257ebc487aee69ec48164f8492d05f7e9ff7ad8d
1 /*
2 Copyright (C) 2004 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include <ardour/audioregion.h>
21 #include <ardour/playlist.h>
22 #include <ardour/location.h>
24 #include <pbd/memento_command.h>
26 #include "editor.h"
27 #include "region_view.h"
28 #include "selection.h"
29 #include "keyboard.h"
31 #include "i18n.h"
33 using namespace ARDOUR;
35 void
36 Editor::kbd_driver (sigc::slot<void,GdkEvent*> theslot, bool use_track_canvas, bool use_time_canvas, bool can_select)
38 gint x, y;
39 double worldx, worldy;
40 GdkEvent ev;
41 Gdk::ModifierType mask;
42 Glib::RefPtr<Gdk::Window> evw = track_canvas->get_window()->get_pointer (x, y, mask);
43 bool doit = false;
45 if (use_track_canvas && track_canvas_event_box.get_window()->get_pointer(x, y, mask) != 0) {
46 doit = true;
47 } else if (use_time_canvas && time_canvas_event_box.get_window()->get_pointer(x, y, mask)!= 0) {
48 doit = true;
51 /* any use of "keyboard mouse buttons" invalidates an existing grab
54 if (drag_info.item) {
55 drag_info.item->ungrab (GDK_CURRENT_TIME);
56 drag_info.item = 0;
59 if (doit) {
61 if (entered_regionview && can_select) {
62 selection->set (entered_regionview);
65 track_canvas->window_to_world (x, y, worldx, worldy);
66 worldx += horizontal_adjustment.get_value();
67 worldy += vertical_adjustment.get_value();
69 ev.type = GDK_BUTTON_PRESS;
70 ev.button.x = worldx;
71 ev.button.y = worldy;
72 ev.button.state = 0; /* XXX correct? */
74 theslot (&ev);
78 void
79 Editor::kbd_mute_unmute_region ()
81 if (!selection->regions.empty ()) {
83 if (selection->regions.size() > 1) {
84 begin_reversible_command (_("mute regions"));
85 } else {
86 begin_reversible_command (_("mute region"));
89 for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) {
91 XMLNode &before = (*i)->region()->playlist()->get_state ();
92 (*i)->region()->set_muted (!(*i)->region()->muted ());
93 XMLNode &after = (*i)->region()->playlist()->get_state ();
95 session->add_command (new MementoCommand<ARDOUR::Playlist>(*((*i)->region()->playlist()), &before, &after));
99 commit_reversible_command ();
101 } else if (entered_regionview) {
103 begin_reversible_command (_("mute region"));
104 XMLNode &before = entered_regionview->region()->playlist()->get_state();
106 entered_regionview->region()->set_muted (!entered_regionview->region()->muted());
108 XMLNode &after = entered_regionview->region()->playlist()->get_state();
109 session->add_command (new MementoCommand<ARDOUR::Playlist>(*(entered_regionview->region()->playlist()), &before, &after));
110 commit_reversible_command();
115 void
116 Editor::kbd_do_brush (GdkEvent *ev)
118 brush (event_frame (ev, 0, 0));
121 void
122 Editor::kbd_brush ()
124 kbd_driver (mem_fun(*this, &Editor::kbd_do_brush), true, true, false);