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_system.h>
30 #include <ardour/types.h>
31 #include <ardour/stateful.h>
39 class Keyboard : public SigC::Object, Stateful
45 XMLNode& get_state (void);
46 int set_state (const XMLNode&);
48 typedef vector<uint32_t> State;
50 void set_target (KeyboardTarget *);
51 void set_default_target (KeyboardTarget *);
52 void allow_focus (bool);
54 gint focus_in_handler (GdkEventFocus*);
55 gint focus_out_handler (GdkEventFocus*);
57 int get_prefix(float&, bool& was_floating);
60 static State translate_key_name (const string&);
61 static string get_real_keyname (const string& name);
63 void register_target (KeyboardTarget *);
65 void set_current_dialog (ArdourDialog*);
66 void close_current_dialog ();
68 typedef uint32_t ModifierMask;
70 static uint32_t Control;
71 static uint32_t Shift;
75 bool key_is_down (uint32_t keyval);
77 static GdkModifierType RelevantModifierKeyMask;
79 static bool no_modifier_keys_pressed(GdkEventButton* ev) {
80 return (ev->state & RelevantModifierKeyMask) == 0;
83 static bool modifier_state_contains (guint state, ModifierMask);
84 static bool modifier_state_equals (guint state, ModifierMask);
86 static bool no_modifiers_active (guint state);
88 static void set_meta_modifier (guint);
90 static void set_snap_modifier (guint);
91 static ModifierMask snap_modifier () { return ModifierMask (snap_mod); }
93 static guint edit_button() { return edit_but; }
94 static void set_edit_button (guint);
95 static guint edit_modifier() { return edit_mod; }
96 static void set_edit_modifier(guint);
98 static guint delete_button() { return delete_but; }
99 static void set_delete_button(guint);
100 static guint delete_modifier() { return delete_mod; }
101 static void set_delete_modifier(guint);
103 static bool is_edit_event (GdkEventButton*);
104 static bool is_delete_event (GdkEventButton*);
105 static bool is_context_menu_event (GdkEventButton*);
107 static Keyboard& the_keyboard() { return *_the_keyboard; }
110 static Keyboard* _the_keyboard;
114 guint32 playback_ignore_count;
118 KeyboardTarget* target;
119 KeyboardTarget* default_target;
121 bool collecting_prefix;
122 string current_prefix;
127 ArdourDialog* current_dialog;
128 std::vector<ArdourDialog*> known_dialogs;
130 static guint edit_but;
131 static guint edit_mod;
132 static guint delete_but;
133 static guint delete_mod;
134 static guint snap_mod;
136 static gint _snooper (GtkWidget*, GdkEventKey*, gpointer);
137 gint snooper (GtkWidget*, GdkEventKey*);
139 void maybe_unset_target (KeyboardTarget *);
140 void queue_event (GdkEventKey*);
141 void playback_queue ();
143 void get_modifier_masks ();
144 void check_modifier_state ();
145 void clear_modifier_state ();
146 gint enter_window (GdkEventCrossing*, KeyboardTarget*);
147 gint leave_window (GdkEventCrossing*);
148 gint current_dialog_vanished (GdkEventAny*);
150 void check_meta_numlock (char keycode, guint mod, string modname);
153 #endif /* __ardour_keyboard_h__ */