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 base class for animations.
AdwAnimation
represents an animation on a widget. It has a target that
provides a value to animate, and a state indicating whether the
animation hasn't been started yet, is playing, paused or finished.
Currently there are two concrete animation types:
[classtimedAnimation
] and [classspringAnimation
].
AdwAnimation
will automatically skip the animation if
[propertyanimation
:widget] is unmapped, or if
Settings:gtkEnableAnimations is FALSE
.
The signalanimation
[done] signal can be used to perform an action after
the animation ends, for example hiding a widget after animating its
Widget:opacity to 0.
AdwAnimation
will be kept alive while the animation is playing. As such,
it's safe to create an animation, start it and immediately unref it:
A fire-and-forget animation:
c code
static void animation_cb (double value, MyObject *self) { // Do something with @value } static void my_object_animate (MyObject *self) { AdwAnimationTarget *target = adw_callback_animation_target_new ((AdwAnimationTargetFunc) animation_cb, self, NULL); g_autoptr (AdwAnimation) animation = adw_timed_animation_new (widget, 0, 1, 250, target); adw_animation_play (animation); }
If there's a chance the previous animation for the same target hasn't yet
finished, the previous animation should be stopped first, or the existing
AdwAnimation
object can be reused.
Synopsis
- newtype Animation = Animation (ManagedPtr Animation)
- class (GObject o, IsDescendantOf Animation o) => IsAnimation o
- toAnimation :: (MonadIO m, IsAnimation o) => o -> m Animation
- animationGetFollowEnableAnimationsSetting :: (HasCallStack, MonadIO m, IsAnimation a) => a -> m Bool
- animationGetState :: (HasCallStack, MonadIO m, IsAnimation a) => a -> m AnimationState
- animationGetTarget :: (HasCallStack, MonadIO m, IsAnimation a) => a -> m AnimationTarget
- animationGetValue :: (HasCallStack, MonadIO m, IsAnimation a) => a -> m Double
- animationGetWidget :: (HasCallStack, MonadIO m, IsAnimation a) => a -> m Widget
- animationPause :: (HasCallStack, MonadIO m, IsAnimation a) => a -> m ()
- animationPlay :: (HasCallStack, MonadIO m, IsAnimation a) => a -> m ()
- animationReset :: (HasCallStack, MonadIO m, IsAnimation a) => a -> m ()
- animationResume :: (HasCallStack, MonadIO m, IsAnimation a) => a -> m ()
- animationSetFollowEnableAnimationsSetting :: (HasCallStack, MonadIO m, IsAnimation a) => a -> Bool -> m ()
- animationSetTarget :: (HasCallStack, MonadIO m, IsAnimation a, IsAnimationTarget b) => a -> b -> m ()
- animationSkip :: (HasCallStack, MonadIO m, IsAnimation a) => a -> m ()
- constructAnimationFollowEnableAnimationsSetting :: (IsAnimation o, MonadIO m) => Bool -> m (GValueConstruct o)
- getAnimationFollowEnableAnimationsSetting :: (MonadIO m, IsAnimation o) => o -> m Bool
- setAnimationFollowEnableAnimationsSetting :: (MonadIO m, IsAnimation o) => o -> Bool -> m ()
- getAnimationState :: (MonadIO m, IsAnimation o) => o -> m AnimationState
- constructAnimationTarget :: (IsAnimation o, MonadIO m, IsAnimationTarget a) => a -> m (GValueConstruct o)
- getAnimationTarget :: (MonadIO m, IsAnimation o) => o -> m AnimationTarget
- setAnimationTarget :: (MonadIO m, IsAnimation o, IsAnimationTarget a) => o -> a -> m ()
- getAnimationValue :: (MonadIO m, IsAnimation o) => o -> m Double
- constructAnimationWidget :: (IsAnimation o, MonadIO m, IsWidget a) => a -> m (GValueConstruct o)
- getAnimationWidget :: (MonadIO m, IsAnimation o) => o -> m Widget
- type AnimationDoneCallback = IO ()
- afterAnimationDone :: (IsAnimation a, MonadIO m) => a -> ((?self :: a) => AnimationDoneCallback) -> m SignalHandlerId
- onAnimationDone :: (IsAnimation a, MonadIO m) => a -> ((?self :: a) => AnimationDoneCallback) -> m SignalHandlerId
Exported types
Memory-managed wrapper type.
Instances
Eq Animation Source # | |
GObject Animation Source # | |
Defined in GI.Adw.Objects.Animation | |
ManagedPtrNewtype Animation Source # | |
Defined in GI.Adw.Objects.Animation toManagedPtr :: Animation -> ManagedPtr Animation | |
TypedObject Animation Source # | |
Defined in GI.Adw.Objects.Animation | |
HasParentTypes Animation Source # | |
Defined in GI.Adw.Objects.Animation | |
IsGValue (Maybe Animation) Source # | Convert |
Defined in GI.Adw.Objects.Animation gvalueGType_ :: IO GType gvalueSet_ :: Ptr GValue -> Maybe Animation -> IO () gvalueGet_ :: Ptr GValue -> IO (Maybe Animation) | |
type ParentTypes Animation Source # | |
Defined in GI.Adw.Objects.Animation type ParentTypes Animation = '[Object] |
class (GObject o, IsDescendantOf Animation o) => IsAnimation o Source #
Type class for types which can be safely cast to Animation
, for instance with toAnimation
.
Instances
(GObject o, IsDescendantOf Animation o) => IsAnimation o Source # | |
Defined in GI.Adw.Objects.Animation |
toAnimation :: (MonadIO m, IsAnimation o) => o -> m Animation Source #
Methods
Click to display all available methods, including inherited ones
Methods
bindProperty, bindPropertyFull, forceFloating, freezeNotify, getv, isFloating, notify, notifyByPspec, pause, play, ref, refSink, reset, resume, runDispose, skip, stealData, stealQdata, thawNotify, unref, watchClosure.
Getters
getData, getFollowEnableAnimationsSetting, getProperty, getQdata, getState, getTarget, getValue, getWidget.
Setters
setData, setDataFull, setFollowEnableAnimationsSetting, setProperty, setTarget.
getFollowEnableAnimationsSetting
animationGetFollowEnableAnimationsSetting Source #
:: (HasCallStack, MonadIO m, IsAnimation a) | |
=> a |
|
-> m Bool | Returns: whether to follow the global setting |
Gets whether self
should be skipped when animations are globally disabled.
Since: 1.3
getState
:: (HasCallStack, MonadIO m, IsAnimation a) | |
=> a |
|
-> m AnimationState | Returns: the animation value |
Gets the current value of self
.
The state indicates whether self
is currently playing, paused, finished or
hasn't been started yet.
getTarget
:: (HasCallStack, MonadIO m, IsAnimation a) | |
=> a |
|
-> m AnimationTarget | Returns: the animation target |
Gets the target self
animates.
getValue
:: (HasCallStack, MonadIO m, IsAnimation a) | |
=> a |
|
-> m Double | Returns: the current value |
Gets the current value of self
.
getWidget
:: (HasCallStack, MonadIO m, IsAnimation a) | |
=> a |
|
-> m Widget | Returns: the animation widget |
Gets the widget self
was created for.
It provides the frame clock for the animation. It's not strictly necessary for this widget to be same as the one being animated.
The widget must be mapped in order for the animation to work. If it's not mapped, or if it gets unmapped during an ongoing animation, the animation will be automatically skipped.
pause
:: (HasCallStack, MonadIO m, IsAnimation a) | |
=> a |
|
-> m () |
Pauses a playing animation for self
.
Does nothing if the current state of self
isn't ADW_ANIMATION_PLAYING
.
Sets [propertyanimation
:state] to ADW_ANIMATION_PAUSED
.
play
:: (HasCallStack, MonadIO m, IsAnimation a) | |
=> a |
|
-> m () |
Starts the animation for self
.
If the animation is playing, paused or has been completed, restarts it from the beginning. This allows to easily play an animation regardless of whether it's already playing or not.
Sets [propertyanimation
:state] to ADW_ANIMATION_PLAYING
.
The animation will be automatically skipped if [propertyanimation
:widget] is
unmapped, or if Settings:gtkEnableAnimations is FALSE
.
As such, it's not guaranteed that the animation will actually run. For
example, when using idleAdd
and starting an animation
immediately afterwards, it's entirely possible that the idle callback will
run after the animation has already finished, and not while it's playing.
reset
:: (HasCallStack, MonadIO m, IsAnimation a) | |
=> a |
|
-> m () |
Resets the animation for self
.
Sets [propertyanimation
:state] to ADW_ANIMATION_IDLE
.
resume
:: (HasCallStack, MonadIO m, IsAnimation a) | |
=> a |
|
-> m () |
Resumes a paused animation for self
.
This function must only be used if the animation has been paused with
[methodanimation
.pause].
Sets [propertyanimation
:state] to ADW_ANIMATION_PLAYING
.
setFollowEnableAnimationsSetting
animationSetFollowEnableAnimationsSetting Source #
:: (HasCallStack, MonadIO m, IsAnimation a) | |
=> a |
|
-> Bool |
|
-> m () |
Sets whether to skip self
when animations are globally disabled.
The default behavior is to skip the animation. Set to FALSE
to disable this
behavior.
This can be useful for cases where animation is essential, like spinners, or in demo applications. Most other animations should keep it enabled.
See Settings:gtkEnableAnimations.
Since: 1.3
setTarget
:: (HasCallStack, MonadIO m, IsAnimation a, IsAnimationTarget b) | |
=> a |
|
-> b |
|
-> m () |
Sets the target self
animates to target
.
skip
:: (HasCallStack, MonadIO m, IsAnimation a) | |
=> a |
|
-> m () |
Skips the animation for self
.
If the animation hasn't been started yet, is playing, or is paused, instantly
skips the animation to the end and causes signalanimation
[done] to be
emitted.
Sets [propertyanimation
:state] to ADW_ANIMATION_FINISHED
.
Properties
followEnableAnimationsSetting
Whether to skip the animation when animations are globally disabled.
The default behavior is to skip the animation. Set to FALSE
to disable
this behavior.
This can be useful for cases where animation is essential, like spinners, or in demo applications. Most other animations should keep it enabled.
See Settings:gtkEnableAnimations.
Since: 1.3
constructAnimationFollowEnableAnimationsSetting :: (IsAnimation o, MonadIO m) => Bool -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “follow-enable-animations-setting
” property. This is rarely needed directly, but it is used by new
.
getAnimationFollowEnableAnimationsSetting :: (MonadIO m, IsAnimation o) => o -> m Bool Source #
Get the value of the “follow-enable-animations-setting
” property.
When overloading is enabled, this is equivalent to
get
animation #followEnableAnimationsSetting
setAnimationFollowEnableAnimationsSetting :: (MonadIO m, IsAnimation o) => o -> Bool -> m () Source #
Set the value of the “follow-enable-animations-setting
” property.
When overloading is enabled, this is equivalent to
set
animation [ #followEnableAnimationsSetting:=
value ]
state
The animation state.
The state indicates whether the animation is currently playing, paused, finished or hasn't been started yet.
getAnimationState :: (MonadIO m, IsAnimation o) => o -> m AnimationState Source #
Get the value of the “state
” property.
When overloading is enabled, this is equivalent to
get
animation #state
target
The target to animate.
constructAnimationTarget :: (IsAnimation o, MonadIO m, IsAnimationTarget a) => a -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “target
” property. This is rarely needed directly, but it is used by new
.
getAnimationTarget :: (MonadIO m, IsAnimation o) => o -> m AnimationTarget Source #
Get the value of the “target
” property.
When overloading is enabled, this is equivalent to
get
animation #target
setAnimationTarget :: (MonadIO m, IsAnimation o, IsAnimationTarget a) => o -> a -> m () Source #
Set the value of the “target
” property.
When overloading is enabled, this is equivalent to
set
animation [ #target:=
value ]
value
The current value of the animation.
getAnimationValue :: (MonadIO m, IsAnimation o) => o -> m Double Source #
Get the value of the “value
” property.
When overloading is enabled, this is equivalent to
get
animation #value
widget
The animation widget.
It provides the frame clock for the animation. It's not strictly necessary for this widget to be same as the one being animated.
The widget must be mapped in order for the animation to work. If it's not mapped, or if it gets unmapped during an ongoing animation, the animation will be automatically skipped.
constructAnimationWidget :: (IsAnimation o, MonadIO m, IsWidget a) => a -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “widget
” property. This is rarely needed directly, but it is used by new
.
getAnimationWidget :: (MonadIO m, IsAnimation o) => o -> m Widget Source #
Get the value of the “widget
” property.
When overloading is enabled, this is equivalent to
get
animation #widget
Signals
done
type AnimationDoneCallback = IO () Source #
This signal is emitted when the animation has been completed, either on its
own or via calling [methodanimation
.skip].
afterAnimationDone :: (IsAnimation a, MonadIO m) => a -> ((?self :: a) => AnimationDoneCallback) -> m SignalHandlerId Source #
Connect a signal handler for the done signal, to be run after the default handler. When overloading is enabled, this is equivalent to
after
animation #done callback
By default the object invoking the signal is not passed to the callback.
If you need to access it, you can use the implit ?self
parameter.
Note that this requires activating the ImplicitParams
GHC extension.
onAnimationDone :: (IsAnimation a, MonadIO m) => a -> ((?self :: a) => AnimationDoneCallback) -> m SignalHandlerId Source #
Connect a signal handler for the done signal, to be run before the default handler. When overloading is enabled, this is equivalent to
on
animation #done callback