36 proxy.deleteAndZero();
54 left = component->getX();
55 top = component->getY();
56 right = component->getRight();
57 bottom = component->getBottom();
58 alpha = component->getAlpha();
65 proxy.deleteAndZero();
73 bool useTimeslice (
const int elapsed)
75 if (
auto* c = proxy !=
nullptr ? proxy.getComponent()
85 const double delta = (
newProgress - lastProgress) / (1.0 - lastProgress);
95 left += (destination.
getX() - left) * delta;
96 top += (destination.
getY() - top) * delta;
97 right += (destination.
getRight() - right) * delta;
98 bottom += (destination.
getBottom() - bottom) * delta;
119 alpha += (destAlpha - alpha) * delta;
130 moveToFinalDestination();
134 void moveToFinalDestination()
136 if (component !=
nullptr)
139 component->setAlpha ((
float) destAlpha);
140 component->setBounds (destination);
143 if (proxy !=
nullptr)
144 component->setVisible (destAlpha > 0);
160 parent->addAndMakeVisible (
this);
199 int msElapsed, msTotal;
200 double startSpeed, midSpeed, endSpeed, lastProgress;
201 double left, top, right, bottom, alpha;
202 bool isMoving, isChangingAlpha;
205 double timeToDistance (
const double time)
const noexcept
207 return (time < 0.5) ?
time * (startSpeed +
time * (midSpeed - startSpeed))
208 : 0.5 * (startSpeed + 0.5 * (midSpeed - startSpeed))
209 + (
time - 0.5) * (midSpeed + (
time - 0.5) * (endSpeed - midSpeed));
223 for (
int i = tasks.size(); --i >= 0;)
224 if (component == tasks.getUnchecked (i)->component.get())
225 return tasks.getUnchecked (i);
235 const double startSpeed,
236 const double endSpeed)
239 jassert (startSpeed >= 0 && endSpeed >= 0);
241 if (component !=
nullptr)
243 auto* at = findTaskFor (component);
265 if (component !=
nullptr)
286 if (tasks.size() > 0)
289 for (
int i = tasks.size(); --i >= 0;)
290 tasks.getUnchecked (i)->moveToFinalDestination();
300 if (
auto* at = findTaskFor (component))
303 at->moveToFinalDestination();
305 tasks.removeObject (at);
312 jassert (component !=
nullptr);
314 if (
auto* at = findTaskFor (component))
315 return at->destination;
322 return findTaskFor (component) !=
nullptr;
327 return tasks.size() != 0;
330void ComponentAnimator::timerCallback()
339 for (
auto* task :
Array<AnimationTask*> (tasks.
begin(), tasks.size()))
341 if (tasks.contains (task) && ! task->useTimeslice (
elapsed))
343 tasks.removeObject (task);
350 if (tasks.size() == 0)
Holds a resizable array of primitive or copy-by-value objects.
void sendChangeMessage()
Causes an asynchronous change message to be sent to all the registered listeners.
void animateComponent(Component *component, const Rectangle< int > &finalBounds, float finalAlpha, int animationDurationMilliseconds, bool useProxyComponent, double startSpeed, double endSpeed)
Starts a component moving from its current position to a specified position.
void cancelAllAnimations(bool moveComponentsToTheirFinalPositions)
Clears all of the active animations.
Rectangle< int > getComponentDestination(Component *component)
Returns the destination position for a component.
void fadeOut(Component *component, int millisecondsToTake)
Begins a fade-out of this components alpha level.
bool isAnimating() const noexcept
Returns true if any components are currently being animated.
~ComponentAnimator() override
Destructor.
void cancelAnimation(Component *component, bool moveComponentToItsFinalPosition)
Stops a component if it's currently being animated.
void fadeIn(Component *component, int millisecondsToTake)
Begins a fade-in of a component.
ComponentAnimator()
Creates a ComponentAnimator.
int getStyleFlags() const noexcept
Returns the set of style flags that were set when the window was created.
@ windowIgnoresKeyPresses
Tells the window not to catch any keypresses.
Holds a pointer to some type of Component, which automatically becomes null if the component is delet...
The base class for all JUCE user-interface objects.
AffineTransform getTransform() const
Returns the transform that is currently being applied to this component.
void setTransform(const AffineTransform &transform)
Sets a transform matrix to be applied to this component.
void toBehind(Component *other)
Changes this component's z-order so that it's just behind another component.
void setInterceptsMouseClicks(bool allowClicksOnThisComponent, bool allowClicksOnChildComponents) noexcept
Changes the default return value for the hitTest() method.
bool isVisible() const noexcept
Tests whether the component is visible or not.
Component * getParentComponent() const noexcept
Returns the component which this component is inside.
Image createComponentSnapshot(Rectangle< int > areaToGrab, bool clipImageToComponentBounds=true, float scaleFactor=1.0f)
Generates a snapshot of part of this component.
int getHeight() const noexcept
Returns the component's height in pixels.
bool isShowing() const
Tests whether this component and all its parents are visible.
static float JUCE_CALLTYPE getApproximateScaleFactorForComponent(const Component *targetComponent)
Returns the approximate scale factor for a given component by traversing its parent hierarchy and app...
void setAlpha(float newAlpha)
Changes the transparency of this component.
float getAlpha() const noexcept
Returns the component's current transparency level.
Rectangle< int > getBounds() const noexcept
Returns this component's bounding box.
Rectangle< int > getScreenBounds() const
Returns the bounds of this component, relative to the screen's top-left.
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 setBounds(int x, int y, int width, int height)
Changes the component's position and size.
void setWantsKeyboardFocus(bool wantsFocus) noexcept
Sets a flag to indicate whether this component wants keyboard focus or not.
int getWidth() const noexcept
Returns the component's width in pixels.
ComponentPeer * getPeer() const
Returns the heavyweight window that contains this component.
Rectangle< int > getLocalBounds() const noexcept
Returns the component's bounds, relative to its own origin.
virtual void setVisible(bool shouldBeVisible)
Makes the component visible or invisible.
const Displays & getDisplays() const noexcept
Returns the Displays object representing the connected displays.
static Desktop &JUCE_CALLTYPE getInstance()
There's only one desktop object, and this method will return it.
const Display * getDisplayForRect(Rectangle< int > rect, bool isPhysical=false) const noexcept
Returns the Display object representing the display containing a given Rectangle (either in logical o...
A graphics context, used for drawing a component or image.
void setOpacity(float newOpacity)
Changes the opacity to use with the current colour.
void drawImageTransformed(const Image &imageToDraw, const AffineTransform &transform, bool fillAlphaChannelWithCurrentBrush=false) const
Draws an image, having applied an affine transform to it.
Holds a fixed-size bitmap.
int getWidth() const noexcept
Returns the image's width (in pixels).
int getHeight() const noexcept
Returns the image's height (in pixels).
Manages a rectangle and allows geometric operations to be performed on it.
ValueType getRight() const noexcept
Returns the x coordinate of the rectangle's right-hand-side.
ValueType getX() const noexcept
Returns the x coordinate of the rectangle's left-hand-side.
ValueType getBottom() const noexcept
Returns the y coordinate of the rectangle's bottom edge.
ValueType getY() const noexcept
Returns the y coordinate of the rectangle's top edge.
static uint32 getMillisecondCounter() noexcept
Returns the number of millisecs since a fixed event (usually system startup).
void stopTimer() noexcept
Stops the timer.
void startTimerHz(int timerFrequencyHz) noexcept
Starts the timer with an interval specified in Hertz.
bool isTimerRunning() const noexcept
Returns true if the timer is currently running.
This class acts as a pointer which will automatically become null if the object to which it points is...
bool wasObjectDeleted() const noexcept
This returns true if this reference has been pointing at an object, but that object has since been de...
#define JUCE_DECLARE_WEAK_REFERENCEABLE(Class)
Macro to easily allow a class to be made weak-referenceable.
constexpr bool approximatelyEqual(Type a, Type b, Tolerance< Type > tolerance=Tolerance< Type >{} .withAbsolute(std::numeric_limits< Type >::min()) .withRelative(std::numeric_limits< Type >::epsilon()))
Returns true if the two floating-point numbers are approximately equal.
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...
int roundToInt(const FloatType value) noexcept
Fast floating-point-to-integer conversion.
RangedDirectoryIterator begin(const RangedDirectoryIterator &it)
Returns the iterator that was passed in.
void paint(Graphics &g) override
Components can override this method to draw their content.