mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-09 23:34:20 +00:00
Merge d7416fab70 into 29396c22c9
This commit is contained in:
commit
b818cf0199
2 changed files with 62 additions and 2 deletions
|
|
@ -47,11 +47,12 @@ public:
|
||||||
|
|
||||||
void reset (const Rectangle<int>& finalBounds,
|
void reset (const Rectangle<int>& finalBounds,
|
||||||
float finalAlpha,
|
float finalAlpha,
|
||||||
|
int millisecondsBeforeStartMoving,
|
||||||
int millisecondsToSpendMoving,
|
int millisecondsToSpendMoving,
|
||||||
bool useProxyComponent,
|
bool useProxyComponent,
|
||||||
double startSpd, double endSpd)
|
double startSpd, double endSpd)
|
||||||
{
|
{
|
||||||
msElapsed = 0;
|
msElapsed = -jmax (0, millisecondsBeforeStartMoving);
|
||||||
msTotal = jmax (1, millisecondsToSpendMoving);
|
msTotal = jmax (1, millisecondsToSpendMoving);
|
||||||
lastProgress = 0;
|
lastProgress = 0;
|
||||||
destination = finalBounds;
|
destination = finalBounds;
|
||||||
|
|
@ -85,6 +86,8 @@ public:
|
||||||
: component.get())
|
: component.get())
|
||||||
{
|
{
|
||||||
msElapsed += elapsed;
|
msElapsed += elapsed;
|
||||||
|
if (msElapsed < 0)
|
||||||
|
return true;
|
||||||
double newProgress = msElapsed / (double) msTotal;
|
double newProgress = msElapsed / (double) msTotal;
|
||||||
|
|
||||||
if (newProgress >= 0 && newProgress < 1.0)
|
if (newProgress >= 0 && newProgress < 1.0)
|
||||||
|
|
@ -243,6 +246,18 @@ void ComponentAnimator::animateComponent (Component* const component,
|
||||||
const bool useProxyComponent,
|
const bool useProxyComponent,
|
||||||
const double startSpeed,
|
const double startSpeed,
|
||||||
const double endSpeed)
|
const double endSpeed)
|
||||||
|
{
|
||||||
|
animateComponent(component, finalBounds, finalAlpha, 0, millisecondsToSpendMoving, useProxyComponent, startSpeed, endSpeed);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ComponentAnimator::animateComponent (Component* const component,
|
||||||
|
const Rectangle<int>& finalBounds,
|
||||||
|
const float finalAlpha,
|
||||||
|
const int millisecondsBeforeStartMoving,
|
||||||
|
const int millisecondsToSpendMoving,
|
||||||
|
const bool useProxyComponent,
|
||||||
|
const double startSpeed,
|
||||||
|
const double endSpeed)
|
||||||
{
|
{
|
||||||
// the speeds must be 0 or greater!
|
// the speeds must be 0 or greater!
|
||||||
jassert (startSpeed >= 0 && endSpeed >= 0);
|
jassert (startSpeed >= 0 && endSpeed >= 0);
|
||||||
|
|
@ -258,7 +273,8 @@ void ComponentAnimator::animateComponent (Component* const component,
|
||||||
sendChangeMessage();
|
sendChangeMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
at->reset (finalBounds, finalAlpha, millisecondsToSpendMoving,
|
at->reset (finalBounds, finalAlpha,
|
||||||
|
millisecondsBeforeStartMoving, millisecondsToSpendMoving,
|
||||||
useProxyComponent, startSpeed, endSpeed);
|
useProxyComponent, startSpeed, endSpeed);
|
||||||
|
|
||||||
if (! isTimerRunning())
|
if (! isTimerRunning())
|
||||||
|
|
|
||||||
|
|
@ -113,6 +113,50 @@ public:
|
||||||
bool useProxyComponent,
|
bool useProxyComponent,
|
||||||
double startSpeed,
|
double startSpeed,
|
||||||
double endSpeed);
|
double endSpeed);
|
||||||
|
|
||||||
|
//==============================================================================
|
||||||
|
/** Starts a component moving from its current position to a specified position.
|
||||||
|
|
||||||
|
If the component is already in the middle of an animation, that will be abandoned,
|
||||||
|
and a new animation will begin, moving the component from its current location.
|
||||||
|
|
||||||
|
The start and end speed parameters let you apply some acceleration to the component's
|
||||||
|
movement.
|
||||||
|
|
||||||
|
@param component the component to move
|
||||||
|
@param finalBounds the destination bounds to which the component should move. To leave the
|
||||||
|
component in the same place, just pass component->getBounds() for this value
|
||||||
|
@param finalAlpha the alpha value that the component should have at the end of the animation
|
||||||
|
@param delayBeforeAnimationMilliseconds how long the animation should wait before start, in milliseconds
|
||||||
|
@param animationDurationMilliseconds how long the animation should last, in milliseconds
|
||||||
|
@param useProxyComponent if true, this means the component should be replaced by an internally
|
||||||
|
managed temporary component which is a snapshot of the original component.
|
||||||
|
This avoids the component having to paint itself as it moves, so may
|
||||||
|
be more efficient. This option also allows you to delete the original
|
||||||
|
component immediately after starting the animation, because the animation
|
||||||
|
can proceed without it. If you use a proxy, the original component will be
|
||||||
|
made invisible by this call, and then will become visible again at the end
|
||||||
|
of the animation. It'll also mean that the proxy component will be temporarily
|
||||||
|
added to the component's parent, so avoid it if this might confuse the parent
|
||||||
|
component, or if there's a chance the parent might decide to delete its children.
|
||||||
|
@param startSpeed a value to indicate the relative start speed of the animation. If this is 0,
|
||||||
|
the component will start by accelerating from rest; higher values mean that it
|
||||||
|
will have an initial speed greater than zero. If the value is greater than 1, it
|
||||||
|
will decelerate towards the middle of its journey. To move the component at a
|
||||||
|
constant rate for its entire animation, set both the start and end speeds to 1.0
|
||||||
|
@param endSpeed a relative speed at which the component should be moving when the animation finishes.
|
||||||
|
If this is 0, the component will decelerate to a standstill at its final position;
|
||||||
|
higher values mean the component will still be moving when it stops. To move the component
|
||||||
|
at a constant rate for its entire animation, set both the start and end speeds to 1.0
|
||||||
|
*/
|
||||||
|
void animateComponent (Component* component,
|
||||||
|
const Rectangle<int>& finalBounds,
|
||||||
|
float finalAlpha,
|
||||||
|
int delayBeforeAnimationMilliseconds,
|
||||||
|
int animationDurationMilliseconds,
|
||||||
|
bool useProxyComponent,
|
||||||
|
double startSpeed,
|
||||||
|
double endSpeed);
|
||||||
|
|
||||||
/** Begins a fade-out of this components alpha level.
|
/** Begins a fade-out of this components alpha level.
|
||||||
This is a quick way of invoking animateComponent() with a target alpha value of 0.0f, using
|
This is a quick way of invoking animateComponent() with a target alpha value of 0.0f, using
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue