跳转至

cf::ui::components::ICFAnimationManagerFactory

Animation Factory Manager Interface. More...

#include <animation_factory_manager.h>

Inherits from QObject

Inherited by cf::ui::components::material::CFMaterialAnimationFactory

Public Types

Name
enum class RegisteredResult { OK, DUP_NAME, UNSUPPORT_TYPE}
Registration result enumeration.

Public Signals

Name
void animationRegistered(constQString & name)
Signal emitted when an animation is registered.
void animationEnabledChanged(constQString & name, bool enabled)
Signal emitted when an animation's enabled state changes.

Public Functions

Name
ICFAnimationManagerFactory(QObject * parent)
Constructor with parent.
~ICFAnimationManagerFactory() override =default
Virtual destructor.
virtual cf::WeakPtr< ICFAnimationManagerFactory > GetWeakPtr() =0
virtual RegisteredResult registerOneAnimation(constQString & name, constQString & type) =0
Register an animation type by name.
virtual RegisteredResult registerAnimationCreator(constQString & name, AnimationCreator creator) =0
Register an animation with a creator function.
virtual cf::WeakPtr< ICFAbstractAnimation > getAnimation(constchar * name) =0
Get or create an animation by name.
void setTargetFps(constfloat fps)
Set the target FPS for animations.
void setTargetEnabled(constQString & which, constbool enabled)
Set enabled state for a specific animation.
bool targetEnabled(constQString & which)
Check if a specific animation is enabled.
virtual void setEnabledAll(bool enabled) =0
Set enabled state for all animations.
virtual bool isAllEnabled() =0
Check if all animations are enabled.

Detailed Description

class cf::ui::components::ICFAnimationManagerFactory;

Animation Factory Manager Interface.

Since: 0.1

Note: Implementations should be thread-safe for concurrent reads.

Warning: Destroying the manager invalidates all WeakPtr references.

Manages creation and lifecycle of animations with support for:

  • Token-based animation lookup (e.g., "md.animation.fadeIn")
  • Type-safe animation registration
  • Global and per-animation enable/disable
  • WeakPtr ownership model for safe access

Animations are owned by the manager and accessed via WeakPtr. This ensures proper lifecycle management and prevents dangling pointers when the manager is destroyed.

// Example usage with MaterialAnimationFactory
MaterialAnimationFactory factory(theme);
auto anim = factory.getAnimation("md.animation.fadeIn");
if (anim) {
    anim->start();
}

Public Types Documentation

enum RegisteredResult

Enumerator Value Description
OK Registration successful.
DUP_NAME Animation with this name already exists.
UNSUPPORT_TYPE Animation type is not supported.

Registration result enumeration.

Since: 0.1

Possible results from animation registration operations.

Public Signals Documentation

signal animationRegistered

void animationRegistered(
    constQString & name
)

Signal emitted when an animation is registered.

Parameters:

  • name The name of the registered animation.

Since: 0.1

signal animationEnabledChanged

void animationEnabledChanged(
    constQString & name,
    bool enabled
)

Signal emitted when an animation's enabled state changes.

Parameters:

  • name The name of the animation.
  • enabled The new enabled state.

Since: 0.1

Public Functions Documentation

function ICFAnimationManagerFactory

explicit ICFAnimationManagerFactory(
    QObject * parent
)

Constructor with parent.

Parameters:

  • parent QObject parent.

Exceptions:

  • None

Since: 0.1

Note: None

Warning: None

function ~ICFAnimationManagerFactory

~ICFAnimationManagerFactory() override =default

Virtual destructor.

Since: 0.1

function GetWeakPtr

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

Reimplemented by: cf::ui::components::material::CFMaterialAnimationFactory::GetWeakPtr

function registerOneAnimation

virtual RegisteredResult registerOneAnimation(
    constQString & name,
    constQString & type
) =0

Register an animation type by name.

Parameters:

  • name Unique name for the animation (e.g., "fadeIn").
  • type Animation type identifier (e.g., "fade", "slide").

