gi-adwaita-1.0.3: Adwaita bindings
CopyrightWill Thompson and Iñaki García Etxebarria
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellSafe-Inferred
LanguageHaskell2010

GI.Adw.Objects.Animation

Description

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.

Since: 1.0

Synopsis

Exported types

newtype Animation Source #

Memory-managed wrapper type.

Constructors

Animation (ManagedPtr Animation) 

Instances

Instances details
Eq Animation Source # 
Instance details

Defined in GI.Adw.Objects.Animation

GObject Animation Source # 
Instance details

Defined in GI.Adw.Objects.Animation

ManagedPtrNewtype Animation Source # 
Instance details

Defined in GI.Adw.Objects.Animation

Methods

toManagedPtr :: Animation -> ManagedPtr Animation

TypedObject Animation Source # 
Instance details

Defined in GI.Adw.Objects.Animation

Methods

glibType :: IO GType

HasParentTypes Animation Source # 
Instance details

Defined in GI.Adw.Objects.Animation

IsGValue (Maybe Animation) Source #

Convert Animation to and from GValue. See toGValue and fromGValue.

Instance details

Defined in GI.Adw.Objects.Animation

Methods

gvalueGType_ :: IO GType

gvalueSet_ :: Ptr GValue -> Maybe Animation -> IO ()

gvalueGet_ :: Ptr GValue -> IO (Maybe Animation)

type ParentTypes Animation Source # 
Instance details

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

Instances details
(GObject o, IsDescendantOf Animation o) => IsAnimation o Source # 
Instance details

Defined in GI.Adw.Objects.Animation

toAnimation :: (MonadIO m, IsAnimation o) => o -> m Animation Source #

Cast to Animation, for types for which this is known to be safe. For general casts, use castTo.

Methods

getState

animationGetState Source #

Arguments

:: (HasCallStack, MonadIO m, IsAnimation a) 
=> a

self: an animation

-> 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.

Since: 1.0

getTarget

animationGetTarget Source #

Arguments

:: (HasCallStack, MonadIO m, IsAnimation a) 
=> a

self: an animation

-> m AnimationTarget

Returns: the animation target

Gets the target self animates.

Since: 1.0

getValue

animationGetValue Source #

Arguments

:: (HasCallStack, MonadIO m, IsAnimation a) 
=> a

self: an animation

-> m Double

Returns: the current value

Gets the current value of self.

Since: 1.0

getWidget

animationGetWidget Source #

Arguments

:: (HasCallStack, MonadIO m, IsAnimation a) 
=> a

self: an animation

-> 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.

Since: 1.0

pause

animationPause Source #

Arguments

:: (HasCallStack, MonadIO m, IsAnimation a) 
=> a

self: an animation

-> 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.

Since: 1.0

play

animationPlay Source #

Arguments

:: (HasCallStack, MonadIO m, IsAnimation a) 
=> a

self: an animation

-> 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.

Since: 1.0

reset

animationReset Source #

Arguments

:: (HasCallStack, MonadIO m, IsAnimation a) 
=> a

self: an animation

-> m () 

Resets the animation for self.

Sets [propertyanimation:state] to ADW_ANIMATION_IDLE.

Since: 1.0

resume

animationResume Source #

Arguments

:: (HasCallStack, MonadIO m, IsAnimation a) 
=> a

self: an animation

-> 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.

Since: 1.0

setTarget

animationSetTarget Source #

Arguments

:: (HasCallStack, MonadIO m, IsAnimation a, IsAnimationTarget b) 
=> a

self: an animation

-> b

target: an animation target

-> m () 

Sets the target self animates to target.

Since: 1.0

skip

animationSkip Source #

Arguments

:: (HasCallStack, MonadIO m, IsAnimation a) 
=> a

self: an animation

-> 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.

Since: 1.0

Properties

state

The animation state.

The state indicates whether the animation is currently playing, paused, finished or hasn't been started yet.

Since: 1.0

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.

Since: 1.0

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.

Since: 1.0

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.

Since: 1.0

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].

Since: 1.0

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