跳转至

cf::ui::components::ICFAbstractAnimation

Abstract animation base class. More...

#include <animation.h>

Inherits from QObject

Inherited by cf::ui::components::ICFAnimationGroup, cf::ui::components::ICFSpringAnimation, cf::ui::components::ICFTimingAnimation, cf::ui::components::material::CFMaterialPropertyAnimation

Public Types

Name
enum class State { Idle, Running, Paused, Finished}
Animation states.
enum class Direction { Forward, Backward}
Animation playback direction.

Public Signals

Name
void started()
Signal emitted when animation starts.
void paused()
Signal emitted when animation is paused.
void stopped()
Signal emitted when animation stops.
void reversed()
Signal emitted when animation reverses direction.
void finished()
Signal emitted when animation finishes.
void progressChanged(float progress)
Signal emitted when animation progress changes.

Public Functions

Name
ICFAbstractAnimation(QObject * parent =nullptr)
virtual void start(Direction dir =Direction::Forward) =0
Starts the animation in the specified direction.
virtual void pause() =0
Pauses the animation.
virtual void stop() =0
Stops the animation and resets to initial state.
virtual void reverse() =0
Reverses the animation direction.
virtual bool tick(int dt) =0
Updates the animation state.
virtual cf::WeakPtr< ICFAbstractAnimation > GetWeakPtr() =0
Gets a weak pointer to this animation.
bool getEnabled() const
Gets the enabled state of the animation.
void setTargetFps(float fps)
Set the target FPS for this animation.
int calculateInterval() const
Calculate the timer interval based on target FPS.

Protected Functions

Name
void setEnabled(bool enabled)
Sets the enabled state of the animation.

Protected Attributes

Name
QTimer * driven_internal_timer
float m_progress
State m_state
float targetFps_
Target FPS for this animation (default 60.0f)

Friends

Name
class ICFAnimationManagerFactory(ICFAnimationManagerFactory )

Detailed Description

class cf::ui::components::ICFAbstractAnimation;

Abstract animation base class.

Since: 0.1

Provides the common interface for all animations including state management, direction control, and lifecycle methods.

Public Types Documentation

enum State

Enumerator Value Description
Idle
Running
Paused
Finished

Animation states.

Since: 0.1

enum Direction

Enumerator Value Description
Forward
Backward

Animation playback direction.

Since: 0.1

Public Signals Documentation

signal started

void started()

Signal emitted when animation starts.

Since: 0.1

signal paused

void paused()

Signal emitted when animation is paused.

Since: 0.1

signal stopped

void stopped()

Signal emitted when animation stops.

Since: 0.1

signal reversed

void reversed()

Signal emitted when animation reverses direction.

Since: 0.1

signal finished

void finished()

Signal emitted when animation finishes.

Since: 0.1

signal progressChanged

void progressChanged(
    float progress
)

Signal emitted when animation progress changes.

Parameters:

  • progress Current progress value (0.0 to 1.0).

Since: 0.1

Public Functions Documentation

function ICFAbstractAnimation

explicit ICFAbstractAnimation(
    QObject * parent =nullptr
)

function start

virtual void start(
    Direction dir =Direction::Forward
) =0

Starts the animation in the specified direction.

Parameters:

  • dir Direction to play the animation (default: Forward).

Exceptions:

  • None

Since: 0.1

Note: If already running, this may restart the animation.

Warning: None

Reimplemented by: cf::ui::components::material::CFMaterialFadeAnimation::start, cf::ui::components::material::CFMaterialPropertyAnimation::start, cf::ui::components::material::CFMaterialScaleAnimation::start, cf::ui::components::material::CFMaterialSlideAnimation::start

function pause

virtual void pause() =0

Pauses the animation.

Exceptions:

  • None

Since: 0.1

Note: Does nothing if the animation is not running.

Warning: None

Reimplemented by: cf::ui::components::material::CFMaterialFadeAnimation::pause, cf::ui::components::material::CFMaterialPropertyAnimation::pause, cf::ui::components::material::CFMaterialScaleAnimation::pause, cf::ui::components::material::CFMaterialSlideAnimation::pause

