mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-08 15:54:57 +01:00
provide a copy-constructor for Gtkmm2ext::Bindings
This copies all the binding information for an existing Bindings object, but then mutates all the action names from foo/bar to name/bar where name is the given name for the new Bindings object.
This commit is contained in:
parent
e9d0085c5c
commit
7d1886b22d
2 changed files with 31 additions and 0 deletions
|
|
@ -378,6 +378,17 @@ Bindings::Bindings (std::string const& name)
|
||||||
bindings.push_back (this);
|
bindings.push_back (this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Bindings::Bindings (std::string const & name, Bindings const & other)
|
||||||
|
: _name (name)
|
||||||
|
, press_bindings (other.press_bindings)
|
||||||
|
, release_bindings (other.release_bindings)
|
||||||
|
, button_press_bindings (other.button_press_bindings)
|
||||||
|
, button_release_bindings (other.button_release_bindings)
|
||||||
|
{
|
||||||
|
relativize ();
|
||||||
|
bindings.push_back (this);
|
||||||
|
}
|
||||||
|
|
||||||
Bindings::~Bindings()
|
Bindings::~Bindings()
|
||||||
{
|
{
|
||||||
bindings.remove (this);
|
bindings.remove (this);
|
||||||
|
|
@ -521,6 +532,23 @@ Bindings::activate (KeyboardKey kb, Operation op)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Bindings::relativize ()
|
||||||
|
{
|
||||||
|
for (auto & [key,action_info] : press_bindings) {
|
||||||
|
action_info.action_name = _name + action_info.action_name.substr (action_info.action_name.find_first_of ('/'));
|
||||||
|
}
|
||||||
|
for (auto & [key,action_info] : release_bindings) {
|
||||||
|
action_info.action_name = _name + action_info.action_name.substr (action_info.action_name.find_first_of ('/'));
|
||||||
|
}
|
||||||
|
for (auto & [mb,action_info] : button_press_bindings) {
|
||||||
|
action_info.action_name = _name + action_info.action_name.substr (action_info.action_name.find_first_of ('/'));
|
||||||
|
}
|
||||||
|
for (auto & [mb,action_info] : button_release_bindings) {
|
||||||
|
action_info.action_name = _name + action_info.action_name.substr (action_info.action_name.find_first_of ('/'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Bindings::associate ()
|
Bindings::associate ()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -118,6 +118,7 @@ class LIBGTKMM2EXT_API Bindings {
|
||||||
typedef std::map<KeyboardKey,ActionInfo> KeybindingMap;
|
typedef std::map<KeyboardKey,ActionInfo> KeybindingMap;
|
||||||
|
|
||||||
Bindings (std::string const& name);
|
Bindings (std::string const& name);
|
||||||
|
Bindings (std::string const & name, Bindings const & other);
|
||||||
~Bindings ();
|
~Bindings ();
|
||||||
|
|
||||||
std::string const& name() const { return _name; }
|
std::string const& name() const { return _name; }
|
||||||
|
|
@ -191,6 +192,8 @@ class LIBGTKMM2EXT_API Bindings {
|
||||||
const KeybindingMap& get_keymap (Operation op) const;
|
const KeybindingMap& get_keymap (Operation op) const;
|
||||||
MouseButtonBindingMap& get_mousemap (Operation op);
|
MouseButtonBindingMap& get_mousemap (Operation op);
|
||||||
|
|
||||||
|
void relativize ();
|
||||||
|
|
||||||
/* GTK has the following position a Gtk::Action:
|
/* GTK has the following position a Gtk::Action:
|
||||||
*
|
*
|
||||||
* accel_path: <Actions>/GroupName/ActionName
|
* accel_path: <Actions>/GroupName/ActionName
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue