Class Animation
- All Implemented Interfaces:
Proxy
- Direct Known Subclasses:
Animation.AnimationImpl
,SpringAnimation
,TimedAnimation
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:
TimedAnimation
and SpringAnimation
.
AdwAnimation
will automatically skip the animation if
Animation:widget
is unmapped, or if
Gtk.Settings:gtk-enable-animations
is FALSE
.
The Animation::done
signal can be used to perform an action after
the animation ends, for example hiding a widget after animating its
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:
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.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static class
The AnimationImpl type represents a native instance of the abstract Animation class.static class
Animation.Builder<B extends Animation.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static interface
Functional interface declaration of theDoneCallback
callback.Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
-
Constructor Summary
ConstructorDescriptionAnimation
(MemorySegment address) Create a Animation proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected Animation
asParent()
Returns this instance as if it were its parent type.static Animation.Builder
<? extends Animation.Builder> builder()
AAnimation.Builder
object constructs aAnimation
with the specified properties.void
emitDone()
Emits the "done" signal.boolean
Gets whether this Animation should be skipped when animations are globally disabled.static MemoryLayout
The memory layout of the native struct.getState()
Gets the current value of this Animation.Gets the target this Animation animates.static Type
getType()
Get the GType of the Animation classdouble
getValue()
Gets the current value of this Animation.Gets the widget this Animation was created for.onDone
(Animation.DoneCallback handler) This signal is emitted when the animation has been completed, either on its own or via callingskip()
.void
pause()
Pauses a playing animation for this Animation.void
play()
Starts the animation for this Animation.void
reset()
Resets the animation for this Animation.void
resume()
Resumes a paused animation for this Animation.void
setFollowEnableAnimationsSetting
(boolean setting) Sets whether to skip this Animation when animations are globally disabled.void
setTarget
(AnimationTarget target) Sets the target this Animation animates totarget
.void
skip()
Skips the animation for this Animation.Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newInstance, newInstance, newv, notify_, notify_, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withProperties
Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
Animation
Create a Animation proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuper
keyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()
doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName()
. This will call the native function pointer of this virtual method in the typeclass of the parent type. -
getFollowEnableAnimationsSetting
public boolean getFollowEnableAnimationsSetting()Gets whether this Animation should be skipped when animations are globally disabled.- Returns:
- whether to follow the global setting
-
getState
Gets the current value of this Animation.The state indicates whether this Animation is currently playing, paused, finished or hasn't been started yet.
- Returns:
- the animation value
-
getTarget
Gets the target this Animation animates.- Returns:
- the animation target
-
getValue
public double getValue()Gets the current value of this Animation.- Returns:
- the current value
-
getWidget
Gets the widget this Animation 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.
- Returns:
- the animation widget
-
pause
public void pause()Pauses a playing animation for this Animation.Does nothing if the current state of this Animation isn't
ADW_ANIMATION_PLAYING
.Sets
Animation:state
toADW_ANIMATION_PAUSED
. -
play
public void play()Starts the animation for this Animation.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
Animation:state
toADW_ANIMATION_PLAYING
.The animation will be automatically skipped if
Animation:widget
is unmapped, or ifGtk.Settings:gtk-enable-animations
isFALSE
.As such, it's not guaranteed that the animation will actually run. For example, when using
GLib.idleAdd(int, org.gnome.glib.SourceFunc)
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
public void reset()Resets the animation for this Animation.Sets
Animation:state
toADW_ANIMATION_IDLE
. -
resume
public void resume()Resumes a paused animation for this Animation.This function must only be used if the animation has been paused with
pause()
.Sets
Animation:state
toADW_ANIMATION_PLAYING
. -
setFollowEnableAnimationsSetting
public void setFollowEnableAnimationsSetting(boolean setting) Sets whether to skip this 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
Gtk.Settings:gtk-enable-animations
.- Parameters:
setting
- whether to follow the global setting
-
setTarget
Sets the target this Animation animates totarget
.- Parameters:
target
- an animation target
-
skip
public void skip()Skips the animation for this Animation.If the animation hasn't been started yet, is playing, or is paused, instantly skips the animation to the end and causes
Animation::done
to be emitted.Sets
Animation:state
toADW_ANIMATION_FINISHED
. -
onDone
This signal is emitted when the animation has been completed, either on its own or via callingskip()
.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitDone
public void emitDone()Emits the "done" signal. SeeonDone(org.gnome.adw.Animation.DoneCallback)
. -
builder
AAnimation.Builder
object constructs aAnimation
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withAnimation.Builder.build()
.
-