function stop

virtual void stop() =0

Stops the animation and resets to initial state.

Exceptions:

  • None

Since: 0.1

Note: Emits the stopped signal.

Warning: None

Reimplemented by: cf::ui::components::material::CFMaterialFadeAnimation::stop, cf::ui::components::material::CFMaterialPropertyAnimation::stop, cf::ui::components::material::CFMaterialScaleAnimation::stop, cf::ui::components::material::CFMaterialSlideAnimation::stop

function reverse

virtual void reverse() =0

Reverses the animation direction.

Exceptions:

  • None

Since: 0.1

Note: Emits the reversed signal.

Warning: None

Reimplemented by: cf::ui::components::material::CFMaterialFadeAnimation::reverse, cf::ui::components::material::CFMaterialPropertyAnimation::reverse, cf::ui::components::material::CFMaterialScaleAnimation::reverse, cf::ui::components::material::CFMaterialSlideAnimation::reverse

Stops the current session and plays in opposite direction.

function tick

virtual bool tick(
    int dt
) =0

Updates the animation state.

Parameters:

  • dt Time interval since the last call (milliseconds).

Exceptions:

  • None

Return: true if animation continues, false if finished.

Since: 0.1

Note: Implementations should update m_progress and apply the interpolated value to the target.

Warning: None

Reimplemented by: cf::ui::components::material::CFMaterialFadeAnimation::tick, cf::ui::components::material::CFMaterialPropertyAnimation::tick, cf::ui::components::material::CFMaterialScaleAnimation::tick, cf::ui::components::material::CFMaterialSlideAnimation::tick, cf::ui::components::ICFSpringAnimation::tick

Called every frame by the animator. Subclasses implement specific interpolation logic.

function GetWeakPtr

virtual cf::WeakPtr< ICFAbstractAnimation > GetWeakPtr() =0

Gets a weak pointer to this animation.

Exceptions:

  • None

Return: WeakPtr to this animation.

Since: 0.1

Note: None

Warning: None

Reimplemented by: cf::ui::components::material::CFMaterialFadeAnimation::GetWeakPtr, cf::ui::components::material::CFMaterialPropertyAnimation::GetWeakPtr, cf::ui::components::material::CFMaterialScaleAnimation::GetWeakPtr, cf::ui::components::material::CFMaterialSlideAnimation::GetWeakPtr

Each concrete animation class must implement this using its WeakPtrFactory.

function getEnabled

inline bool getEnabled() const

Gets the enabled state of the animation.

Exceptions:

  • None

Return: true if animation is enabled, false otherwise.

Since: 0.1

Note: None

Warning: None

function setTargetFps

void setTargetFps(
    float fps
)

Set the target FPS for this animation.

Parameters:

  • fps Target frames per second (e.g., 60.0f).

Exceptions:

  • None

Since: 0.1

Note: Default is 60.0f. Takes effect on the next animation start.

Warning: None

Sets the desired frame rate for this animation's timer updates. This affects the tick interval for this animation instance.

animation->setTargetFps(30.0f);  // 30 FPS (lower CPU usage)

function calculateInterval

int calculateInterval() const

Calculate the timer interval based on target FPS.

Exceptions:

  • None

Return: Timer interval in milliseconds.

Since: 0.1

Note: None

Warning: None

Returns the interval in milliseconds for the timer based on the current target FPS setting.

Protected Functions Documentation

function setEnabled

inline void setEnabled(
    bool enabled
)

Sets the enabled state of the animation.

Parameters:

  • enabled true to enable, false to disable.

Exceptions:

  • None

Since: 0.1

Note: None

Warning: None

Protected Attributes Documentation

variable driven_internal_timer

QTimer * driven_internal_timer {nullptr};

variable m_progress

float m_progress = 0.0f;

variable m_state

State m_state = State::Idle;

variable targetFps_

float targetFps_ = 60.0f;

Target FPS for this animation (default 60.0f)

Friends

friend ICFAnimationManagerFactory

friend class ICFAnimationManagerFactory(
    ICFAnimationManagerFactory 
);

Updated on 2026-03-09 at 10:14:00 +0000