Adw.Animation¶
- Subclasses:
Methods¶
- Inherited:
- Structs:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w/en |
|||
r |
|||
r/w/c/en |
|||
r |
|||
r/w/co |
Signals¶
- Inherited:
Name |
Short Description |
---|---|
This signal is emitted when the animation has been completed, either on its own or via calling [method`Animation`.skip]. |
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
parent_instance |
r |
Class Details¶
- class Adw.Animation(**kwargs)¶
- Bases:
- Abstract:
Yes
- Structure:
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: [class`TimedAnimation`] and [class`SpringAnimation`].
AdwAnimation
will automatically skip the animation if [property`Animation`:py:data::widget<Adw.Animation.props.widget>] is unmapped, or if [property`Gtk`.Settings:gtk-enable-animations] isFALSE
.The [signal`Animation`:py:func:::done<Adw.Animation.signals.done>] signal can be used to perform an action after the animation ends, for example hiding a widget after animating its [property`Gtk`.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 static void animation_cb (double value, MyObject *self) { // Do something with value }
static void my_object_animate (MyObject *self) {
Adw.AnimationTarget
*target =Adw.CallbackAnimationTarget.new
((Adw.AnimationTargetFunc
) animation_cb, self,None
); g_autoptr (Adw.Animation
) animation =Adw.TimedAnimation.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.- get_follow_enable_animations_setting()¶
- Returns:
whether to follow the global setting
- Return type:
Gets whether self should be skipped when animations are globally disabled.
New in version 1.3.
- get_state()¶
- Returns:
the animation value
- Return type:
Gets the current value of self.
The state indicates whether self is currently playing, paused, finished or hasn’t been started yet.
- get_target()¶
- Returns:
the animation target
- Return type:
Gets the target self animates.
- get_widget()¶
- Returns:
the animation widget
- Return type:
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()¶
Pauses a playing animation for self.
Does nothing if the current state of self isn’t
ADW_ANIMATION_PLAYING
.Sets [property`Animation`:py:data::state<Adw.Animation.props.state>] to
ADW_ANIMATION_PAUSED
.
- play()¶
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 [property`Animation`:py:data::state<Adw.Animation.props.state>] to
ADW_ANIMATION_PLAYING
.The animation will be automatically skipped if [property`Animation`:py:data::widget<Adw.Animation.props.widget>] is unmapped, or if [property`Gtk`.Settings:gtk-enable-animations] is
FALSE
.As such, it’s not guaranteed that the animation will actually run. For example, when using [func`GLib`.idle_add] 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()¶
Resets the animation for self.
Sets [property`Animation`:py:data::state<Adw.Animation.props.state>] to
ADW_ANIMATION_IDLE
.
- resume()¶
Resumes a paused animation for self.
This function must only be used if the animation has been paused with [method`Animation`.pause].
Sets [property`Animation`:py:data::state<Adw.Animation.props.state>] to
ADW_ANIMATION_PLAYING
.
- set_follow_enable_animations_setting(setting)¶
- Parameters:
setting (
bool
) – whether to follow the global setting
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 [property`Gtk`.Settings:gtk-enable-animations].
New in version 1.3.
- set_target(target)¶
- Parameters:
target (
Adw.AnimationTarget
) – an animation target
Sets the target self animates to target.
- skip()¶
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 [signal`Animation`:py:func:::done<Adw.Animation.signals.done>] to be emitted.
Sets [property`Animation`:py:data::state<Adw.Animation.props.state>] to
ADW_ANIMATION_FINISHED
.
Signal Details¶
- Adw.Animation.signals.done(animation)¶
- Signal Name:
done
- Flags:
- Parameters:
animation (
Adw.Animation
) – The object which received the signal
This signal is emitted when the animation has been completed, either on its own or via calling [method`Animation`.skip].
Property Details¶
- Adw.Animation.props.follow_enable_animations_setting¶
- Name:
follow-enable-animations-setting
- Type:
- Default Value:
- Flags:
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 [property`Gtk`.Settings:gtk-enable-animations].
New in version 1.3.
- Adw.Animation.props.state¶
- Name:
state
- Type:
- Default Value:
- Flags:
The animation state.
The state indicates whether the animation is currently playing, paused, finished or hasn’t been started yet.
- Adw.Animation.props.target¶
- Name:
target
- Type:
- Default Value:
- Flags:
The target to animate.
- Adw.Animation.props.value¶
-
The current value of the animation.
- Adw.Animation.props.widget¶
- Name:
widget
- Type:
- Default Value:
- Flags:
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.