mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-08 15:54:57 +01:00
create a two-way association between an action map and a bindings object, rather than just one way.
This helps us lookup bindings when printing out lists for the user
This commit is contained in:
parent
75e671b867
commit
66e0328a93
2 changed files with 44 additions and 20 deletions
|
|
@ -315,7 +315,13 @@ Bindings::get_binding_for_action (RefPtr<Action> action, Operation& op)
|
||||||
void
|
void
|
||||||
Bindings::set_action_map (ActionMap& actions)
|
Bindings::set_action_map (ActionMap& actions)
|
||||||
{
|
{
|
||||||
|
if (_action_map) {
|
||||||
|
_action_map->set_bindings (0);
|
||||||
|
}
|
||||||
|
|
||||||
_action_map = &actions;
|
_action_map = &actions;
|
||||||
|
_action_map->set_bindings (this);
|
||||||
|
|
||||||
dissociate ();
|
dissociate ();
|
||||||
associate ();
|
associate ();
|
||||||
}
|
}
|
||||||
|
|
@ -393,10 +399,9 @@ Bindings::associate ()
|
||||||
for (k = press_bindings.begin(); k != press_bindings.end(); ++k) {
|
for (k = press_bindings.begin(); k != press_bindings.end(); ++k) {
|
||||||
k->second.action = _action_map->find_action (k->second.action_name);
|
k->second.action = _action_map->find_action (k->second.action_name);
|
||||||
if (k->second.action) {
|
if (k->second.action) {
|
||||||
cerr << "push to GTK " << k->first << ' ' << k->second.action_name << endl;
|
|
||||||
push_to_gtk (k->first, k->second.action);
|
push_to_gtk (k->first, k->second.action);
|
||||||
} else {
|
} else {
|
||||||
cerr << "didn't find " << k->second.action_name << endl;
|
cerr << _name << " didn't find " << k->second.action_name << " in " << _action_map->name() << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -903,6 +908,24 @@ Bindings::associate_all ()
|
||||||
|
|
||||||
/*==========================================ACTION MAP =========================================*/
|
/*==========================================ACTION MAP =========================================*/
|
||||||
|
|
||||||
|
ActionMap::ActionMap (string const & name)
|
||||||
|
: _name (name)
|
||||||
|
, _bindings (0)
|
||||||
|
{
|
||||||
|
action_maps.push_back (this);
|
||||||
|
}
|
||||||
|
|
||||||
|
ActionMap::~ActionMap ()
|
||||||
|
{
|
||||||
|
action_maps.remove (this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ActionMap::set_bindings (Bindings* b)
|
||||||
|
{
|
||||||
|
_bindings = b;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ActionMap::get_actions (ActionMap::Actions& acts)
|
ActionMap::get_actions (ActionMap::Actions& acts)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -76,10 +76,14 @@ class LIBGTKMM2EXT_API MouseButton {
|
||||||
uint64_t _val;
|
uint64_t _val;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class LIBGTKMM2EXT_API Bindings;
|
||||||
|
|
||||||
class LIBGTKMM2EXT_API ActionMap {
|
class LIBGTKMM2EXT_API ActionMap {
|
||||||
public:
|
public:
|
||||||
ActionMap() {}
|
ActionMap (std::string const& name);
|
||||||
~ActionMap() {}
|
~ActionMap();
|
||||||
|
|
||||||
|
std::string name() const { return _name; }
|
||||||
|
|
||||||
Glib::RefPtr<Gtk::ActionGroup> create_action_group (const std::string& group_name);
|
Glib::RefPtr<Gtk::ActionGroup> create_action_group (const std::string& group_name);
|
||||||
|
|
||||||
|
|
@ -105,18 +109,24 @@ class LIBGTKMM2EXT_API ActionMap {
|
||||||
|
|
||||||
static std::list<ActionMap*> action_maps;
|
static std::list<ActionMap*> action_maps;
|
||||||
|
|
||||||
|
void set_bindings (Bindings*);
|
||||||
|
Bindings* bindings() const { return _bindings; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
<<<<<<< HEAD
|
std::string _name;
|
||||||
typedef std::map<std::string, Glib::RefPtr<Gtk::Action> > _ActionMap;
|
|
||||||
_ActionMap actions;
|
|
||||||
};
|
|
||||||
=======
|
|
||||||
/* hash for faster lookup of actions by name */
|
/* hash for faster lookup of actions by name */
|
||||||
|
|
||||||
typedef std::map<std::string, Glib::RefPtr<Gtk::Action> > _ActionMap;
|
typedef std::map<std::string, Glib::RefPtr<Gtk::Action> > _ActionMap;
|
||||||
_ActionMap _actions;
|
_ActionMap _actions;
|
||||||
|
|
||||||
|
/* initialized to null; set after a Bindings object has ::associated()
|
||||||
|
* itself with this action map.
|
||||||
|
*/
|
||||||
|
|
||||||
|
Bindings* _bindings;
|
||||||
|
|
||||||
};
|
};
|
||||||
>>>>>>> radically change Keyboard/Binding API design to disconnect Gtk::Action lookup from binding definition
|
|
||||||
|
|
||||||
class LIBGTKMM2EXT_API Bindings {
|
class LIBGTKMM2EXT_API Bindings {
|
||||||
public:
|
public:
|
||||||
|
|
@ -125,9 +135,6 @@ class LIBGTKMM2EXT_API Bindings {
|
||||||
Release
|
Release
|
||||||
};
|
};
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
Bindings();
|
|
||||||
=======
|
|
||||||
struct ActionInfo {
|
struct ActionInfo {
|
||||||
ActionInfo (std::string const& name) : action_name (name) {}
|
ActionInfo (std::string const& name) : action_name (name) {}
|
||||||
|
|
||||||
|
|
@ -136,7 +143,6 @@ class LIBGTKMM2EXT_API Bindings {
|
||||||
};
|
};
|
||||||
|
|
||||||
Bindings (std::string const& name);
|
Bindings (std::string const& name);
|
||||||
>>>>>>> radically change Keyboard/Binding API design to disconnect Gtk::Action lookup from binding definition
|
|
||||||
~Bindings ();
|
~Bindings ();
|
||||||
|
|
||||||
std::string const& name() const { return _name; }
|
std::string const& name() const { return _name; }
|
||||||
|
|
@ -164,11 +170,6 @@ class LIBGTKMM2EXT_API Bindings {
|
||||||
bool load (XMLNode const& node);
|
bool load (XMLNode const& node);
|
||||||
void load_operation (XMLNode const& node);
|
void load_operation (XMLNode const& node);
|
||||||
void save (XMLNode& root);
|
void save (XMLNode& root);
|
||||||
<<<<<<< HEAD
|
|
||||||
|
|
||||||
void set_action_map (ActionMap&);
|
|
||||||
=======
|
|
||||||
>>>>>>> radically change Keyboard/Binding API design to disconnect Gtk::Action lookup from binding definition
|
|
||||||
|
|
||||||
/* There are modifiers that we just don't care about
|
/* There are modifiers that we just don't care about
|
||||||
when it comes to defining bindings. This sets the modifiers
|
when it comes to defining bindings. This sets the modifiers
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue