Copyright | Will Thompson and Iñaki García Etxebarria |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
A spring-based [classanimation
].
AdwSpringAnimation
implements an animation driven by a physical model of a
spring described by [structspringParams
], with a resting position in
[propertyspringAnimation
:value-to], stretched to
[propertyspringAnimation
: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
[propertyspringAnimation
:epsilon], or immediately when it reaches
[propertyspringAnimation
:value-to] if
[propertyspringAnimation
:clamp] is set to TRUE
. The estimated duration can
be obtained with [propertyspringAnimation
:estimated-duration].
Due to the nature of spring-driven motion the animation can overshoot
[propertyspringAnimation
:value-to] before coming to a rest. Whether the
animation will overshoot or not depends on the damping ratio of the spring.
See [structspringParams
] for more information about specific damping ratio
values.
If [propertyspringAnimation
: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
[propertyspringAnimation
: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.
Synopsis
- newtype SpringAnimation = SpringAnimation (ManagedPtr SpringAnimation)
- class (GObject o, IsDescendantOf SpringAnimation o) => IsSpringAnimation o
- toSpringAnimation :: (MonadIO m, IsSpringAnimation o) => o -> m SpringAnimation
- springAnimationCalculateValue :: (HasCallStack, MonadIO m, IsSpringAnimation a) => a -> Word32 -> m Double
- springAnimationCalculateVelocity :: (HasCallStack, MonadIO m, IsSpringAnimation a) => a -> Word32 -> m Double
- springAnimationGetClamp :: (HasCallStack, MonadIO m, IsSpringAnimation a) => a -> m Bool
- springAnimationGetEpsilon :: (HasCallStack, MonadIO m, IsSpringAnimation a) => a -> m Double
- springAnimationGetEstimatedDuration :: (HasCallStack, MonadIO m, IsSpringAnimation a) => a -> m Word32
- springAnimationGetInitialVelocity :: (HasCallStack, MonadIO m, IsSpringAnimation a) => a -> m Double
- springAnimationGetSpringParams :: (HasCallStack, MonadIO m, IsSpringAnimation a) => a -> m SpringParams
- springAnimationGetValueFrom :: (HasCallStack, MonadIO m, IsSpringAnimation a) => a -> m Double
- springAnimationGetValueTo :: (HasCallStack, MonadIO m, IsSpringAnimation a) => a -> m Double
- springAnimationGetVelocity :: (HasCallStack, MonadIO m, IsSpringAnimation a) => a -> m Double
- springAnimationNew :: (HasCallStack, MonadIO m, IsWidget a, IsAnimationTarget b) => a -> Double -> Double -> SpringParams -> b -> m SpringAnimation
- springAnimationSetClamp :: (HasCallStack, MonadIO m, IsSpringAnimation a) => a -> Bool -> m ()
- springAnimationSetEpsilon :: (HasCallStack, MonadIO m, IsSpringAnimation a) => a -> Double -> m ()
- springAnimationSetInitialVelocity :: (HasCallStack, MonadIO m, IsSpringAnimation a) => a -> Double -> m ()
- springAnimationSetSpringParams :: (HasCallStack, MonadIO m, IsSpringAnimation a) => a -> SpringParams -> m ()
- springAnimationSetValueFrom :: (HasCallStack, MonadIO m, IsSpringAnimation a) => a -> Double -> m ()
- springAnimationSetValueTo :: (HasCallStack, MonadIO m, IsSpringAnimation a) => a -> Double -> m ()
- constructSpringAnimationClamp :: (IsSpringAnimation o, MonadIO m) => Bool -> m (GValueConstruct o)
- getSpringAnimationClamp :: (MonadIO m, IsSpringAnimation o) => o -> m Bool
- setSpringAnimationClamp :: (MonadIO m, IsSpringAnimation o) => o -> Bool -> m ()
- constructSpringAnimationEpsilon :: (IsSpringAnimation o, MonadIO m) => Double -> m (GValueConstruct o)
- getSpringAnimationEpsilon :: (MonadIO m, IsSpringAnimation o) => o -> m Double
- setSpringAnimationEpsilon :: (MonadIO m, IsSpringAnimation o) => o -> Double -> m ()
- getSpringAnimationEstimatedDuration :: (MonadIO m, IsSpringAnimation o) => o -> m Word32
- constructSpringAnimationInitialVelocity :: (IsSpringAnimation o, MonadIO m) => Double -> m (GValueConstruct o)
- getSpringAnimationInitialVelocity :: (MonadIO m, IsSpringAnimation o) => o -> m Double
- setSpringAnimationInitialVelocity :: (MonadIO m, IsSpringAnimation o) => o -> Double -> m ()
- constructSpringAnimationSpringParams :: (IsSpringAnimation o, MonadIO m) => SpringParams -> m (GValueConstruct o)
- getSpringAnimationSpringParams :: (MonadIO m, IsSpringAnimation o) => o -> m SpringParams
- setSpringAnimationSpringParams :: (MonadIO m, IsSpringAnimation o) => o -> SpringParams -> m ()
- constructSpringAnimationValueFrom :: (IsSpringAnimation o, MonadIO m) => Double -> m (GValueConstruct o)
- getSpringAnimationValueFrom :: (MonadIO m, IsSpringAnimation o) => o -> m Double
- setSpringAnimationValueFrom :: (MonadIO m, IsSpringAnimation o) => o -> Double -> m ()
- constructSpringAnimationValueTo :: (IsSpringAnimation o, MonadIO m) => Double -> m (GValueConstruct o)
- getSpringAnimationValueTo :: (MonadIO m, IsSpringAnimation o) => o -> m Double
- setSpringAnimationValueTo :: (MonadIO m, IsSpringAnimation o) => o -> Double -> m ()
- getSpringAnimationVelocity :: (MonadIO m, IsSpringAnimation o) => o -> m Double
Exported types
newtype SpringAnimation Source #
Memory-managed wrapper type.
SpringAnimation (ManagedPtr SpringAnimation) |
Instances
Eq SpringAnimation Source # | |
Defined in GI.Adw.Objects.SpringAnimation (==) :: SpringAnimation -> SpringAnimation -> Bool # (/=) :: SpringAnimation -> SpringAnimation -> Bool # | |
GObject SpringAnimation Source # | |
Defined in GI.Adw.Objects.SpringAnimation | |
ManagedPtrNewtype SpringAnimation Source # | |
Defined in GI.Adw.Objects.SpringAnimation toManagedPtr :: SpringAnimation -> ManagedPtr SpringAnimation | |
TypedObject SpringAnimation Source # | |
Defined in GI.Adw.Objects.SpringAnimation | |
HasParentTypes SpringAnimation Source # | |
Defined in GI.Adw.Objects.SpringAnimation | |
IsGValue (Maybe SpringAnimation) Source # | Convert |
Defined in GI.Adw.Objects.SpringAnimation gvalueGType_ :: IO GType gvalueSet_ :: Ptr GValue -> Maybe SpringAnimation -> IO () gvalueGet_ :: Ptr GValue -> IO (Maybe SpringAnimation) | |
type ParentTypes SpringAnimation Source # | |
Defined in GI.Adw.Objects.SpringAnimation |
class (GObject o, IsDescendantOf SpringAnimation o) => IsSpringAnimation o Source #
Type class for types which can be safely cast to SpringAnimation
, for instance with toSpringAnimation
.
Instances
(GObject o, IsDescendantOf SpringAnimation o) => IsSpringAnimation o Source # | |
Defined in GI.Adw.Objects.SpringAnimation |
toSpringAnimation :: (MonadIO m, IsSpringAnimation o) => o -> m SpringAnimation Source #
Cast to SpringAnimation
, for types for which this is known to be safe. For general casts, use castTo
.
Methods
Click to display all available methods, including inherited ones
Methods
bindProperty, bindPropertyFull, calculateValue, calculateVelocity, forceFloating, freezeNotify, getv, isFloating, notify, notifyByPspec, pause, play, ref, refSink, reset, resume, runDispose, skip, stealData, stealQdata, thawNotify, unref, watchClosure.
Getters
getClamp, getData, getEpsilon, getEstimatedDuration, getFollowEnableAnimationsSetting, getInitialVelocity, getProperty, getQdata, getSpringParams, getState, getTarget, getValue, getValueFrom, getValueTo, getVelocity, getWidget.
Setters
setClamp, setData, setDataFull, setEpsilon, setFollowEnableAnimationsSetting, setInitialVelocity, setProperty, setSpringParams, setTarget, setValueFrom, setValueTo.
calculateValue
springAnimationCalculateValue Source #
:: (HasCallStack, MonadIO m, IsSpringAnimation a) | |
=> a |
|
-> Word32 |
|
-> m Double | Returns: the value at |
Calculates the value self
will have at time
.
The time starts at 0 and ends at
[propertyspringAnimation
:estimated_duration].
See also [methodspringAnimation
.calculate_velocity].
Since: 1.3
calculateVelocity
springAnimationCalculateVelocity Source #
:: (HasCallStack, MonadIO m, IsSpringAnimation a) | |
=> a |
|
-> Word32 |
|
-> m Double | Returns: the velocity at |
Calculates the velocity self
will have at time
.
The time starts at 0 and ends at
[propertyspringAnimation
:estimated_duration].
See also [methodspringAnimation
.calculate_value].
Since: 1.3
getClamp
springAnimationGetClamp Source #
:: (HasCallStack, MonadIO m, IsSpringAnimation a) | |
=> a |
|
-> m Bool | Returns: whether |
Gets whether self
should be clamped.
getEpsilon
springAnimationGetEpsilon Source #
:: (HasCallStack, MonadIO m, IsSpringAnimation a) | |
=> a |
|
-> m Double | Returns: the epsilon value |
Gets the precision of the spring.
getEstimatedDuration
springAnimationGetEstimatedDuration Source #
:: (HasCallStack, MonadIO m, IsSpringAnimation a) | |
=> a |
|
-> m Word32 | Returns: the estimated duration |
Gets the estimated duration of self
, in milliseconds.
Can be [constdURATIONINFINITE
] if the spring damping is set to 0.
getInitialVelocity
springAnimationGetInitialVelocity Source #
:: (HasCallStack, MonadIO m, IsSpringAnimation a) | |
=> a |
|
-> m Double | Returns: the initial velocity |
Gets the initial velocity of self
.
getSpringParams
springAnimationGetSpringParams Source #
:: (HasCallStack, MonadIO m, IsSpringAnimation a) | |
=> a |
|
-> m SpringParams | Returns: the spring parameters |
Gets the physical parameters of the spring of self
.
getValueFrom
springAnimationGetValueFrom Source #
:: (HasCallStack, MonadIO m, IsSpringAnimation a) | |
=> a |
|
-> m Double | Returns: the value to animate from |
Gets the value self
will animate from.
getValueTo
springAnimationGetValueTo Source #
:: (HasCallStack, MonadIO m, IsSpringAnimation a) | |
=> a |
|
-> m Double | Returns: the value to animate to |
Gets the value self
will animate to.
getVelocity
springAnimationGetVelocity Source #
:: (HasCallStack, MonadIO m, IsSpringAnimation a) | |
=> a |
|
-> m Double | Returns: the current velocity |
Gets the current velocity of self
.
new
:: (HasCallStack, MonadIO m, IsWidget a, IsAnimationTarget b) | |
=> a |
|
-> Double |
|
-> Double |
|
-> SpringParams |
|
-> b |
|
-> m SpringAnimation | Returns: the newly created animation |
Creates a new AdwSpringAnimation
on widget
.
The animation will animate target
from from
to to
with the dynamics of a
spring described by springParams
.
setClamp
springAnimationSetClamp Source #
:: (HasCallStack, MonadIO m, IsSpringAnimation a) | |
=> a |
|
-> Bool |
|
-> m () |
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 [propertyspringAnimation
:value-from] if a
relative negative [propertyspringAnimation
:initial-velocity] is set.
setEpsilon
springAnimationSetEpsilon Source #
:: (HasCallStack, MonadIO m, IsSpringAnimation a) | |
=> a |
|
-> Double |
|
-> m () |
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.
setInitialVelocity
springAnimationSetInitialVelocity Source #
:: (HasCallStack, MonadIO m, IsSpringAnimation a) | |
=> a |
|
-> Double |
|
-> m () |
Sets the initial velocity of self
.
Initial velocity affects only the animation curve, but not its duration.
setSpringParams
springAnimationSetSpringParams Source #
:: (HasCallStack, MonadIO m, IsSpringAnimation a) | |
=> a |
|
-> SpringParams |
|
-> m () |
Sets the physical parameters of the spring of self
.
setValueFrom
springAnimationSetValueFrom Source #
:: (HasCallStack, MonadIO m, IsSpringAnimation a) | |
=> a |
|
-> Double |
|
-> m () |
Sets the value self
will animate from.
The animation will start at this value and end at
[propertyspringAnimation
:value-to].
setValueTo
springAnimationSetValueTo Source #
:: (HasCallStack, MonadIO m, IsSpringAnimation a) | |
=> a |
|
-> Double |
|
-> m () |
Sets the value self
will animate to.
The animation will start at [propertyspringAnimation
:value-from] and end at
this value.
Properties
clamp
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 [propertyspringAnimation
:value-from] if a
relative negative [propertyspringAnimation
:initial-velocity] is set.
constructSpringAnimationClamp :: (IsSpringAnimation o, MonadIO m) => Bool -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “clamp
” property. This is rarely needed directly, but it is used by new
.
getSpringAnimationClamp :: (MonadIO m, IsSpringAnimation o) => o -> m Bool Source #
Get the value of the “clamp
” property.
When overloading is enabled, this is equivalent to
get
springAnimation #clamp
setSpringAnimationClamp :: (MonadIO m, IsSpringAnimation o) => o -> Bool -> m () Source #
Set the value of the “clamp
” property.
When overloading is enabled, this is equivalent to
set
springAnimation [ #clamp:=
value ]
epsilon
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.
constructSpringAnimationEpsilon :: (IsSpringAnimation o, MonadIO m) => Double -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “epsilon
” property. This is rarely needed directly, but it is used by new
.
getSpringAnimationEpsilon :: (MonadIO m, IsSpringAnimation o) => o -> m Double Source #
Get the value of the “epsilon
” property.
When overloading is enabled, this is equivalent to
get
springAnimation #epsilon
setSpringAnimationEpsilon :: (MonadIO m, IsSpringAnimation o) => o -> Double -> m () Source #
Set the value of the “epsilon
” property.
When overloading is enabled, this is equivalent to
set
springAnimation [ #epsilon:=
value ]
estimatedDuration
Estimated duration of the animation, in milliseconds.
Can be [constdURATIONINFINITE
] if the spring damping is set to 0.
getSpringAnimationEstimatedDuration :: (MonadIO m, IsSpringAnimation o) => o -> m Word32 Source #
Get the value of the “estimated-duration
” property.
When overloading is enabled, this is equivalent to
get
springAnimation #estimatedDuration
initialVelocity
The initial velocity to start the animation with.
Initial velocity affects only the animation curve, but not its duration.
constructSpringAnimationInitialVelocity :: (IsSpringAnimation o, MonadIO m) => Double -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “initial-velocity
” property. This is rarely needed directly, but it is used by new
.
getSpringAnimationInitialVelocity :: (MonadIO m, IsSpringAnimation o) => o -> m Double Source #
Get the value of the “initial-velocity
” property.
When overloading is enabled, this is equivalent to
get
springAnimation #initialVelocity
setSpringAnimationInitialVelocity :: (MonadIO m, IsSpringAnimation o) => o -> Double -> m () Source #
Set the value of the “initial-velocity
” property.
When overloading is enabled, this is equivalent to
set
springAnimation [ #initialVelocity:=
value ]
springParams
Physical parameters describing the spring.
constructSpringAnimationSpringParams :: (IsSpringAnimation o, MonadIO m) => SpringParams -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “spring-params
” property. This is rarely needed directly, but it is used by new
.
getSpringAnimationSpringParams :: (MonadIO m, IsSpringAnimation o) => o -> m SpringParams Source #
Get the value of the “spring-params
” property.
When overloading is enabled, this is equivalent to
get
springAnimation #springParams
setSpringAnimationSpringParams :: (MonadIO m, IsSpringAnimation o) => o -> SpringParams -> m () Source #
Set the value of the “spring-params
” property.
When overloading is enabled, this is equivalent to
set
springAnimation [ #springParams:=
value ]
valueFrom
The value to animate from.
The animation will start at this value and end at
[propertyspringAnimation
:value-to].
constructSpringAnimationValueFrom :: (IsSpringAnimation o, MonadIO m) => Double -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “value-from
” property. This is rarely needed directly, but it is used by new
.
getSpringAnimationValueFrom :: (MonadIO m, IsSpringAnimation o) => o -> m Double Source #
Get the value of the “value-from
” property.
When overloading is enabled, this is equivalent to
get
springAnimation #valueFrom
setSpringAnimationValueFrom :: (MonadIO m, IsSpringAnimation o) => o -> Double -> m () Source #
Set the value of the “value-from
” property.
When overloading is enabled, this is equivalent to
set
springAnimation [ #valueFrom:=
value ]
valueTo
The value to animate to.
The animation will start at [propertyspringAnimation
:value-from] and end
at this value.
constructSpringAnimationValueTo :: (IsSpringAnimation o, MonadIO m) => Double -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “value-to
” property. This is rarely needed directly, but it is used by new
.
getSpringAnimationValueTo :: (MonadIO m, IsSpringAnimation o) => o -> m Double Source #
Get the value of the “value-to
” property.
When overloading is enabled, this is equivalent to
get
springAnimation #valueTo
setSpringAnimationValueTo :: (MonadIO m, IsSpringAnimation o) => o -> Double -> m () Source #
Set the value of the “value-to
” property.
When overloading is enabled, this is equivalent to
set
springAnimation [ #valueTo:=
value ]
velocity
Current velocity of the animation.
getSpringAnimationVelocity :: (MonadIO m, IsSpringAnimation o) => o -> m Double Source #
Get the value of the “velocity
” property.
When overloading is enabled, this is equivalent to
get
springAnimation #velocity