Browse Source

DragAndDropContainer: Avoid out-parameters

v7.0.9
reuk 2 years ago
parent
commit
b7beb42153
No known key found for this signature in database GPG Key ID: FCB43929F012EE5C
1 changed files with 8 additions and 16 deletions
  1. +8
    -16
      modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp

+ 8
- 16
modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp View File

@@ -98,12 +98,12 @@ public:
// (note: use a local copy of this in case the callback runs
// a modal loop and deletes this object before the method completes)
auto details = sourceDetails;
DragAndDropTarget* finalTarget = nullptr;
auto wasVisible = isVisible();
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
dismissWithAnimation (finalTarget == nullptr);
@@ -133,8 +133,8 @@ public:
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());
@@ -288,8 +288,7 @@ private:
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();
@@ -305,20 +304,13 @@ private:
while (hit != nullptr)
{
if (auto* ddt = dynamic_cast<DragAndDropTarget*> (hit))
{
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();
}
resultComponent = nullptr;
return nullptr;
return {};
}
void setNewScreenPos (Point<int> screenPos)


Loading…
Cancel
Save