跳转至

cf::ui::components::material::CFMaterialSlideAnimation

Material Design 3 Slide Animation. More...

#include <cfmaterial_slide_animation.h>

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

Public Functions

Name
CFMaterialSlideAnimation(cf::ui::core::IMotionSpec * spec, SlideDirection direction, QObject * parent =nullptr)
Constructor with motion spec and direction.
~CFMaterialSlideAnimation() override
Destructor.
CFMaterialSlideAnimation(constCFMaterialSlideAnimation & ) =delete
CFMaterialSlideAnimation & operator=(constCFMaterialSlideAnimation & ) =delete
CFMaterialSlideAnimation(CFMaterialSlideAnimation && ) =delete
CFMaterialSlideAnimation & operator=(CFMaterialSlideAnimation && ) =delete
virtual void start(Direction dir =Direction::Forward) override
Start the slide 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 offset value.
void setTargetWidget(QWidget * widget)
Set the target widget for the slide animation.
QWidget * targetWidget() const
Get the target widget.
void setDistance(float distance)
Set the slide distance in pixels.
float distance() const
Get the slide distance.
void setDirection(SlideDirection direction)
Set the slide direction.
SlideDirection direction() const
Get the slide direction.
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::CFMaterialSlideAnimation;

Material Design 3 Slide 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 position of a widget from a start offset to an end offset following Material Design 3 motion specifications.

The animation uses:

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

Position is applied via widget movement using setGeometry() or pos(). The original position is stored and restored after animation completion.

// Create a slide-up animation
auto& motionSpec = theme.motion_spec();
auto slideAnim = std::make_unique<CFMaterialSlideAnimation>(
    cf::WeakPtr<cf::ui::core::IMotionSpec>(&motionSpec),
    SlideDirection::Up,
    this);
slideAnim->setDistance(100.0f);  // Slide 100 pixels
slideAnim->setTargetWidget(myWidget);
slideAnim->start();

Public Functions Documentation

function CFMaterialSlideAnimation

explicit CFMaterialSlideAnimation(
    cf::ui::core::IMotionSpec * spec,
    SlideDirection direction,
    QObject * parent =nullptr
)

Constructor with motion spec and direction.

Parameters:

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

Exceptions:

  • None

Since: 0.1

Note: None

Warning: None

function ~CFMaterialSlideAnimation

~CFMaterialSlideAnimation() override

Destructor.

Exceptions:

  • None

Since: 0.1

Note: None

Warning: None

function CFMaterialSlideAnimation

CFMaterialSlideAnimation(
    constCFMaterialSlideAnimation & 
) =delete

function operator=

CFMaterialSlideAnimation & operator=(
    constCFMaterialSlideAnimation & 
) =delete

function CFMaterialSlideAnimation

CFMaterialSlideAnimation(
    CFMaterialSlideAnimation && 
) =delete

function operator=

CFMaterialSlideAnimation & operator=(
    CFMaterialSlideAnimation && 
) =delete

function start

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

Start the slide 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 offset value.

Return: Current offset in pixels.

Since: 0.1

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

function setTargetWidget

void setTargetWidget(
    QWidget * widget
)

Set the target widget for the slide 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 setDistance

inline void setDistance(
    float distance
)

Set the slide distance in pixels.

Parameters:

  • distance Distance to slide in pixels.

Exceptions:

  • None

Since: 0.1

Note: None

Warning: None

function distance

inline float distance() const

Get the slide distance.

Exceptions:

  • None

Return: Distance in pixels.

Since: 0.1

Note: None

Warning: None

function setDirection

inline void setDirection(
    SlideDirection direction
)

Set the slide direction.

Parameters:

  • direction Direction to slide.

Exceptions:

  • None

Since: 0.1

Note: None

Warning: None

function direction

inline SlideDirection direction() const

Get the slide direction.

Return: Current slide direction.

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