33 : target (c), props (p)
38 if (target->isOnDesktop())
45 else if (
auto* parent = target->getParentComponent())
47 auto targetIndex = parent->getIndexOfChildComponent (target);
54 if (target !=
nullptr)
65 return target !=
nullptr ? target->getDesktopScaleFactor()
78 : properties (
std::move (props))
85 owner->removeComponentListener (
this);
87 if (lastParentComp !=
nullptr)
88 lastParentComp->removeComponentListener (
this);
96 owner->removeComponentListener (
this);
100 if (owner !=
nullptr)
101 owner->addComponentListener (
this);
104 updateOutlineWindow();
108void FocusOutline::componentMovedOrResized (
Component& c,
bool,
bool)
111 updateOutlineWindow();
114void FocusOutline::componentBroughtToFront (Component& c)
117 updateOutlineWindow();
120void FocusOutline::componentParentHierarchyChanged (Component& c)
125 updateOutlineWindow();
129void FocusOutline::componentVisibilityChanged (Component& c)
132 updateOutlineWindow();
135void FocusOutline::updateParent()
137 lastParentComp = (owner !=
nullptr ? owner->getParentComponent()
141void FocusOutline::updateOutlineWindow()
148 if (owner ==
nullptr)
150 outlineWindow =
nullptr;
154 if (owner->isShowing()
155 && owner->getWidth() > 0 && owner->getHeight() > 0)
157 if (outlineWindow ==
nullptr)
158 outlineWindow = std::make_unique<OutlineWindowComponent> (owner, *properties);
162 outlineWindow->setAlwaysOnTop (owner->isAlwaysOnTop());
169 const auto bounds = properties->getOutlineBounds (*owner);
171 if (lastParentComp !=
nullptr)
172 return lastParentComp->getLocalArea (
nullptr, bounds);
181 outlineWindow =
nullptr;
@ windowIsTemporary
Indicates that the window is a temporary popup, like a menu, tooltip, etc.
@ windowIgnoresKeyPresses
Tells the window not to catch any keypresses.
@ windowIgnoresMouseClicks
Indicates that the window should let mouse clicks pass through it (may not be possible on some platfo...
The base class for all JUCE user-interface objects.
void setInterceptsMouseClicks(bool allowClicksOnThisComponent, bool allowClicksOnChildComponents) noexcept
Changes the default return value for the hitTest() method.
int getHeight() const noexcept
Returns the component's height in pixels.
void repaint()
Marks the whole component as needing to be redrawn.
virtual void addToDesktop(int windowStyleFlags, void *nativeWindowToAttachTo=nullptr)
Makes this component appear as a window on the desktop.
void setSize(int newWidth, int newHeight)
Changes the size of the component.
int getWidth() const noexcept
Returns the component's width in pixels.
virtual void setVisible(bool shouldBeVisible)
Makes the component visible or invisible.
virtual float getDesktopScaleFactor() const
Returns the default scale factor to use for this component when it is placed on the desktop.
void setOwner(Component *componentToFollow)
Attaches the outline to a component.
FocusOutline(std::unique_ptr< OutlineWindowProperties > props)
Creates a FocusOutline.
~FocusOutline() override
Destructor.
A graphics context, used for drawing a component or image.
This class acts as a pointer which will automatically become null if the object to which it points is...
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
Defines the focus outline window properties.
virtual void drawOutline(Graphics &, int width, int height)=0
This method will be called to draw the focus outline.
float getDesktopScaleFactor() const override
Returns the default scale factor to use for this component when it is placed on the desktop.
void resized() override
Called when this component's size has been changed.
void paint(Graphics &g) override
Components can override this method to draw their content.