X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fkeyboard.h;h=6a689567e54e67b4b6d8468052f682b91fce00ba;hb=8b5f990267622100b3a1a7ff6fa346282aca4dda;hp=cff45b11f200ffbf1e47bbcb76209a2bb6e61bcf;hpb=df71243d6c18e5ae54706b51a6cbe770476ab419;p=ardour.git diff --git a/gtk2_ardour/keyboard.h b/gtk2_ardour/keyboard.h index cff45b11f2..6a689567e5 100644 --- a/gtk2_ardour/keyboard.h +++ b/gtk2_ardour/keyboard.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2001 Paul Davis + Copyright (C) 2001 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 @@ -20,150 +20,23 @@ #ifndef __ardour_keyboard_h__ #define __ardour_keyboard_h__ -#include -#include -#include - -#include -#include -#include - #include "ardour/types.h" -#include "pbd/stateful.h" +#include "gtkmm2ext/keyboard.h" #include "selection.h" -class Keyboard : public sigc::trackable, PBD::Stateful +class ARDOUR_UI; + +class ArdourKeyboard : public Gtkmm2ext::Keyboard { public: - Keyboard (); - ~Keyboard (); - - XMLNode& get_state (void); - int set_state (const XMLNode&); - - typedef std::vector State; - typedef uint32_t ModifierMask; - - static uint32_t PrimaryModifier; - static uint32_t SecondaryModifier; - static uint32_t TertiaryModifier; - static uint32_t Level4Modifier; - static uint32_t CopyModifier; - static uint32_t RangeSelectModifier; - - static void set_primary_modifier (uint32_t newval) { - set_modifier (newval, PrimaryModifier); - } - static void set_secondary_modifier (uint32_t newval) { - set_modifier (newval, SecondaryModifier); - } - static void set_tertiary_modifier (uint32_t newval) { - set_modifier (newval, TertiaryModifier); - } - static void set_level4_modifier (uint32_t newval) { - set_modifier (newval, Level4Modifier); - } - static void set_copy_modifier (uint32_t newval) { - set_modifier (newval, CopyModifier); - } - static void set_range_select_modifier (uint32_t newval) { - set_modifier (newval, RangeSelectModifier); - } + ArdourKeyboard(ARDOUR_UI& ardour_ui) : ui(ardour_ui) {} - bool key_is_down (uint32_t keyval); - - static GdkModifierType RelevantModifierKeyMask; - - static bool no_modifier_keys_pressed(GdkEventButton* ev) { - return (ev->state & RelevantModifierKeyMask) == 0; - } - - bool leave_window (GdkEventCrossing *ev, Gtk::Window*); - bool enter_window (GdkEventCrossing *ev, Gtk::Window*); - - static bool modifier_state_contains (guint state, ModifierMask); - static bool modifier_state_equals (guint state, ModifierMask); + void setup_keybindings (); static Selection::Operation selection_type (guint state); - static bool no_modifiers_active (guint state); - - static void set_snap_modifier (guint); - - /** @return Modifier mask to temporarily toggle grid setting; with this modifier - * - magnetic or normal grid should become no grid and - * - no grid should become normal grid - */ - static ModifierMask snap_modifier () { return ModifierMask (snap_mod); } - - static guint edit_button() { return edit_but; } - static void set_edit_button (guint); - static guint edit_modifier() { return edit_mod; } - static void set_edit_modifier(guint); - - static guint delete_button() { return delete_but; } - static void set_delete_button(guint); - static guint delete_modifier() { return delete_mod; } - static void set_delete_modifier(guint); - - static bool is_edit_event (GdkEventButton*); - static bool is_delete_event (GdkEventButton*); - static bool is_context_menu_event (GdkEventButton*); - static bool is_button2_event (GdkEventButton*); - - static Keyboard& the_keyboard() { return *_the_keyboard; } - - static bool some_magic_widget_has_focus (); - static void magic_widget_grab_focus (); - static void magic_widget_drop_focus (); - - static void setup_keybindings (); - static void keybindings_changed (); - static void save_keybindings (); - static bool load_keybindings (std::string path); - static void set_can_save_keybindings (bool yn); - static std::string current_binding_name () { return _current_binding_name; } - static std::map binding_files; - - struct AccelKeyLess { - bool operator() (const Gtk::AccelKey a, const Gtk::AccelKey b) const { - if (a.get_key() != b.get_key()) { - return a.get_key() < b.get_key(); - } else { - return a.get_mod() < b.get_mod(); - } - } - }; - - private: - static Keyboard* _the_keyboard; - - guint snooper_id; - State state; - - static guint edit_but; - static guint edit_mod; - static guint delete_but; - static guint delete_mod; - static guint snap_mod; - static guint button2_modifiers; - static Gtk::Window* current_window; - static std::string user_keybindings_path; - static bool can_save_keybindings; - static bool bindings_changed_after_save_became_legal; - static std::string _current_binding_name; - - typedef std::pair two_strings; - - static std::map release_keys; - - static gint _snooper (GtkWidget*, GdkEventKey*, gpointer); - gint snooper (GtkWidget*, GdkEventKey*); - - static void set_modifier (uint32_t newval, uint32_t& variable); - - static bool _some_magic_widget_has_focus; + ARDOUR_UI& ui; }; #endif /* __ardour_keyboard_h__ */