ui/components/animation.h¶
Abstract Animation Interface. More...
Namespaces¶
| Name |
|---|
| cf |
| cf::ui |
| cf::ui::components |
Classes¶
| Name | |
|---|---|
| class | cf::ui::components::ICFAbstractAnimation Abstract animation base class. |
Detailed Description¶
Abstract Animation Interface.
Author: Charliechen114514 (chengh1922@mails.jlu.edu.cn)
Version: 0.1
Date: 2026-02-28
Copyright: Copyright © 2026
Defines the base animation interface for all animation types. Provides common animation states, direction control, and lifecycle methods.
Source code¶
#pragma once
#include "base/weak_ptr/weak_ptr.h"
#include "export.h"
#include <QObject>
#include <QTimer>
namespace cf::ui::components {
class CF_UI_EXPORT ICFAbstractAnimation : public QObject {
Q_OBJECT
public:
friend class ICFAnimationManagerFactory;
explicit ICFAbstractAnimation(QObject* parent = nullptr);
enum class State { Idle, Running, Paused, Finished };
Q_ENUM(State)
enum class Direction { Forward, Backward };
Q_ENUM(Direction)
virtual void start(Direction dir = Direction::Forward) = 0;
virtual void pause() = 0;
virtual void stop() = 0;
virtual void reverse() = 0;
virtual bool tick(int dt) = 0;
virtual cf::WeakPtr<ICFAbstractAnimation> GetWeakPtr() = 0;
bool getEnabled() const { return enabled; }
void setTargetFps(float fps);
int calculateInterval() const;
signals:
void started();
void paused();
void stopped();
void reversed();
void finished();
void progressChanged(float progress);
protected:
QTimer* driven_internal_timer{nullptr};
float m_progress = 0.0f;
State m_state = State::Idle;
float targetFps_ = 60.0f;
void setEnabled(bool enabled) { this->enabled = enabled; }
private:
bool enabled;
};
} // namespace cf::ui::components
Updated on 2026-03-09 at 10:14:01 +0000