2 Copyright (C) 2001 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 #ifndef __ardour_keyboard_h__
21 #define __ardour_keyboard_h__
26 #include <sigc++/signal.h>
28 #include <gtkmm/window.h>
30 #include <ardour/types.h>
31 #include <pbd/stateful.h>
33 #include "selection.h"
38 class Keyboard : public sigc::trackable, Stateful
44 XMLNode& get_state (void);
45 int set_state (const XMLNode&);
47 typedef vector<uint32_t> State;
48 typedef uint32_t ModifierMask;
50 static uint32_t Control;
51 static uint32_t Shift;
55 bool key_is_down (uint32_t keyval);
57 static GdkModifierType RelevantModifierKeyMask;
59 static bool no_modifier_keys_pressed(GdkEventButton* ev) {
60 return (ev->state & RelevantModifierKeyMask) == 0;
63 bool leave_window (GdkEventCrossing *ev, Gtk::Window*);
64 bool enter_window (GdkEventCrossing *ev, Gtk::Window*);
66 static bool modifier_state_contains (guint state, ModifierMask);
67 static bool modifier_state_equals (guint state, ModifierMask);
69 static Selection::Operation selection_type (guint state);
71 static bool no_modifiers_active (guint state);
73 static void set_meta_modifier (guint);
75 static void set_snap_modifier (guint);
76 static ModifierMask snap_modifier () { return ModifierMask (snap_mod); }
78 static guint edit_button() { return edit_but; }
79 static void set_edit_button (guint);
80 static guint edit_modifier() { return edit_mod; }
81 static void set_edit_modifier(guint);
83 static guint delete_button() { return delete_but; }
84 static void set_delete_button(guint);
85 static guint delete_modifier() { return delete_mod; }
86 static void set_delete_modifier(guint);
88 static bool is_edit_event (GdkEventButton*);
89 static bool is_delete_event (GdkEventButton*);
90 static bool is_context_menu_event (GdkEventButton*);
92 static Keyboard& the_keyboard() { return *_the_keyboard; }
94 static bool some_magic_widget_has_focus ();
95 static void magic_widget_grab_focus ();
96 static void magic_widget_drop_focus ();
99 static Keyboard* _the_keyboard;
104 static guint edit_but;
105 static guint edit_mod;
106 static guint delete_but;
107 static guint delete_mod;
108 static guint snap_mod;
109 static Gtk::Window* current_window;
111 static gint _snooper (GtkWidget*, GdkEventKey*, gpointer);
112 gint snooper (GtkWidget*, GdkEventKey*);
114 static bool _some_magic_widget_has_focus;
117 #endif /* __ardour_keyboard_h__ */