From fffd7d6d0e6bfeaba21f1ebe81ae9d6ce7423941 Mon Sep 17 00:00:00 2001 From: Paul Walker Date: Sun, 22 Aug 2021 15:49:14 -0400 Subject: [PATCH] Restore Drag and Drop after Accessibility changes To make accessibility more reasonable I group components in overlays but those overlays messed up z order a bit and also made the component heirarchy deeper. So handle both of those and allow dnd to work with a deeper heirarchy Closes #4858 --- src/gui/SurgeGUIEditor.cpp | 32 ++++++++++++++++++---- src/gui/widgets/ModulationSourceButton.cpp | 1 + 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/gui/SurgeGUIEditor.cpp b/src/gui/SurgeGUIEditor.cpp index b3aba62ab3d..4f52c07f975 100644 --- a/src/gui/SurgeGUIEditor.cpp +++ b/src/gui/SurgeGUIEditor.cpp @@ -3740,16 +3740,36 @@ void SurgeGUIEditor::modSourceButtonDroppedAt(Surge::Widgets::ModulationSourceBu // We need to do this search vs componentAt because componentAt will return self since I am // there being dropped juce::Component *target = nullptr; - for (auto kid : frame->getChildren()) - { - if (kid && kid->isVisible() && kid != msb && kid->getBounds().contains(pt)) + + auto isDroppable = [msb](juce::Component *c) { + auto tMSB = dynamic_cast(c); + auto tMCI = dynamic_cast(c); + if (tMSB && msb->isMeta && tMSB && tMSB->isMeta) + return true; + if (tMCI) + return true; + return false; + }; + auto recC = [isDroppable, msb, pt](juce::Component *p, auto rec) -> juce::Component * { + for (auto kid : p->getChildren()) { - target = kid; - // break; + if (kid && kid->isVisible() && kid != msb && kid->getBounds().contains(pt)) + { + if (isDroppable(kid)) + return kid; + + auto q = rec(kid, rec); + if (q) + return q; + } } - } + return nullptr; + }; + target = recC(frame.get(), recC); + if (!target) return; + auto tMSB = dynamic_cast(target); auto tMCI = dynamic_cast(target); if (msb->isMeta && tMSB && tMSB->isMeta) diff --git a/src/gui/widgets/ModulationSourceButton.cpp b/src/gui/widgets/ModulationSourceButton.cpp index 96b5898ec83..39a984a2cea 100644 --- a/src/gui/widgets/ModulationSourceButton.cpp +++ b/src/gui/widgets/ModulationSourceButton.cpp @@ -410,6 +410,7 @@ void ModulationSourceButton::mouseDrag(const juce::MouseEvent &event) return; } + getParentComponent()->toFront(false); toFront(false); mouseMode = DRAG_COMPONENT_HAPPEN; componentDragger.dragComponent(this, event, nullptr);