|
|
|
@@ -329,47 +329,48 @@ struct Component::ComponentHelpers |
|
|
|
}
|
|
|
|
|
|
|
|
template <typename PointOrRect>
|
|
|
|
static PointOrRect convertFromParentSpace (const Component& comp, PointOrRect pointInParentSpace)
|
|
|
|
static PointOrRect convertFromParentSpace (const Component& comp, const PointOrRect pointInParentSpace)
|
|
|
|
{
|
|
|
|
if (comp.affineTransform != nullptr)
|
|
|
|
pointInParentSpace = pointInParentSpace.transformedBy (comp.affineTransform->inverted());
|
|
|
|
const auto transformed = comp.affineTransform != nullptr ? pointInParentSpace.transformedBy (comp.affineTransform->inverted())
|
|
|
|
: pointInParentSpace;
|
|
|
|
|
|
|
|
if (comp.isOnDesktop())
|
|
|
|
{
|
|
|
|
if (auto* peer = comp.getPeer())
|
|
|
|
pointInParentSpace = ScalingHelpers::unscaledScreenPosToScaled
|
|
|
|
(comp, peer->globalToLocal (ScalingHelpers::scaledScreenPosToUnscaled (pointInParentSpace)));
|
|
|
|
else
|
|
|
|
jassertfalse;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pointInParentSpace = ScalingHelpers::subtractPosition (pointInParentSpace, comp);
|
|
|
|
return ScalingHelpers::unscaledScreenPosToScaled (comp, peer->globalToLocal (ScalingHelpers::scaledScreenPosToUnscaled (transformed)));
|
|
|
|
|
|
|
|
jassertfalse;
|
|
|
|
return transformed;
|
|
|
|
}
|
|
|
|
|
|
|
|
return pointInParentSpace;
|
|
|
|
if (comp.getParentComponent() == nullptr)
|
|
|
|
return ScalingHelpers::subtractPosition (ScalingHelpers::unscaledScreenPosToScaled (comp, ScalingHelpers::scaledScreenPosToUnscaled (transformed)), comp);
|
|
|
|
|
|
|
|
return ScalingHelpers::subtractPosition (transformed, comp);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename PointOrRect>
|
|
|
|
static PointOrRect convertToParentSpace (const Component& comp, PointOrRect pointInLocalSpace)
|
|
|
|
static PointOrRect convertToParentSpace (const Component& comp, const PointOrRect pointInLocalSpace)
|
|
|
|
{
|
|
|
|
if (comp.isOnDesktop())
|
|
|
|
const auto preTransform = [&]
|
|
|
|
{
|
|
|
|
if (auto* peer = comp.getPeer())
|
|
|
|
pointInLocalSpace = ScalingHelpers::unscaledScreenPosToScaled
|
|
|
|
(peer->localToGlobal (ScalingHelpers::scaledScreenPosToUnscaled (comp, pointInLocalSpace)));
|
|
|
|
else
|
|
|
|
if (comp.isOnDesktop())
|
|
|
|
{
|
|
|
|
if (auto* peer = comp.getPeer())
|
|
|
|
return ScalingHelpers::unscaledScreenPosToScaled (peer->localToGlobal (ScalingHelpers::scaledScreenPosToUnscaled (comp, pointInLocalSpace)));
|
|
|
|
|
|
|
|
jassertfalse;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pointInLocalSpace = ScalingHelpers::addPosition (pointInLocalSpace, comp);
|
|
|
|
}
|
|
|
|
return pointInLocalSpace;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (comp.getParentComponent() == nullptr)
|
|
|
|
return ScalingHelpers::unscaledScreenPosToScaled (ScalingHelpers::scaledScreenPosToUnscaled (comp, ScalingHelpers::addPosition (pointInLocalSpace, comp)));
|
|
|
|
|
|
|
|
if (comp.affineTransform != nullptr)
|
|
|
|
pointInLocalSpace = pointInLocalSpace.transformedBy (*comp.affineTransform);
|
|
|
|
return ScalingHelpers::addPosition (pointInLocalSpace, comp);
|
|
|
|
}();
|
|
|
|
|
|
|
|
return pointInLocalSpace;
|
|
|
|
return comp.affineTransform != nullptr ? preTransform.transformedBy (*comp.affineTransform)
|
|
|
|
: preTransform;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename PointOrRect>
|
|
|
|
|