mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-26 02:14:22 +00:00
Fix for broken screen coord conversion in plugin windows.
This commit is contained in:
parent
aafa12fd81
commit
fc21a145cf
4 changed files with 41 additions and 14 deletions
|
|
@ -364,7 +364,7 @@ String String::charToString (const juce_wchar character)
|
|||
namespace NumberToStringConverters
|
||||
{
|
||||
template <typename Type>
|
||||
static inline char* printDigits (char* t, Type v) noexcept
|
||||
static char* printDigits (char* t, Type v) noexcept
|
||||
{
|
||||
*--t = 0;
|
||||
|
||||
|
|
@ -507,10 +507,9 @@ juce_wchar String::operator[] (int index) const noexcept
|
|||
|
||||
int String::hashCode() const noexcept
|
||||
{
|
||||
CharPointerType t (text);
|
||||
int result = 0;
|
||||
|
||||
while (! t.isEmpty())
|
||||
for (CharPointerType t (text); ! t.isEmpty();)
|
||||
result = 31 * result + (int) t.getAndAdvance();
|
||||
|
||||
return result;
|
||||
|
|
@ -518,10 +517,9 @@ int String::hashCode() const noexcept
|
|||
|
||||
int64 String::hashCode64() const noexcept
|
||||
{
|
||||
CharPointerType t (text);
|
||||
int64 result = 0;
|
||||
|
||||
while (! t.isEmpty())
|
||||
for (CharPointerType t (text); ! t.isEmpty();)
|
||||
result = 101 * result + t.getAndAdvance();
|
||||
|
||||
return result;
|
||||
|
|
|
|||
|
|
@ -237,19 +237,43 @@ struct Component::ComponentHelpers
|
|||
template <typename PointOrRect>
|
||||
static PointOrRect convertFromParentSpace (const Component& comp, PointOrRect pointInParentSpace)
|
||||
{
|
||||
if (comp.affineTransform == nullptr)
|
||||
return pointInParentSpace - comp.getPosition();
|
||||
if (comp.affineTransform != nullptr)
|
||||
pointInParentSpace = pointInParentSpace.transformedBy (comp.affineTransform->inverted());
|
||||
|
||||
return pointInParentSpace.transformedBy (comp.affineTransform->inverted()) - comp.getPosition();
|
||||
if (comp.isOnDesktop())
|
||||
{
|
||||
if (ComponentPeer* peer = comp.getPeer())
|
||||
pointInParentSpace = unscaledScreenPosToScaled (peer->globalToLocal (scaledScreenPosToUnscaled (pointInParentSpace)));
|
||||
else
|
||||
jassertfalse;
|
||||
}
|
||||
else
|
||||
{
|
||||
pointInParentSpace -= comp.getPosition();
|
||||
}
|
||||
|
||||
return pointInParentSpace;
|
||||
}
|
||||
|
||||
template <typename PointOrRect>
|
||||
static PointOrRect convertToParentSpace (const Component& comp, PointOrRect pointInLocalSpace)
|
||||
{
|
||||
if (comp.affineTransform == nullptr)
|
||||
return pointInLocalSpace + comp.getPosition();
|
||||
if (comp.isOnDesktop())
|
||||
{
|
||||
if (ComponentPeer* peer = comp.getPeer())
|
||||
pointInLocalSpace = unscaledScreenPosToScaled (peer->localToGlobal (scaledScreenPosToUnscaled (pointInLocalSpace)));
|
||||
else
|
||||
jassertfalse;
|
||||
}
|
||||
else
|
||||
{
|
||||
pointInLocalSpace += comp.getPosition();
|
||||
}
|
||||
|
||||
return (pointInLocalSpace + comp.getPosition()).transformedBy (*comp.affineTransform);
|
||||
if (comp.affineTransform != nullptr)
|
||||
pointInLocalSpace = pointInLocalSpace.transformedBy (*comp.affineTransform);
|
||||
|
||||
return pointInLocalSpace;
|
||||
}
|
||||
|
||||
template <typename PointOrRect>
|
||||
|
|
|
|||
|
|
@ -59,6 +59,12 @@ public:
|
|||
|
||||
static Point<int> screenPosToLocalPos (Component& comp, Point<int> pos)
|
||||
{
|
||||
if (ComponentPeer* const peer = comp.getPeer())
|
||||
{
|
||||
pos = peer->globalToLocal (pos);
|
||||
return comp.getLocalPoint (&peer->getComponent(), Component::ComponentHelpers::unscaledScreenPosToScaled (pos));
|
||||
}
|
||||
|
||||
return comp.getLocalPoint (nullptr, Component::ComponentHelpers::unscaledScreenPosToScaled (pos));
|
||||
}
|
||||
|
||||
|
|
@ -66,9 +72,8 @@ public:
|
|||
{
|
||||
if (ComponentPeer* const peer = getPeer())
|
||||
{
|
||||
Point<int> relativePos (Component::ComponentHelpers::unscaledScreenPosToScaled (peer->globalToLocal (screenPos)));
|
||||
Component& comp = peer->getComponent();
|
||||
Point<int> relativePos (Component::ComponentHelpers::convertFromParentSpace (comp,
|
||||
Component::ComponentHelpers::unscaledScreenPosToScaled (screenPos)));
|
||||
|
||||
// (the contains() call is needed to test for overlapping desktop windows)
|
||||
if (comp.contains (relativePos))
|
||||
|
|
|
|||
|
|
@ -270,7 +270,7 @@ public:
|
|||
r.origin.y = [[view superview] frame].size.height - r.origin.y - r.size.height;
|
||||
}
|
||||
|
||||
return Rectangle<int> (convertToRectInt (r));
|
||||
return convertToRectInt (r);
|
||||
}
|
||||
|
||||
Rectangle<int> getBounds() const override
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue