mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-06 23:05:04 +01:00
design to handle "cloned" bindings/actions
This commit is contained in:
parent
7a8fbdd5b1
commit
87ed40a855
2 changed files with 74 additions and 18 deletions
|
|
@ -373,19 +373,21 @@ KeyboardKey::make_key (const string& str, KeyboardKey& k)
|
||||||
|
|
||||||
/*================================= Bindings =================================*/
|
/*================================= Bindings =================================*/
|
||||||
Bindings::Bindings (std::string const& name)
|
Bindings::Bindings (std::string const& name)
|
||||||
: _name (name)
|
: _parent (nullptr)
|
||||||
|
, _name (name)
|
||||||
{
|
{
|
||||||
bindings.push_back (this);
|
bindings.push_back (this);
|
||||||
}
|
}
|
||||||
|
|
||||||
Bindings::Bindings (std::string const & name, Bindings const & other)
|
Bindings::Bindings (std::string const & name, Bindings & other)
|
||||||
: _name (name)
|
: _parent (&other)
|
||||||
, press_bindings (other.press_bindings)
|
, _name (name)
|
||||||
, release_bindings (other.release_bindings)
|
|
||||||
, button_press_bindings (other.button_press_bindings)
|
|
||||||
, button_release_bindings (other.button_release_bindings)
|
|
||||||
{
|
{
|
||||||
relativize ();
|
PBD::stacktrace (std::cerr, 13);
|
||||||
|
copy_from_parent (false);
|
||||||
|
|
||||||
|
BindingsChanged.connect_same_thread (bc, std::bind (&Bindings::parent_changed, this, _1));
|
||||||
|
|
||||||
bindings.push_back (this);
|
bindings.push_back (this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -536,7 +538,9 @@ void
|
||||||
Bindings::relativize ()
|
Bindings::relativize ()
|
||||||
{
|
{
|
||||||
for (auto & [key,action_info] : press_bindings) {
|
for (auto & [key,action_info] : press_bindings) {
|
||||||
|
std::cerr << action_info.action_name << " ---------> ";
|
||||||
action_info.action_name = _name + action_info.action_name;
|
action_info.action_name = _name + action_info.action_name;
|
||||||
|
std::cerr << action_info.action_name << std::endl;
|
||||||
}
|
}
|
||||||
for (auto & [key,action_info] : release_bindings) {
|
for (auto & [key,action_info] : release_bindings) {
|
||||||
action_info.action_name = _name + action_info.action_name;
|
action_info.action_name = _name + action_info.action_name;
|
||||||
|
|
@ -550,13 +554,8 @@ Bindings::relativize ()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Bindings::associate ()
|
Bindings::associate (bool force)
|
||||||
{
|
{
|
||||||
#warning find a better solution than this
|
|
||||||
if (_name == "Editing" || _name == "MIDI") {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
KeybindingMap::iterator k;
|
KeybindingMap::iterator k;
|
||||||
|
|
||||||
for (k = press_bindings.begin(); k != press_bindings.end(); ++k) {
|
for (k = press_bindings.begin(); k != press_bindings.end(); ++k) {
|
||||||
|
|
@ -595,6 +594,55 @@ Bindings::dissociate ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Bindings::copy_from_parent (bool assoc)
|
||||||
|
{
|
||||||
|
assert (_parent);
|
||||||
|
press_bindings.clear ();
|
||||||
|
release_bindings.clear ();
|
||||||
|
|
||||||
|
_parent->clone_press (press_bindings);
|
||||||
|
_parent->clone_release (release_bindings);
|
||||||
|
|
||||||
|
dissociate ();
|
||||||
|
relativize ();
|
||||||
|
|
||||||
|
if (assoc) {
|
||||||
|
associate (true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Bindings::parent_changed (Bindings* changed)
|
||||||
|
{
|
||||||
|
if (_parent != changed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
press_bindings.clear();
|
||||||
|
release_bindings.clear();
|
||||||
|
|
||||||
|
copy_from_parent (true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Bindings::clone_press (KeybindingMap& target) const
|
||||||
|
{
|
||||||
|
clone_kbd_bindings (press_bindings, target);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Bindings::clone_release (KeybindingMap& target) const
|
||||||
|
{
|
||||||
|
clone_kbd_bindings (release_bindings, target);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Bindings::clone_kbd_bindings (KeybindingMap const & src, KeybindingMap& target) const
|
||||||
|
{
|
||||||
|
target = src;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Bindings::push_to_gtk (KeyboardKey kb, RefPtr<Action> what)
|
Bindings::push_to_gtk (KeyboardKey kb, RefPtr<Action> what)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -118,14 +118,15 @@ 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 (std::string const & name, Bindings & other);
|
||||||
~Bindings ();
|
~Bindings ();
|
||||||
|
|
||||||
std::string const& name() const { return _name; }
|
std::string const& name() const { return _name; }
|
||||||
|
Bindings const * parent() const { return _parent; }
|
||||||
|
|
||||||
void reassociate ();
|
void associate (bool force = false);
|
||||||
void associate ();
|
|
||||||
void dissociate ();
|
void dissociate ();
|
||||||
|
void reassociate ();
|
||||||
|
|
||||||
bool empty() const;
|
bool empty() const;
|
||||||
bool empty_keys () const;
|
bool empty_keys () const;
|
||||||
|
|
@ -178,6 +179,7 @@ class LIBGTKMM2EXT_API Bindings {
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Bindings * _parent;
|
||||||
std::string _name;
|
std::string _name;
|
||||||
KeybindingMap press_bindings;
|
KeybindingMap press_bindings;
|
||||||
KeybindingMap release_bindings;
|
KeybindingMap release_bindings;
|
||||||
|
|
@ -193,6 +195,12 @@ class LIBGTKMM2EXT_API Bindings {
|
||||||
MouseButtonBindingMap& get_mousemap (Operation op);
|
MouseButtonBindingMap& get_mousemap (Operation op);
|
||||||
|
|
||||||
void relativize ();
|
void relativize ();
|
||||||
|
void clone_press (KeybindingMap&) const;
|
||||||
|
void clone_release (KeybindingMap&) const;
|
||||||
|
void clone_kbd_bindings (KeybindingMap const&, KeybindingMap&) const;
|
||||||
|
void copy_from_parent (bool associate);
|
||||||
|
void parent_changed (Bindings*);
|
||||||
|
PBD::ScopedConnection bc;
|
||||||
|
|
||||||
/* GTK has the following position a Gtk::Action:
|
/* GTK has the following position a Gtk::Action:
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue