summaryrefslogtreecommitdiff
path: root/libs/gtkmm2ext/gtkmm2ext
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2010-08-06 18:44:55 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2010-08-06 18:44:55 +0000
commite2965cd138b31e27dc027bb674585ae93ffdc055 (patch)
treea52397e200b8e952fd3f8db48f6a995a91a8f549 /libs/gtkmm2ext/gtkmm2ext
parent93603ab24ffd43f49956119cd0d94722d4772cda (diff)
new files for new per-window/action-driven key binding mechanism
git-svn-id: svn://localhost/ardour2/branches/3.0@7553 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/gtkmm2ext/gtkmm2ext')
-rw-r--r--libs/gtkmm2ext/gtkmm2ext/bindings.h93
1 files changed, 93 insertions, 0 deletions
diff --git a/libs/gtkmm2ext/gtkmm2ext/bindings.h b/libs/gtkmm2ext/gtkmm2ext/bindings.h
new file mode 100644
index 0000000000..0ece4a7404
--- /dev/null
+++ b/libs/gtkmm2ext/gtkmm2ext/bindings.h
@@ -0,0 +1,93 @@
+#ifndef __libgtkmm2ext_bindings_h__
+#define __libgtkmm2ext_bindings_h__
+
+#include <map>
+#include <stdint.h>
+#include <gdk/gdkkeysyms.h>
+#include <gtkmm/action.h>
+#include <gtkmm/action.h>
+#include <gtkmm/radioaction.h>
+#include <gtkmm/toggleaction.h>
+
+namespace Gtkmm2ext {
+
+class KeyboardKey
+{
+ public:
+ enum Operation {
+ Press,
+ Release
+ };
+
+ KeyboardKey () {
+ _val = GDK_VoidSymbol;
+ }
+
+ KeyboardKey (int state, int keycode) {
+ _val = state;
+ _val <<= 32;
+ _val |= keycode;
+ };
+
+ int state() const { return _val >> 32; }
+ int key() const { return _val & 0xffff; }
+
+ bool operator<(const KeyboardKey& other) const {
+ return _val < other._val;
+ }
+
+ bool operator==(const KeyboardKey& other) const {
+ return _val == other._val;
+ }
+
+ std::string name() const;
+ static bool make_key (const std::string&, KeyboardKey&);
+
+ private:
+ uint64_t _val;
+};
+
+class ActionMap {
+ public:
+ ActionMap() {}
+ ~ActionMap() {}
+
+ Glib::RefPtr<Gtk::Action> register_action (const char* path,
+ const char* name, const char* label, sigc::slot<void> sl);
+ Glib::RefPtr<Gtk::Action> register_radio_action (const char* path, Gtk::RadioAction::Group&,
+ const char* name, const char* label, sigc::slot<void> sl);
+ Glib::RefPtr<Gtk::Action> register_toggle_action (const char*path,
+ const char* name, const char* label, sigc::slot<void> sl);
+
+ Glib::RefPtr<Gtk::Action> find_action (const std::string& name);
+
+ private:
+ typedef std::map<std::string, Glib::RefPtr<Gtk::Action> > _ActionMap;
+ _ActionMap actions;
+};
+
+class Bindings {
+ public:
+ Bindings();
+ ~Bindings ();
+
+ void add (KeyboardKey, KeyboardKey::Operation, Glib::RefPtr<Gtk::Action>);
+ void remove (KeyboardKey, KeyboardKey::Operation);
+ bool activate (KeyboardKey, KeyboardKey::Operation);
+
+ bool load (const std::string& path);
+ bool save (const std::string& path);
+
+ void set_action_map (ActionMap&);
+
+ private:
+ typedef std::map<KeyboardKey,Glib::RefPtr<Gtk::Action> > KeybindingMap;
+ KeybindingMap press_bindings;
+ KeybindingMap release_bindings;
+
+ ActionMap* action_map;
+};
+
+} // namespace
+
+#endif /* __libgtkmm2ext_bindings_h__ */