36 #if JUCE_MODAL_LOOPS_PERMITTED
37 static void* runModalLoopCallback (
void* userData)
43 static Identifier getColourPropertyID (
int colourID)
50 for (
auto v = (
uint32) colourID;;)
52 *--t =
"0123456789abcdef" [v & 15];
59 for (
int i = (
int)
sizeof (colourPropertyPrefix) - 1; --i >= 0;)
60 *--t = colourPropertyPrefix[i];
70 && comp.
hitTest (intPoint.x, intPoint.y);
74 template <
typename Po
intOrRect>
75 static PointOrRect rawPeerPositionToLocal (
const Component& comp, PointOrRect pos)
noexcept
80 return SH::unscaledScreenPosToScaled (comp, pos);
84 template <
typename Po
intOrRect>
85 static PointOrRect localPositionToRawPeerPos (
const Component& comp, PointOrRect pos)
noexcept
90 return SH::scaledScreenPosToUnscaled (comp, pos);
93 template <
typename Po
intOrRect>
94 static PointOrRect convertFromParentSpace (
const Component& comp,
const PointOrRect pointInParentSpace)
96 const auto transformed = comp.affineTransform !=
nullptr ? pointInParentSpace.transformedBy (comp.affineTransform->inverted())
101 if (
auto* peer = comp.
getPeer())
102 return SH::unscaledScreenPosToScaled (comp, peer->globalToLocal (SH::scaledScreenPosToUnscaled (transformed)));
109 return SH::subtractPosition (SH::unscaledScreenPosToScaled (comp, SH::scaledScreenPosToUnscaled (transformed)), comp);
111 return SH::subtractPosition (transformed, comp);
114 template <
typename Po
intOrRect>
115 static PointOrRect convertToParentSpace (
const Component& comp,
const PointOrRect pointInLocalSpace)
117 const auto preTransform = [&]
121 if (
auto* peer = comp.
getPeer())
122 return SH::unscaledScreenPosToScaled (peer->localToGlobal (SH::scaledScreenPosToUnscaled (comp, pointInLocalSpace)));
125 return pointInLocalSpace;
129 return SH::unscaledScreenPosToScaled (SH::scaledScreenPosToUnscaled (comp, SH::addPosition (pointInLocalSpace, comp)));
131 return SH::addPosition (pointInLocalSpace, comp);
134 return comp.affineTransform !=
nullptr ? preTransform.transformedBy (*comp.affineTransform)
138 template <
typename Po
intOrRect>
139 static PointOrRect convertFromDistantParentSpace (
const Component* parent,
const Component& target, PointOrRect coordInParent)
142 jassert (directParent !=
nullptr);
144 if (directParent == parent)
145 return convertFromParentSpace (target, coordInParent);
147 JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6011)
148 return convertFromParentSpace (target, convertFromDistantParentSpace (parent, *directParent, coordInParent));
149 JUCE_END_IGNORE_WARNINGS_MSVC
152 template <
typename Po
intOrRect>
153 static PointOrRect convertCoordinate (
const Component* target,
const Component* source, PointOrRect p)
155 while (source !=
nullptr)
157 if (source == target)
160 JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6011)
163 return convertFromDistantParentSpace (source, *target, p);
165 JUCE_END_IGNORE_WARNINGS_MSVC
167 p = convertToParentSpace (*source, p);
172 if (target ==
nullptr)
177 p = convertFromParentSpace (*topLevelComp, p);
179 if (topLevelComp == target)
182 return convertFromDistantParentSpace (topLevelComp, *target, p);
188 bool wasClipped =
false;
190 for (
int i = comp.childComponentList.size(); --i >= 0;)
192 auto& child = *comp.childComponentList.getUnchecked (i);
194 if (child.isVisible() && ! child.isTransformed())
196 auto newClip = clipRect.
getIntersection (child.boundsRelativeToParent);
198 if (! newClip.isEmpty())
200 if (child.isOpaque() && child.componentTransparency == 0)
207 auto childPos = child.getPosition();
209 if (clipObscuredRegions (child, g, newClip - childPos, childPos + delta))
222 return p->getLocalBounds();
227 static void releaseAllCachedImageResources (
Component& c)
230 cached->releaseResources();
232 for (
auto* child : c.childComponentList)
233 releaseAllCachedImageResources (*child);
237 static bool modalWouldBlockComponent (
const Component& maybeBlocked,
Component* modal)
239 return modal !=
nullptr
240 && modal != &maybeBlocked
245 template <
typename Function>
246 static void sendMouseEventToComponentsThatAreBlockedByModal (
Component& modal, Function&& function)
249 if (
auto* c = ms.getComponentUnderMouse())
250 if (modalWouldBlockComponent (*c, &modal))
257 static auto& getInstance()
265 return listeners.addListener (std::move (l));
268 void modalComponentManagerChanged()