mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-20 01:14:20 +00:00
LinuxComponentPeer: Properly transform coordinates into peer space when collision testing
This commit is contained in:
parent
092314deac
commit
3e0fa4489a
1 changed files with 20 additions and 4 deletions
|
|
@ -147,12 +147,12 @@ public:
|
|||
|
||||
Point<float> localToGlobal (Point<float> relativePosition) override
|
||||
{
|
||||
return relativePosition + getScreenPosition (false).toFloat();
|
||||
return localToGlobal (*this, relativePosition);
|
||||
}
|
||||
|
||||
Point<float> globalToLocal (Point<float> screenPosition) override
|
||||
{
|
||||
return screenPosition - getScreenPosition (false).toFloat();
|
||||
return globalToLocal (*this, screenPosition);
|
||||
}
|
||||
|
||||
using ComponentPeer::localToGlobal;
|
||||
|
|
@ -231,8 +231,11 @@ public:
|
|||
if (! c->isVisible())
|
||||
continue;
|
||||
|
||||
if (auto* peer = c->getPeer())
|
||||
if (peer->contains (localPos + bounds.getPosition() - peer->getBounds().getPosition(), true))
|
||||
auto* otherPeer = c->getPeer();
|
||||
jassert (otherPeer == nullptr || dynamic_cast<LinuxComponentPeer*> (c->getPeer()) != nullptr);
|
||||
|
||||
if (auto* peer = static_cast<LinuxComponentPeer*> (otherPeer))
|
||||
if (peer->contains (globalToLocal (*peer, localToGlobal (*this, localPos.toFloat())).roundToInt(), true))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -474,6 +477,19 @@ private:
|
|||
JUCE_DECLARE_NON_COPYABLE (LinuxRepaintManager)
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
template <typename This>
|
||||
static Point<float> localToGlobal (This& t, Point<float> relativePosition)
|
||||
{
|
||||
return relativePosition + t.getScreenPosition (false).toFloat();
|
||||
}
|
||||
|
||||
template <typename This>
|
||||
static Point<float> globalToLocal (This& t, Point<float> screenPosition)
|
||||
{
|
||||
return screenPosition - t.getScreenPosition (false).toFloat();
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void settingChanged (const XWindowSystemUtilities::XSetting& settingThatHasChanged) override
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue