| @@ -364,7 +364,7 @@ String String::charToString (const juce_wchar character) | |||||
| namespace NumberToStringConverters | namespace NumberToStringConverters | ||||
| { | { | ||||
| template <typename Type> | template <typename Type> | ||||
| static inline char* printDigits (char* t, Type v) noexcept | |||||
| static char* printDigits (char* t, Type v) noexcept | |||||
| { | { | ||||
| *--t = 0; | *--t = 0; | ||||
| @@ -507,10 +507,9 @@ juce_wchar String::operator[] (int index) const noexcept | |||||
| int String::hashCode() const noexcept | int String::hashCode() const noexcept | ||||
| { | { | ||||
| CharPointerType t (text); | |||||
| int result = 0; | int result = 0; | ||||
| while (! t.isEmpty()) | |||||
| for (CharPointerType t (text); ! t.isEmpty();) | |||||
| result = 31 * result + (int) t.getAndAdvance(); | result = 31 * result + (int) t.getAndAdvance(); | ||||
| return result; | return result; | ||||
| @@ -518,10 +517,9 @@ int String::hashCode() const noexcept | |||||
| int64 String::hashCode64() const noexcept | int64 String::hashCode64() const noexcept | ||||
| { | { | ||||
| CharPointerType t (text); | |||||
| int64 result = 0; | int64 result = 0; | ||||
| while (! t.isEmpty()) | |||||
| for (CharPointerType t (text); ! t.isEmpty();) | |||||
| result = 101 * result + t.getAndAdvance(); | result = 101 * result + t.getAndAdvance(); | ||||
| return result; | return result; | ||||
| @@ -237,19 +237,43 @@ struct Component::ComponentHelpers | |||||
| template <typename PointOrRect> | template <typename PointOrRect> | ||||
| static PointOrRect convertFromParentSpace (const Component& comp, PointOrRect pointInParentSpace) | 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> | template <typename PointOrRect> | ||||
| static PointOrRect convertToParentSpace (const Component& comp, PointOrRect pointInLocalSpace) | 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(); | |||||
| } | |||||
| if (comp.affineTransform != nullptr) | |||||
| pointInLocalSpace = pointInLocalSpace.transformedBy (*comp.affineTransform); | |||||
| return (pointInLocalSpace + comp.getPosition()).transformedBy (*comp.affineTransform); | |||||
| return pointInLocalSpace; | |||||
| } | } | ||||
| template <typename PointOrRect> | template <typename PointOrRect> | ||||
| @@ -59,6 +59,12 @@ public: | |||||
| static Point<int> screenPosToLocalPos (Component& comp, Point<int> pos) | 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)); | return comp.getLocalPoint (nullptr, Component::ComponentHelpers::unscaledScreenPosToScaled (pos)); | ||||
| } | } | ||||
| @@ -66,9 +72,8 @@ public: | |||||
| { | { | ||||
| if (ComponentPeer* const peer = getPeer()) | if (ComponentPeer* const peer = getPeer()) | ||||
| { | { | ||||
| Point<int> relativePos (Component::ComponentHelpers::unscaledScreenPosToScaled (peer->globalToLocal (screenPos))); | |||||
| Component& comp = peer->getComponent(); | 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) | // (the contains() call is needed to test for overlapping desktop windows) | ||||
| if (comp.contains (relativePos)) | if (comp.contains (relativePos)) | ||||
| @@ -270,7 +270,7 @@ public: | |||||
| r.origin.y = [[view superview] frame].size.height - r.origin.y - r.size.height; | 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 | Rectangle<int> getBounds() const override | ||||