| @@ -98,12 +98,12 @@ public: | |||||
| // (note: use a local copy of this in case the callback runs | // (note: use a local copy of this in case the callback runs | ||||
| // a modal loop and deletes this object before the method completes) | // a modal loop and deletes this object before the method completes) | ||||
| auto details = sourceDetails; | auto details = sourceDetails; | ||||
| DragAndDropTarget* finalTarget = nullptr; | |||||
| auto wasVisible = isVisible(); | auto wasVisible = isVisible(); | ||||
| setVisible (false); | setVisible (false); | ||||
| Component* unused; | |||||
| finalTarget = findTarget (e.getScreenPosition(), details.localPosition, unused); | |||||
| const auto [finalTarget, unused, localPosition] = findTarget (e.getScreenPosition()); | |||||
| ignoreUnused (unused); | |||||
| details.localPosition = localPosition; | |||||
| if (wasVisible) // fade the component and remove it - it'll be deleted later by the timer callback | if (wasVisible) // fade the component and remove it - it'll be deleted later by the timer callback | ||||
| dismissWithAnimation (finalTarget == nullptr); | dismissWithAnimation (finalTarget == nullptr); | ||||
| @@ -133,8 +133,8 @@ public: | |||||
| setNewScreenPos (screenPos); | setNewScreenPos (screenPos); | ||||
| Component* newTargetComp; | |||||
| auto* newTarget = findTarget (screenPos, details.localPosition, newTargetComp); | |||||
| const auto [newTarget, newTargetComp, localPosition] = findTarget (screenPos); | |||||
| details.localPosition = localPosition; | |||||
| setVisible (newTarget == nullptr || newTarget->shouldDrawDragImageWhenOver()); | setVisible (newTarget == nullptr || newTarget->shouldDrawDragImageWhenOver()); | ||||
| @@ -288,8 +288,7 @@ private: | |||||
| return getLocalPoint (sourceComponent, offsetInSource) - getLocalPoint (sourceComponent, Point<int>()); | return getLocalPoint (sourceComponent, offsetInSource) - getLocalPoint (sourceComponent, Point<int>()); | ||||
| } | } | ||||
| DragAndDropTarget* findTarget (Point<int> screenPos, Point<int>& relativePos, | |||||
| Component*& resultComponent) const | |||||
| std::tuple<DragAndDropTarget*, Component*, Point<int>> findTarget (Point<int> screenPos) const | |||||
| { | { | ||||
| auto* hit = getParentComponent(); | auto* hit = getParentComponent(); | ||||
| @@ -305,20 +304,13 @@ private: | |||||
| while (hit != nullptr) | while (hit != nullptr) | ||||
| { | { | ||||
| if (auto* ddt = dynamic_cast<DragAndDropTarget*> (hit)) | if (auto* ddt = dynamic_cast<DragAndDropTarget*> (hit)) | ||||
| { | |||||
| if (ddt->isInterestedInDragSource (details)) | if (ddt->isInterestedInDragSource (details)) | ||||
| { | |||||
| relativePos = hit->getLocalPoint (nullptr, screenPos); | |||||
| resultComponent = hit; | |||||
| return ddt; | |||||
| } | |||||
| } | |||||
| return std::tuple (ddt, hit, hit->getLocalPoint (nullptr, screenPos)); | |||||
| hit = hit->getParentComponent(); | hit = hit->getParentComponent(); | ||||
| } | } | ||||
| resultComponent = nullptr; | |||||
| return nullptr; | |||||
| return {}; | |||||
| } | } | ||||
| void setNewScreenPos (Point<int> screenPos) | void setNewScreenPos (Point<int> screenPos) | ||||