33 : target (comp), shadow (
ds)
46 return std::make_unique<ScopedThreadDPIAwarenessSetter> (handle);
59 parent->addChildComponent (
this);
76 if (target !=
nullptr)
77 return target->getDesktopScaleFactor();
96 component->addComponentListener (
this);
104 if (
auto* c = component.get())
108 bool shouldHideDropShadow()
const
110 return hasReasonToHide;
115 listeners[listener] = std::move (
cb);
118 void removeListener (
void* listener)
120 listeners.
erase (listener);
126 if (component.get() == &c)
136 if (! component.wasObjectDeleted() && isWindows && component->isOnDesktop())
144 newHasReasonToHide = ! detail::WindowingHelpers::isWindowOnCurrentVirtualDesktop (component->getWindowHandle());
155 for (
auto&
l : listeners)
159 void timerCallback()
override
167 bool hasReasonToHide =
false;
177 : root (&r), listener (&
l)
179 updateParentHierarchy();
184 for (
auto&
compEntry : observedComponents)
186 comp->removeComponentListener (
this);
191 if (root != &component)
192 listener->componentVisibilityChanged (*root);
197 if (root == &component)
198 updateParentHierarchy();
202 class ComponentWithWeakReference
205 explicit ComponentWithWeakReference (
Component& c)
206 : ptr (&c), ref (&c) {}
208 Component* get()
const {
return ref.get(); }
210 bool operator< (
const ComponentWithWeakReference&
other)
const {
return ptr <
other.ptr; }
217 void updateParentHierarchy()
223 for (
auto node = root; node !=
nullptr; node = node->getParentComponent())
234 for (
const auto& item : result)
243 Component* root =
nullptr;
244 ComponentListener* listener =
nullptr;
256 if (virtualDesktopWatcher !=
nullptr)
257 virtualDesktopWatcher->removeListener (
this);
259 if (owner !=
nullptr)
261 owner->removeComponentListener (
this);
268 shadowWindows.clear();
275 if (owner !=
nullptr)
276 owner->removeComponentListener (
this);
285 owner->addComponentListener (
this);
289 visibilityChangedListener = std::make_unique<ParentVisibilityChangedListener> (*owner,
292 virtualDesktopWatcher = std::make_unique<VirtualDesktopWatcher> (*owner);
293 virtualDesktopWatcher->addListener (
this, [
this]() { updateShadows(); });
299void DropShadower::updateParent()
302 p->removeComponentListener (
this);
304 lastParentComp = owner !=
nullptr ? owner->getParentComponent() :
nullptr;
307 p->addComponentListener (
this);
310void DropShadower::componentMovedOrResized (Component& c,
bool ,
bool )
316void DropShadower::componentBroughtToFront (Component& c)
322void DropShadower::componentChildrenChanged (Component&)
327void DropShadower::componentParentHierarchyChanged (Component& c)
336void DropShadower::componentVisibilityChanged (Component& c)
342void DropShadower::updateShadows()
350 && owner->isShowing()
351 && owner->getWidth() > 0 && owner->getHeight() > 0
353 && (virtualDesktopWatcher ==
nullptr || ! virtualDesktopWatcher->shouldHideDropShadow()))
355 while (shadowWindows.size() < 4)
356 shadowWindows.add (
new ShadowWindow (owner, shadow));
359 const int x = owner->getX();
361 const int w = owner->getWidth();
364 for (
int i = 4; --i >= 0;)
372 sw->setAlwaysOnTop (owner->isAlwaysOnTop());
382 case 3:
sw->setBounds (x, owner->getBottom(), w,
shadowEdge);
break;
389 sw->toBehind (i == 3 ? owner.get() : shadowWindows.getUnchecked (i + 1));
395 shadowWindows.clear();
T back_inserter(T... args)
Gets informed about changes to a component's hierarchy or position.
@ 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 removeComponentListener(ComponentListener *listenerToRemove)
Removes a component listener.
void setAccessible(bool shouldBeAccessible)
Sets whether this component and its children are visible to accessibility clients.
void setInterceptsMouseClicks(bool allowClicksOnThisComponent, bool allowClicksOnChildComponents) noexcept
Changes the default return value for the hitTest() method.
Component * getParentComponent() const noexcept
Returns the component which this component is inside.
void * getWindowHandle() const
Returns the underlying native window handle for this component.
Rectangle< int > getLocalArea(const Component *sourceComponent, Rectangle< int > areaRelativeToSourceComponent) const
Converts a rectangle to be relative to this component's coordinate space.
void repaint()
Marks the whole component as needing to be redrawn.
bool isOnDesktop() const noexcept
Returns true if this component is currently showing on the desktop.
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.
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.
static bool canUseSemiTransparentWindows() noexcept
True if the OS supports semitransparent windows.
void componentVisibilityChanged(Component &component) override
Called when the component is made visible or invisible.
void componentParentHierarchyChanged(Component &component) override
Called to indicate that the component's parents have changed.
float getDesktopScaleFactor() const override
Returns the default scale factor to use for this component when it is placed on the desktop.
void paint(Graphics &g) override
Components can override this method to draw their content.
void resized() override
Called when this component's size has been changed.
void componentParentHierarchyChanged(Component &c) override
Called to indicate that the component's parents have changed.
DropShadower(const DropShadow &shadowType)
Creates a DropShadower.
~DropShadower() override
Destructor.
void setOwner(Component *componentToFollow)
Attaches the DropShadower to the component you want to shadow.
A graphics context, used for drawing a component or image.
ValueType y
The point's Y coordinate.
ValueType x
The point's X coordinate.
Helper class providing an RAII-based mechanism for temporarily setting and then re-setting a value.
@ Windows
To test whether any version of Windows is running, you can use the expression ((getOperatingSystemTyp...
static OperatingSystemType getOperatingSystemType()
Returns the type of operating system we're running on.
Makes repeated callbacks to a virtual method at a specified time interval.
void stopTimer() noexcept
Stops the timer.
void startTimerHz(int timerFrequencyHz) noexcept
Starts the timer with an interval specified in Hertz.
This class acts as a pointer which will automatically become null if the object to which it points is...
auto & get(ProcessorChain< Processors... > &chain) noexcept
Non-member equivalent of ProcessorChain::get which avoids awkward member template syntax.
#define JUCE_DECLARE_WEAK_REFERENCEABLE(Class)
Macro to easily allow a class to be made weak-referenceable.
constexpr Type jmax(Type a, Type b)
Returns the larger of two values.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
T set_difference(T... args)
Defines a drop-shadow effect.
Point< int > offset
The offset of the shadow.
int radius
The approximate spread of the shadow.
void drawForRectangle(Graphics &g, const Rectangle< int > &area) const
Renders a drop-shadow for a rectangle.