diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2011-03-04 03:10:17 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2011-03-04 03:10:17 +0000 |
commit | 3d1fc33abb9592379ed5600a60e3097013eed9fb (patch) | |
tree | e7190d2d64506a438c5cc2510ffb3fe2b825b4c2 /libs/gtkmm2ext/gtkmm2ext | |
parent | b15e1cba3b11f73f3155c5dbd8a162c2512f5641 (diff) |
extend Gtkmm2ext::Bindings system to handle mouse buttons as well as keyboard events
git-svn-id: svn://localhost/ardour2/branches/3.0@9062 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/gtkmm2ext/gtkmm2ext')
-rw-r--r-- | libs/gtkmm2ext/gtkmm2ext/bindings.h | 60 |
1 files changed, 52 insertions, 8 deletions
diff --git a/libs/gtkmm2ext/gtkmm2ext/bindings.h b/libs/gtkmm2ext/gtkmm2ext/bindings.h index 45c3cfd809..36da0b6075 100644 --- a/libs/gtkmm2ext/gtkmm2ext/bindings.h +++ b/libs/gtkmm2ext/gtkmm2ext/bindings.h @@ -9,16 +9,13 @@ #include <gtkmm/radioaction.h> #include <gtkmm/toggleaction.h> +class XMLNode; + namespace Gtkmm2ext { class KeyboardKey { public: - enum Operation { - Press, - Release - }; - KeyboardKey () { _val = GDK_VoidSymbol; } @@ -38,6 +35,31 @@ class KeyboardKey std::string name() const; static bool make_key (const std::string&, KeyboardKey&); + + private: + uint64_t _val; +}; + +class MouseButton { + public: + MouseButton () { + _val = ~0ULL; + } + + MouseButton (uint32_t state, uint32_t button_number); + uint32_t state() const { return _val >> 32; } + uint32_t button() const { return _val & 0xffff; } + + bool operator<(const MouseButton& other) const { + return _val < other._val; + } + + bool operator==(const MouseButton& other) const { + return _val == other._val; + } + + std::string name() const; + static bool make_button (const std::string&, MouseButton&); static void set_ignored_state (int mask) { _ignored_state = mask; } @@ -70,24 +92,46 @@ class ActionMap { class Bindings { public: + enum Operation { + Press, + Release + }; + Bindings(); ~Bindings (); - void add (KeyboardKey, KeyboardKey::Operation, Glib::RefPtr<Gtk::Action>); - void remove (KeyboardKey, KeyboardKey::Operation); - bool activate (KeyboardKey, KeyboardKey::Operation); + void add (KeyboardKey, Operation, Glib::RefPtr<Gtk::Action>); + void remove (KeyboardKey, Operation); + bool activate (KeyboardKey, Operation); + + void add (MouseButton, Operation, Glib::RefPtr<Gtk::Action>); + void remove (MouseButton, Operation); + bool activate (MouseButton, Operation); bool load (const std::string& path); + void load (const XMLNode& node); bool save (const std::string& path); + void save (XMLNode& root); void set_action_map (ActionMap&); + static void set_ignored_state (int mask) { + _ignored_state = mask; + } + static uint32_t ignored_state() { return _ignored_state; } + private: typedef std::map<KeyboardKey,Glib::RefPtr<Gtk::Action> > KeybindingMap; + KeybindingMap press_bindings; KeybindingMap release_bindings; + typedef std::map<MouseButton,Glib::RefPtr<Gtk::Action> > MouseButtonBindingMap; + MouseButtonBindingMap button_press_bindings; + MouseButtonBindingMap button_release_bindings; + ActionMap* action_map; + static uint32_t _ignored_state; }; } // namespace |