diff options
| author | TrickyLeifa <date.epoch@gmail.com> | 2024-05-22 22:10:29 +0200 |
|---|---|---|
| committer | TrickyLeifa <date.epoch@gmail.com> | 2024-05-22 22:10:29 +0200 |
| commit | 695d51dbfe858d877408de78b424c1af8fc30e3a (patch) | |
| tree | 8add1fce52295ff7acd19856d6cd19f1ce2b3928 /src/animationloader.h | |
| parent | 137a2d3a04bb0381d1923b1a9530d1cdd9872e88 (diff) | |
Complete AOLayer reimplementation, ...
* Complete AOLayer reimplementation
* Reimplemented sliding as well.
Diffstat (limited to 'src/animationloader.h')
| -rw-r--r-- | src/animationloader.h | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/animationloader.h b/src/animationloader.h new file mode 100644 index 00000000..a3a10367 --- /dev/null +++ b/src/animationloader.h @@ -0,0 +1,55 @@ +#pragma once + +#include <QFuture> +#include <QImageReader> +#include <QMutex> +#include <QObject> +#include <QPixmap> +#include <QString> +#include <QWaitCondition> + +#include <atomic> + +namespace kal +{ +class AnimationFrame +{ +public: + QPixmap texture; + int duration = 0; +}; + +class AnimationLoader +{ + Q_DISABLE_COPY_MOVE(AnimationLoader) + +public: + explicit AnimationLoader(QThreadPool *threadPool); + virtual ~AnimationLoader(); + + QString loadedFileName() const; + void load(const QString &fileName); + void stopLoading(); + + QSize size(); + + int frameCount(); + AnimationFrame frame(int frameNumber); + + int loopCount(); + +private: + QThreadPool *m_thread_pool; + QString m_file_name; + QSize m_size; + int m_frame_count = 0; + int m_loop_count = -1; + QList<AnimationFrame> m_frames; + QFuture<void> m_task; + std::atomic_bool m_exit_task = false; + QMutex m_task_lock; + QWaitCondition m_task_signal; + + void populateVector(QImageReader *reader); +}; +} // namespace kal |
