跳转至

cf::ui::components::material::CFMaterialScaleAnimation

Material Design 3 Scale Animation. More...

#include <cfmaterial_scale_animation.h>

Inherits from cf::ui::components::ICFTimingAnimation, cf::ui::components::ICFAbstractAnimation, QObject

Public Functions

Name
CFMaterialScaleAnimation(cf::ui::core::IMotionSpec * spec, QObject * parent =nullptr)
Constructor with motion spec.
~CFMaterialScaleAnimation() override
Destructor.
CFMaterialScaleAnimation(constCFMaterialScaleAnimation & ) =delete
CFMaterialScaleAnimation & operator=(constCFMaterialScaleAnimation & ) =delete
CFMaterialScaleAnimation(CFMaterialScaleAnimation && ) =delete
CFMaterialScaleAnimation & operator=(CFMaterialScaleAnimation && ) =delete
virtual void start(Direction dir =Direction::Forward) override
Start the scale animation.
virtual void pause() override
Pause the animation.
virtual void stop() override
Stop the animation and reset to initial state.
virtual void reverse() override
Reverse the animation direction.
virtual bool tick(int dt) override
Update animation state.
virtual float currentValue() const override
Get the current scale value.
void setTargetWidget(QWidget * widget)
Set the target widget for the scale animation.
QWidget * targetWidget() const
Get the target widget.
void setScaleFromCenter(bool center)
Set whether to scale from center.
bool scaleFromCenter() const
Check if scaling from center.
virtual cf::WeakPtr< ICFAbstractAnimation > GetWeakPtr() override
Get a weak pointer to this animation.

Additional inherited members

Public Functions inherited from cf::ui::components::ICFTimingAnimation

Name
ICFTimingAnimation(cf::ui::core::IMotionSpec * spec, QObject * parent =nullptr)
Constructor with motion specification.
virtual void setRange(float from, float to)
Sets the value range for the animation.

Protected Attributes inherited from cf::ui::components::ICFTimingAnimation

Name
cf::ui::core::IMotionSpec * motion_spec_
float m_from
float m_to
int m_elapsed

Public Types inherited from cf::ui::components::ICFAbstractAnimation

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

Public Signals inherited from cf::ui::components::ICFAbstractAnimation

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 inherited from cf::ui::components::ICFAbstractAnimation

Name
ICFAbstractAnimation(QObject * parent =nullptr)
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 inherited from cf::ui::components::ICFAbstractAnimation

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

Protected Attributes inherited from cf::ui::components::ICFAbstractAnimation

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

Friends inherited from cf::ui::components::ICFAbstractAnimation

Name
class ICFAnimationManagerFactory(ICFAnimationManagerFactory )

Detailed Description

class cf::ui::components::material::CFMaterialScaleAnimation;

Material Design 3 Scale Animation.

Since: 0.1

Note: The target widget must remain valid during animation.

Warning: Changing the target widget during animation may cause issues.

Animates the scale of a widget from a start value to an end value following Material Design 3 motion specifications.

The animation uses:

  • Duration from the MotionSpec token
  • Easing curve from the MotionSpec token
  • Optional delay before starting

Scale is applied via QWidget::setGeometry() with adjusted size and position to maintain the widget's center point.

// Create a scale-up animation
auto& motionSpec = theme.motion_spec();
auto scaleAnim = std::make_unique<CFMaterialScaleAnimation>(
    cf::WeakPtr<cf::ui::core::IMotionSpec>(&motionSpec),
    this);
scaleAnim->setRange(0.8f, 1.0f);  // Scale from 80% to 100%
scaleAnim->setTargetWidget(myWidget);
scaleAnim->start();

Public Functions Documentation

function CFMaterialScaleAnimation

explicit CFMaterialScaleAnimation(
    cf::ui::core::IMotionSpec * spec,
    QObject * parent =nullptr
)

Constructor with motion spec.

Parameters:

  • spec Raw pointer to the motion spec for timing/easing. Must remain valid for the lifetime of this animation.
  • parent QObject parent.

Exceptions:

  • None

Since: 0.1

Note: None

Warning: None

function ~CFMaterialScaleAnimation

~CFMaterialScaleAnimation() override

Destructor.

Since: 0.1

function CFMaterialScaleAnimation

CFMaterialScaleAnimation(
    constCFMaterialScaleAnimation & 
) =delete

function operator=

CFMaterialScaleAnimation & operator=(
    constCFMaterialScaleAnimation & 
) =delete

function CFMaterialScaleAnimation

CFMaterialScaleAnimation(
    CFMaterialScaleAnimation && 
) =delete

function operator=

CFMaterialScaleAnimation & operator=(
    CFMaterialScaleAnimation && 
) =delete

function start

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

Start the scale animation.

Parameters:

  • dir Direction to play.

Exceptions:

  • None

Since: 0.1

Note: None

Warning: None

Reimplements: cf::ui::components::ICFAbstractAnimation::start

function pause

virtual void pause() override

Pause the animation.

Exceptions:

  • None

Since: 0.1

Note: None

Warning: None

Reimplements: cf::ui::components::ICFAbstractAnimation::pause

function stop

virtual void stop() override

Stop the animation and reset to initial state.

Exceptions:

  • None

Since: 0.1

Note: None

Warning: None

Reimplements: cf::ui::components::ICFAbstractAnimation::stop

function reverse

virtual void reverse() override

Reverse the animation direction.

Exceptions:

  • None

Since: 0.1

Note: None

Warning: None

Reimplements: cf::ui::components::ICFAbstractAnimation::reverse

function tick

virtual bool tick(
    int dt
) override

Update animation state.

Parameters:

  • dt Time elapsed since last tick (milliseconds).

Exceptions:

  • None

Return: true if animation is still running, false if finished.

Since: 0.1

Note: None

Warning: None

Reimplements: cf::ui::components::ICFAbstractAnimation::tick

function currentValue

inline virtual float currentValue() const override

Get the current scale value.

Return: Current scale (1.0 = normal size).

Since: 0.1

Reimplements: cf::ui::components::ICFTimingAnimation::currentValue

function setTargetWidget

void setTargetWidget(
    QWidget * widget
)

Set the target widget for the scale animation.

Parameters:

  • widget Target widget (may be nullptr).

Exceptions:

  • None

Since: 0.1

Note: None

Warning: None

function targetWidget

inline QWidget * targetWidget() const

Get the target widget.

Exceptions:

  • None

Return: Target widget, or nullptr if not set.

Since: 0.1

Note: None

Warning: None

function setScaleFromCenter

inline void setScaleFromCenter(
    bool center
)

Set whether to scale from center.

Parameters:

  • center If true, widget scales from its center point.

Exceptions:

  • None

Since: 0.1

Note: None

Warning: None

function scaleFromCenter

inline bool scaleFromCenter() const

Check if scaling from center.

Return: true if scaling from center.

Since: 0.1

function GetWeakPtr

inline virtual cf::WeakPtr< ICFAbstractAnimation > GetWeakPtr() override

Get a weak pointer to this animation.

Return: WeakPtr that can be used to safely access this animation.

Since: 0.1

Reimplements: cf::ui::components::ICFAbstractAnimation::GetWeakPtr


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