bindings: add a mechanism to prevent binding activation during drag

This commit is contained in:
Paul Davis
2022-04-18 11:38:21 -06:00
parent 8b82de7ac1
commit 729f930974
2 changed files with 18 additions and 0 deletions

View File

@@ -46,6 +46,7 @@ using namespace PBD;
list<Bindings*> Bindings::bindings; /* global. Gulp */
PBD::Signal1<void,Bindings*> Bindings::BindingsChanged;
int Bindings::_drag_active = 0;
template <typename IteratorValueType>
struct ActionNameRegistered
@@ -492,6 +493,12 @@ Bindings::activate (KeyboardKey kb, Operation op)
action = ActionManager::get_action (k->second.action_name, false);
}
/* bindings cannot be used during drags */
if (_drag_active) {
return true;
}
if (action) {
/* lets do it ... */
if (action->get_sensitive()) {

View File

@@ -167,6 +167,15 @@ class LIBGTKMM2EXT_API Bindings {
static PBD::Signal1<void,Bindings*> BindingsChanged;
struct DragsBlockBindings {
DragsBlockBindings() { Bindings::_drag_active++; }
~DragsBlockBindings() {
if (Bindings::_drag_active--) {
Bindings::_drag_active--;
}
}
};
private:
std::string _name;
KeybindingMap press_bindings;
@@ -197,6 +206,8 @@ class LIBGTKMM2EXT_API Bindings {
*/
static std::string ardour_action_name (Glib::RefPtr<Gtk::Action>);
static int _drag_active;
friend struct DragsBlockBindings;
};
} // namespace