ui::DoubleAnimation¶
Header: winui/ui/Animation.hpp.
A from/to/by animation of one property. A missing from starts from the property's current animated value. to wins over by, and with neither the animation goes back to the property's own value. duration is one iteration, a second by default. repeat_count is the number of iterations, infinity repeats forever, and an auto-reversing iteration lasts two durations. On a three-component property (Translation, Scale, CenterPoint), every component runs the same values.
Example:
auto stack = std::make_unique<ui::StackControl>(ui::Orientation::Vertical);
ui::RectangleControl* rect = stack->add(std::make_unique<ui::RectangleControl>());
rect->start_animation(ui::AnimatedProperty::TranslationX,
ui::DoubleAnimation{.to = 200.0f,
.duration = 500ms,
.easing = ui::CircleEase{ui::EasingMode::EaseInOut},
.on_completed = [] { /* now at x + 200 */ }});
// A pulsing fade that gives the property back when done.
rect->start_animation(ui::AnimatedProperty::Opacity,
ui::DoubleAnimation{.from = 1.0f,
.to = 0.2f,
.duration = 300ms,
.auto_reverse = true,
.repeat_count = 3.0,
.fill = ui::FillBehavior::Stop});
| Field | Type | Default | |
|---|---|---|---|
from |
OptionalFloat |
Start value. Unset starts from the property's current animated value. | |
to |
OptionalFloat |
End value; wins over by. |
|
by |
OptionalFloat |
End value relative to the start, used when to is unset. |
|
duration |
Duration |
{1000.0} |
Length of one iteration. |
easing |
std::optional<EasingFunction> |
Curve over each iteration. Unset is linear. | |
begin_time |
Duration |
Delay before the first iteration. | |
auto_reverse |
bool |
false |
Plays each iteration forward then backward, doubling its length. |
repeat_count |
double |
1.0 |
Iterations to run; std::numeric_limits<double>::infinity() repeats forever. |
fill |
FillBehavior |
FillBehavior::HoldEnd |
What the property shows once the animation finishes. |
on_completed |
Callback<void()> |
Fires once when the animation finishes (not when it is replaced or stopped). |