Package ch.bailu.gtk.adw
Class SpringAnimation
java.lang.Object
ch.bailu.gtk.type.Type
ch.bailu.gtk.type.Pointer
ch.bailu.gtk.gobject.Object
ch.bailu.gtk.adw.Animation
ch.bailu.gtk.adw.SpringAnimation
- All Implemented Interfaces:
PointerInterface
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:value-to], stretched to
[property@SpringAnimation: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:epsilon], or immediately when it reaches
[property@SpringAnimation:value-to] if
[property@SpringAnimation:clamp] is set to `TRUE`. The estimated duration can
be obtained with [property@SpringAnimation:estimated-duration].
Due to the nature of spring-driven motion the animation can overshoot
[property@SpringAnimation: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: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: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.
`AdwSpringAnimation` implements an animation driven by a physical model of a
spring described by [struct@SpringParams], with a resting position in
[property@SpringAnimation:value-to], stretched to
[property@SpringAnimation: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:epsilon], or immediately when it reaches
[property@SpringAnimation:value-to] if
[property@SpringAnimation:clamp] is set to `TRUE`. The estimated duration can
be obtained with [property@SpringAnimation:estimated-duration].
Due to the nature of spring-driven motion the animation can overshoot
[property@SpringAnimation: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: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: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.
https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.SpringAnimation.html
-
Nested Class Summary
Nested classes/interfaces inherited from class ch.bailu.gtk.adw.Animation
Animation.OnDone
Nested classes/interfaces inherited from class ch.bailu.gtk.gobject.Object
Object.OnBindingTransformFunc, Object.OnDestroyNotify, Object.OnDuplicateFunc, Object.OnNotify, Object.OnToggleNotify, Object.OnWeakNotify
-
Field Summary
Fields inherited from class ch.bailu.gtk.adw.Animation
SIGNAL_ON_DONE
Fields inherited from class ch.bailu.gtk.gobject.Object
SIGNAL_ON_NOTIFY
-
Constructor Summary
ConstructorDescriptionSpringAnimation
(Widget widget, double from, double to, SpringParams spring_params, AnimationTarget target) Creates a new `AdwSpringAnimation` on @widget.SpringAnimation
(PointerContainer pointer) -
Method Summary
Modifier and TypeMethodDescriptionboolean
getClamp()
Gets whether @self should be clamped.static ClassHandler
double
Gets the precision of the spring.int
Gets the estimated duration of @self.double
Gets the initial velocity of @self.static int
static long
static TypeSystem.TypeSize
Gets the physical parameters of the spring of @self.static long
static TypeSystem.TypeSize
double
Gets the value @self will animate from.double
Gets the value @self will animate to.double
Gets the current velocity of @self.void
setClamp
(boolean clamp) Sets whether @self should be clamped.void
setEpsilon
(double epsilon) Sets the precision of the spring.void
setInitialVelocity
(double velocity) Sets the initial velocity of @self.void
setSpringParams
(SpringParams spring_params) Sets the physical parameters of the spring of @self.void
setValueFrom
(double value) Sets the value @self will animate from.void
setValueTo
(double value) Sets the value @self will animate to.Methods inherited from class ch.bailu.gtk.adw.Animation
getState, getTarget, getValue, getWidget, onDone, pause, play, reset, resume, setTarget, skip
Methods inherited from class ch.bailu.gtk.gobject.Object
addToggleRef, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, disconnect, disconnect, dupData, dupData, dupQdata, forceFloating, freezeNotify, get, get, getData, getData, getProperty, getProperty, getQdata, interfaceFindProperty, interfaceInstallProperty, isFloating, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, replaceData, replaceData, replaceQdata, runDispose, set, set, setData, setData, setDataFull, setDataFull, setProperty, setProperty, setQdata, setQdataFull, stealData, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref
Methods inherited from class ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacks
Methods inherited from class ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNull
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Constructor Details
-
SpringAnimation
-
SpringAnimation
public SpringAnimation(@Nonnull Widget widget, double from, double to, @Nonnull SpringParams spring_params, @Nonnull AnimationTarget target) 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.- Parameters:
widget
- a widget to create animation onfrom
- a value to animate fromto
- a value to animate tospring_params
- physical parameters of the springtarget
- a target value to animate
-
-
Method Details
-
getClassHandler
-
getClamp
public boolean getClamp()Gets whether @self should be clamped.- Returns:
- whether @self is clamped
-
getEpsilon
public double getEpsilon()Gets the precision of the spring.- Returns:
- the epsilon value
-
getEstimatedDuration
public int getEstimatedDuration()Gets the estimated duration of @self.
Can be [const@DURATION_INFINITE] if the spring damping is set to 0.- Returns:
- the estimated duration
-
getInitialVelocity
public double getInitialVelocity()Gets the initial velocity of @self.- Returns:
- the initial velocity
-
getSpringParams
Gets the physical parameters of the spring of @self.- Returns:
- the spring parameters
-
getValueFrom
public double getValueFrom()Gets the value @self will animate from.- Returns:
- the value to animate from
-
getValueTo
public double getValueTo()Gets the value @self will animate to.- Returns:
- the value to animate to
-
getVelocity
public double getVelocity()Gets the current velocity of @self.- Returns:
- the current velocity
-
setClamp
public void setClamp(boolean clamp) 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:value-from] if a
relative negative [property@SpringAnimation:initial-velocity] is set.- Parameters:
clamp
- the new value
-
setEpsilon
public void setEpsilon(double epsilon) 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.- Parameters:
epsilon
- the new value
-
setInitialVelocity
public void setInitialVelocity(double velocity) Sets the initial velocity of @self.
Initial velocity affects only the animation curve, but not its duration.- Parameters:
velocity
- the initial velocity
-
setSpringParams
Sets the physical parameters of the spring of @self.- Parameters:
spring_params
- the new spring parameters
-
setValueFrom
public void setValueFrom(double value) Sets the value @self will animate from.
The animation will start at this value and end at
[property@SpringAnimation:value-to].- Parameters:
value
- the value to animate from
-
setValueTo
public void setValueTo(double value) Sets the value @self will animate to.
The animation will start at [property@SpringAnimation:value-from] and end at
this value.- Parameters:
value
- the value to animate to
-
getTypeID
public static long getTypeID() -
getParentTypeID
public static long getParentTypeID() -
getTypeSize
-
getParentTypeSize
-
getInstanceSize
public static int getInstanceSize()
-