Adw.SpringAnimation¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
- Inherited:
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w/en |
|||
r/w/en |
|||
r |
|||
r/w/en |
|||
r/w/c/en |
|||
r/w/c/en |
|||
r/w/c/en |
|||
r |
Signals¶
- Inherited:
Fields¶
- Inherited:
Class Details¶
- class Adw.SpringAnimation(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
A spring-based [class`Animation`].
AdwSpringAnimation
implements an animation driven by a physical model of a spring described by [struct`SpringParams`], with a resting position in [property`SpringAnimation`:py:data::value-to<Adw.SpringAnimation.props.value_to>], stretched to [property`SpringAnimation`:py:data::value-from<Adw.SpringAnimation.props.value_from>].Since the animation is physically simulated, spring animations don’t have a fixed duration. The animation will stop when the simulated spring comes to a rest - when the amplitude of the oscillations becomes smaller than [property`SpringAnimation`:py:data::epsilon<Adw.SpringAnimation.props.epsilon>], or immediately when it reaches [property`SpringAnimation`:py:data::value-to<Adw.SpringAnimation.props.value_to>] if [property`SpringAnimation`:py:data::clamp<Adw.SpringAnimation.props.clamp>] is set to
TRUE
. The estimated duration can be obtained with [property`SpringAnimation`:py:data::estimated-duration<Adw.SpringAnimation.props.estimated_duration>].Due to the nature of spring-driven motion the animation can overshoot [property`SpringAnimation`:py:data::value-to<Adw.SpringAnimation.props.value_to>] before coming to a rest. Whether the animation will overshoot or not depends on the damping ratio of the spring. See [struct`SpringParams`] for more information about specific damping ratio values.
If [property`SpringAnimation`:py:data::clamp<Adw.SpringAnimation.props.clamp>] is
TRUE
, the animation will abruptly end as soon as it reaches the final value, preventing overshooting.Animations can have an initial velocity value, set via [property`SpringAnimation`:py:data::initial-velocity<Adw.SpringAnimation.props.initial_velocity>], which adjusts the curve without changing the duration. This makes spring animations useful for deceleration at the end of gestures.
If the initial and final values are equal, and the initial velocity is not 0, the animation value will bounce and return to its resting position.
- classmethod new(widget, from_, to, spring_params, target)¶
- Parameters:
widget (
Gtk.Widget
) – a widget to create animation onfrom (
float
) – a value to animate fromto (
float
) – a value to animate tospring_params (
Adw.SpringParams
) – physical parameters of the springtarget (
Adw.AnimationTarget
) – a target value to animate
- Returns:
the newly created animation
- Return type:
Creates a new
AdwSpringAnimation
on widget.The animation will animate target from from to to with the dynamics of a spring described by spring_params.
- calculate_value(time)¶
- Parameters:
time (
int
) – elapsed time, in milliseconds- Returns:
the value at time
- Return type:
Calculates the value self will have at time.
The time starts at 0 and ends at [property`SpringAnimation`:estimated_duration].
See also [method`SpringAnimation`.calculate_velocity].
New in version 1.3.
- calculate_velocity(time)¶
- Parameters:
time (
int
) – elapsed time, in milliseconds- Returns:
the velocity at time
- Return type:
Calculates the velocity self will have at time.
The time starts at 0 and ends at [property`SpringAnimation`:estimated_duration].
See also [method`SpringAnimation`.calculate_value].
New in version 1.3.
- get_clamp()¶
- Returns:
whether self is clamped
- Return type:
Gets whether self should be clamped.
- get_estimated_duration()¶
- Returns:
the estimated duration
- Return type:
Gets the estimated duration of self, in milliseconds.
Can be [constDURATION_INFINITE] if the spring damping is set to 0.
- get_initial_velocity()¶
- Returns:
the initial velocity
- Return type:
Gets the initial velocity of self.
- get_spring_params()¶
- Returns:
the spring parameters
- Return type:
Gets the physical parameters of the spring of self.
- get_value_from()¶
- Returns:
the value to animate from
- Return type:
Gets the value self will animate from.
- get_value_to()¶
- Returns:
the value to animate to
- Return type:
Gets the value self will animate to.
- set_clamp(clamp)¶
- Parameters:
clamp (
bool
) – the new value
Sets whether self should be clamped.
If set to
TRUE
, the animation will abruptly end as soon as it reaches the final value, preventing overshooting.It won’t prevent overshooting [property`SpringAnimation`:py:data::value-from<Adw.SpringAnimation.props.value_from>] if a relative negative [property`SpringAnimation`:py:data::initial-velocity<Adw.SpringAnimation.props.initial_velocity>] is set.
- set_epsilon(epsilon)¶
- Parameters:
epsilon (
float
) – the new value
Sets the precision of the spring.
The level of precision used to determine when the animation has come to a rest, that is, when the amplitude of the oscillations becomes smaller than this value.
If the epsilon value is too small, the animation will take a long time to stop after the animated value has stopped visibly changing.
If the epsilon value is too large, the animation will end prematurely.
The default value is 0.001.
- set_initial_velocity(velocity)¶
- Parameters:
velocity (
float
) – the initial velocity
Sets the initial velocity of self.
Initial velocity affects only the animation curve, but not its duration.
- set_spring_params(spring_params)¶
- Parameters:
spring_params (
Adw.SpringParams
) – the new spring parameters
Sets the physical parameters of the spring of self.
Property Details¶
- Adw.SpringAnimation.props.clamp¶
- Name:
clamp
- Type:
- Default Value:
- Flags:
Whether the animation should be clamped.
If set to
TRUE
, the animation will abruptly end as soon as it reaches the final value, preventing overshooting.It won’t prevent overshooting [property`SpringAnimation`:py:data::value-from<Adw.SpringAnimation.props.value_from>] if a relative negative [property`SpringAnimation`:py:data::initial-velocity<Adw.SpringAnimation.props.initial_velocity>] is set.
- Adw.SpringAnimation.props.epsilon¶
- Name:
epsilon
- Type:
- Default Value:
0.001
- Flags:
Precision of the spring.
The level of precision used to determine when the animation has come to a rest, that is, when the amplitude of the oscillations becomes smaller than this value.
If the epsilon value is too small, the animation will take a long time to stop after the animated value has stopped visibly changing.
If the epsilon value is too large, the animation will end prematurely.
The default value is 0.001.
- Adw.SpringAnimation.props.estimated_duration¶
-
Estimated duration of the animation, in milliseconds.
Can be [constDURATION_INFINITE] if the spring damping is set to 0.
- Adw.SpringAnimation.props.initial_velocity¶
- Name:
initial-velocity
- Type:
- Default Value:
0.0
- Flags:
The initial velocity to start the animation with.
Initial velocity affects only the animation curve, but not its duration.
- Adw.SpringAnimation.props.spring_params¶
- Name:
spring-params
- Type:
- Default Value:
- Flags:
Physical parameters describing the spring.
- Adw.SpringAnimation.props.value_from¶
- Name:
value-from
- Type:
- Default Value:
0.0
- Flags:
The value to animate from.
The animation will start at this value and end at [property`SpringAnimation`:py:data::value-to<Adw.SpringAnimation.props.value_to>].
- Adw.SpringAnimation.props.value_to¶
- Name:
value-to
- Type:
- Default Value:
0.0
- Flags:
The value to animate to.
The animation will start at [property`SpringAnimation`:py:data::value-from<Adw.SpringAnimation.props.value_from>] and end at this value.