Exceptions:

  • None

Return: Registration result indicating success or failure reason.

Since: 0.1

Note: None

Warning: None

Reimplemented by: cf::ui::components::material::CFMaterialAnimationFactory::registerOneAnimation

Associates a name with an animation type for later retrieval. The type string is used to determine which animation class to instantiate.

manager->registerOneAnimation("buttonPress", "fade");

function registerAnimationCreator

virtual RegisteredResult registerAnimationCreator(
    constQString & name,
    AnimationCreator creator
) =0

Register an animation with a creator function.

Parameters:

  • name Unique name for the animation.
  • creator Function that creates the animation instance.

Exceptions:

  • None

Return: Registration result indicating success or failure reason.

Since: 0.1

Note: None

Warning: None

Reimplemented by: cf::ui::components::material::CFMaterialAnimationFactory::registerAnimationCreator

Associates a name with a function that creates animation instances. This provides type-safe registration for custom animation types.

manager->registerAnimationCreator("customFade",
    [](QObject* parent) {
        return new CFMaterialFadeAnimation(motionSpec, parent);
    });

function getAnimation

virtual cf::WeakPtr< ICFAbstractAnimation > getAnimation(
    constchar * name
) =0

Get or create an animation by name.

Parameters:

  • name Animation name or token.

Exceptions:

  • None

Return: WeakPtr to the animation, or invalid WeakPtr if not found.

Since: 0.1

Note: The returned WeakPtr may become invalid if the manager is destroyed. Always check validity before use.

Warning: The manager owns the animation; do not delete it manually.

Reimplemented by: cf::ui::components::material::CFMaterialAnimationFactory::getAnimation

Retrieves an existing animation or creates a new one based on the registered name/token.

Supports both custom registered names and Material Design tokens (e.g., "md.animation.fadeIn").

auto anim = manager->getAnimation("md.animation.fadeIn");
if (anim) {
    anim->start();
}

function setTargetFps

void setTargetFps(
    constfloat fps
)

Set the target FPS for animations.

Parameters:

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

Exceptions:

  • None

Since: 0.1

Note: None

Warning: None

Sets the desired frame rate for animation updates. This affects the tick interval for all animations.

manager->setTargetFps(60.0f);  // 60 FPS

function setTargetEnabled

void setTargetEnabled(
    constQString & which,
    constbool enabled
)

Set enabled state for a specific animation.

Parameters:

  • which Animation name.
  • enabled true to enable, false to disable.

Exceptions:

  • None

Since: 0.1

Note: None

Warning: None

Controls whether a specific animation is allowed to run. When disabled, getAnimation() returns invalid WeakPtr.

manager->setTargetEnabled("md.animation.fadeIn", false);

function targetEnabled

bool targetEnabled(
    constQString & which
)

Check if a specific animation is enabled.

Parameters:

  • which Animation name.

Exceptions:

  • None

Return: true if enabled, false otherwise.

Since: 0.1

Note: None

Warning: None

function setEnabledAll

virtual void setEnabledAll(
    bool enabled
) =0

Set enabled state for all animations.

Parameters:

  • enabled true to enable all, false to disable all.

Exceptions:

  • None

Since: 0.1

Note: Existing running animations continue until completion.

Warning: None

Reimplemented by: cf::ui::components::material::CFMaterialAnimationFactory::setEnabledAll

When disabled, getAnimation() returns invalid WeakPtr for all animations. Existing running animations continue until completion.

// Disable all animations during heavy processing
manager->setEnabledAll(false);
// ... do heavy work ...
manager->setEnabledAll(true);

function isAllEnabled

virtual bool isAllEnabled() =0

Check if all animations are enabled.

Exceptions:

  • None

Return: true if all animations are enabled, false otherwise.

Since: 0.1

Note: None

Warning: None

Reimplemented by: cf::ui::components::material::CFMaterialAnimationFactory::isAllEnabled


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