remove unused static member from MouseButton
[ardour.git] / libs / gtkmm2ext / gtkmm2ext / bindings.h
1 #ifndef __libgtkmm2ext_bindings_h__
2 #define __libgtkmm2ext_bindings_h__
3
4 #include <map>
5 #include <stdint.h>
6 #include <gdk/gdkkeysyms.h>
7 #include <gtkmm/action.h>
8 #include <gtkmm/action.h>
9 #include <gtkmm/radioaction.h>
10 #include <gtkmm/toggleaction.h>
11
12 #include "gtkmm2ext/visibility.h"
13
14 class XMLNode;
15
16 namespace Gtkmm2ext {
17
18 class LIBGTKMM2EXT_API KeyboardKey
19 {
20   public:
21         KeyboardKey () {
22                 _val = GDK_VoidSymbol;
23         }
24         
25         KeyboardKey (uint32_t state, uint32_t keycode);
26         
27         uint32_t state() const { return _val >> 32; }
28         uint32_t key() const { return _val & 0xffff; }
29         
30         bool operator<(const KeyboardKey& other) const {
31                 return _val < other._val;
32         }
33
34         bool operator==(const KeyboardKey& other) const {
35                 return _val == other._val;
36         }
37
38         std::string name() const;
39         static bool make_key (const std::string&, KeyboardKey&);
40
41   private:
42         uint64_t _val;
43 };
44
45 class LIBGTKMM2EXT_API MouseButton {
46   public:
47         MouseButton () {
48                 _val = ~0ULL;
49         }
50
51         MouseButton (uint32_t state, uint32_t button_number);
52         uint32_t state() const { return _val >> 32; }
53         uint32_t button() const { return _val & 0xffff; }
54
55         bool operator<(const MouseButton& other) const {
56                 return _val < other._val;
57         }
58
59         bool operator==(const MouseButton& other) const {
60                 return _val == other._val;
61         }
62
63         std::string name() const;
64         static bool make_button (const std::string&, MouseButton&);
65
66   private:
67         uint64_t _val;
68 };
69
70 class LIBGTKMM2EXT_API ActionMap {
71   public:
72         ActionMap() {}
73         ~ActionMap() {}
74
75         Glib::RefPtr<Gtk::Action> register_action (const char* path,
76                                                    const char* name, const char* label, sigc::slot<void> sl);
77         Glib::RefPtr<Gtk::Action> register_radio_action (const char* path, Gtk::RadioAction::Group&,
78                                                          const char* name, const char* label, 
79                                                          sigc::slot<void,GtkAction*> sl,
80                                                          int value);
81         Glib::RefPtr<Gtk::Action> register_toggle_action (const char*path,
82                                                           const char* name, const char* label, sigc::slot<void> sl);
83
84         Glib::RefPtr<Gtk::Action> find_action (const std::string& name);
85
86   private:
87         typedef std::map<std::string, Glib::RefPtr<Gtk::Action> > _ActionMap;
88         _ActionMap actions;
89 };        
90
91 class LIBGTKMM2EXT_API Bindings {
92   public:
93         enum Operation { 
94                 Press,
95                 Release
96         };
97         
98         Bindings();
99         ~Bindings ();
100
101         void add (KeyboardKey, Operation, Glib::RefPtr<Gtk::Action>);
102         void remove (KeyboardKey, Operation);
103         bool activate (KeyboardKey, Operation);
104
105         void add (MouseButton, Operation, Glib::RefPtr<Gtk::Action>);
106         void remove (MouseButton, Operation);
107         bool activate (MouseButton, Operation);
108
109         bool load (const std::string& path);
110         void load (const XMLNode& node);
111         bool save (const std::string& path);
112         void save (XMLNode& root);
113         
114         void set_action_map (ActionMap&);
115
116         static void set_ignored_state (int mask) {
117                 _ignored_state = mask;
118         }
119         static uint32_t ignored_state() { return _ignored_state; }
120
121   private:
122         typedef std::map<KeyboardKey,Glib::RefPtr<Gtk::Action> > KeybindingMap;
123
124         KeybindingMap press_bindings;
125         KeybindingMap release_bindings;
126
127         typedef std::map<MouseButton,Glib::RefPtr<Gtk::Action> > MouseButtonBindingMap;
128         MouseButtonBindingMap button_press_bindings;
129         MouseButtonBindingMap button_release_bindings;
130
131         ActionMap* action_map;
132         static uint32_t _ignored_state;
133 };
134
135 } // namespace
136
137 #endif /* __libgtkmm2ext_bindings_h__ */