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:
parent
9ba5dd5a30
commit
eb6e579f0a
5 changed files with 36 additions and 41 deletions
|
|
@ -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_";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue