1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

ComponentPeer: Correctly scale drag and drop coordinates to account for global scale

This commit is contained in:
reuk 2022-02-21 18:18:17 +00:00
parent 9ba5dd5a30
commit eb6e579f0a
No known key found for this signature in database
GPG key ID: 9ADCD339CFC98A11
5 changed files with 36 additions and 41 deletions

View file

@ -275,6 +275,18 @@ struct ScalingHelpers
static Rectangle<int> subtractPosition (Rectangle<int> p, const Component& c) noexcept { return p - c.getPosition(); }
static Point<float> subtractPosition (Point<float> p, const Component& c) noexcept { return p - c.getPosition().toFloat(); }
static Rectangle<float> subtractPosition (Rectangle<float> p, const Component& c) noexcept { return p - c.getPosition().toFloat(); }
static Point<float> screenPosToLocalPos (Component& comp, Point<float> pos)
{
if (auto* peer = comp.getPeer())
{
pos = peer->globalToLocal (pos);
auto& peerComp = peer->getComponent();
return comp.getLocalPoint (&peerComp, unscaledScreenPosToScaled (peerComp, pos));
}
return comp.getLocalPoint (nullptr, unscaledScreenPosToScaled (comp, pos));
}
};
static const char colourPropertyPrefix[] = "jcclr_";