mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Component: Improve opaque component checks
- Improve default performance when components check if they are opaque - Allows all components to take advantage of setPaintingIsUnclipped - Give more control to opt out of opaque checks separate from setPaintingIsUnclipped
This commit is contained in:
parent
79dfa1d392
commit
961ff32b9e
3 changed files with 204 additions and 92 deletions
|
|
@ -191,42 +191,6 @@ struct ComponentHelpers
|
|||
return convertFromDistantParentSpace (topLevelComp, *target, p);
|
||||
}
|
||||
|
||||
static bool clipChildComponent (const Component& child,
|
||||
Graphics& g,
|
||||
const Rectangle<int> clipRect,
|
||||
Point<int> delta)
|
||||
{
|
||||
if (! child.isVisible() || child.isTransformed())
|
||||
return false;
|
||||
|
||||
const auto newClip = clipRect.getIntersection (child.boundsRelativeToParent);
|
||||
|
||||
if (newClip.isEmpty())
|
||||
return false;
|
||||
|
||||
if (child.isOpaque() && child.componentTransparency == 0)
|
||||
{
|
||||
g.excludeClipRegion (newClip + delta);
|
||||
return true;
|
||||
}
|
||||
|
||||
const auto childPos = child.getPosition();
|
||||
return clipObscuredRegions (child, g, newClip - childPos, childPos + delta);
|
||||
}
|
||||
|
||||
static bool clipObscuredRegions (const Component& comp,
|
||||
Graphics& g,
|
||||
const Rectangle<int> clipRect,
|
||||
Point<int> delta)
|
||||
{
|
||||
auto wasClipped = false;
|
||||
|
||||
for (int i = comp.childComponentList.size(); --i >= 0;)
|
||||
wasClipped |= clipChildComponent (*comp.childComponentList.getUnchecked (i), g, clipRect, delta);
|
||||
|
||||
return wasClipped;
|
||||
}
|
||||
|
||||
static Rectangle<int> getParentOrMainMonitorBounds (const Component& comp)
|
||||
{
|
||||
if (auto* p = comp.getParentComponent())
|
||||
|
|
@ -261,6 +225,14 @@ struct ComponentHelpers
|
|||
function (c, ms, SH::screenPosToLocalPos (*c, ms.getScreenPosition()), Time::getCurrentTime());
|
||||
}
|
||||
|
||||
static bool isVisible (const Component& component, bool allowTransparency = true)
|
||||
{
|
||||
return component.isVisible()
|
||||
&& component.getWidth() > 0
|
||||
&& component.getHeight() > 0
|
||||
&& component.componentTransparency < (allowTransparency ? 255 : 1);
|
||||
}
|
||||
|
||||
class ModalComponentManagerChangeNotifier
|
||||
{
|
||||
public:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue