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.
21 #ifndef __ardour_keyboard_h__
22 #define __ardour_keyboard_h__
27 #include <sigc++/signal.h>
30 #include <ardour/types.h>
31 #include <ardour/stateful.h>
36 class Keyboard : public sigc::trackable, Stateful
42 XMLNode& get_state (void);
43 int set_state (const XMLNode&);
45 typedef vector<uint32_t> State;
47 int get_prefix(float&, bool& was_floating);
50 static State translate_key_name (const string&);
51 static string get_real_keyname (const string& name);
53 typedef uint32_t ModifierMask;
55 static uint32_t Control;
56 static uint32_t Shift;
60 bool key_is_down (uint32_t keyval);
62 static GdkModifierType RelevantModifierKeyMask;
64 static bool no_modifier_keys_pressed(GdkEventButton* ev) {
65 return (ev->state & RelevantModifierKeyMask) == 0;
68 bool leave_window (GdkEventCrossing *ev, Gtk::Window*);
69 bool enter_window (GdkEventCrossing *ev, Gtk::Window*);
71 static bool modifier_state_contains (guint state, ModifierMask);
72 static bool modifier_state_equals (guint state, ModifierMask);
74 static bool no_modifiers_active (guint state);
76 static void set_meta_modifier (guint);
78 static void set_snap_modifier (guint);
79 static ModifierMask snap_modifier () { return ModifierMask (snap_mod); }
81 static guint edit_button() { return edit_but; }
82 static void set_edit_button (guint);
83 static guint edit_modifier() { return edit_mod; }
84 static void set_edit_modifier(guint);
86 static guint delete_button() { return delete_but; }
87 static void set_delete_button(guint);
88 static guint delete_modifier() { return delete_mod; }
89 static void set_delete_modifier(guint);
91 static bool is_edit_event (GdkEventButton*);
92 static bool is_delete_event (GdkEventButton*);
93 static bool is_context_menu_event (GdkEventButton*);
95 static Keyboard& the_keyboard() { return *_the_keyboard; }
98 static Keyboard* _the_keyboard;
105 bool collecting_prefix;
106 string current_prefix;
112 static guint edit_but;
113 static guint edit_mod;
114 static guint delete_but;
115 static guint delete_mod;
116 static guint snap_mod;
118 static gint _snooper (GtkWidget*, GdkEventKey*, gpointer);
119 gint snooper (GtkWidget*, GdkEventKey*);
121 void queue_event (GdkEventKey*);
122 void get_modifier_masks ();
123 void check_modifier_state ();
124 void clear_modifier_state ();
126 void check_meta_numlock (char keycode, guint mod, string modname);
129 #endif /* __ardour_keyboard_h__ */