2017-07-21 18:21:34 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
|
|
|
* This file may be used under the terms of the QSkinny License, Version 1.0
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef QSK_ANIMATOR_H
|
|
|
|
#define QSK_ANIMATOR_H
|
|
|
|
|
|
|
|
#include "QskGlobal.h"
|
2018-08-03 08:30:23 +02:00
|
|
|
|
2018-07-19 14:10:48 +02:00
|
|
|
#include <qeasingcurve.h>
|
|
|
|
#include <qobjectdefs.h>
|
2017-07-21 18:21:34 +02:00
|
|
|
|
|
|
|
class QQuickWindow;
|
|
|
|
class QObject;
|
|
|
|
class QDebug;
|
|
|
|
|
|
|
|
class QSK_EXPORT QskAnimator
|
|
|
|
{
|
2018-08-03 08:15:28 +02:00
|
|
|
public:
|
2017-07-21 18:21:34 +02:00
|
|
|
QskAnimator();
|
|
|
|
virtual ~QskAnimator();
|
|
|
|
|
|
|
|
QQuickWindow* window() const;
|
|
|
|
void setWindow( QQuickWindow* );
|
|
|
|
|
|
|
|
void setEasingCurve( QEasingCurve::Type type );
|
|
|
|
void setEasingCurve( const QEasingCurve& );
|
|
|
|
|
|
|
|
const QEasingCurve& easingCurve() const;
|
|
|
|
|
2020-08-09 10:43:52 +02:00
|
|
|
void setAutoRepeat( bool );
|
|
|
|
bool autoRepeat() const;
|
|
|
|
|
2017-07-21 18:21:34 +02:00
|
|
|
void setDuration( int ms );
|
|
|
|
int duration() const;
|
|
|
|
|
|
|
|
bool isRunning() const;
|
2020-08-09 10:43:52 +02:00
|
|
|
qint64 elapsed() const;
|
2017-07-21 18:21:34 +02:00
|
|
|
|
|
|
|
void start();
|
|
|
|
void stop();
|
|
|
|
void update();
|
|
|
|
|
2018-08-03 08:15:28 +02:00
|
|
|
static QMetaObject::Connection addCleanupHandler(
|
|
|
|
QObject* receiver, const char* method,
|
|
|
|
Qt::ConnectionType type = Qt::AutoConnection );
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2018-08-03 08:15:28 +02:00
|
|
|
static QMetaObject::Connection addAdvanceHandler(
|
|
|
|
QObject* receiver, const char* method,
|
|
|
|
Qt::ConnectionType type = Qt::AutoConnection );
|
2017-07-21 18:21:34 +02:00
|
|
|
|
|
|
|
#ifndef QT_NO_DEBUG_STREAM
|
|
|
|
static void debugStatistics( QDebug );
|
|
|
|
#endif
|
|
|
|
|
2018-08-03 08:15:28 +02:00
|
|
|
protected:
|
2017-07-21 18:21:34 +02:00
|
|
|
virtual void setup();
|
|
|
|
virtual void advance( qreal value ) = 0;
|
|
|
|
virtual void done();
|
|
|
|
|
2018-08-03 08:15:28 +02:00
|
|
|
private:
|
2017-07-21 18:21:34 +02:00
|
|
|
QQuickWindow* m_window;
|
|
|
|
|
|
|
|
int m_duration;
|
|
|
|
QEasingCurve m_easingCurve;
|
|
|
|
qint64 m_startTime; // quint32 might be enough
|
2020-08-09 10:43:52 +02:00
|
|
|
|
|
|
|
bool m_autoRepeat = false;
|
2017-07-21 18:21:34 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
inline bool QskAnimator::isRunning() const
|
|
|
|
{
|
|
|
|
return m_startTime >= 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline int QskAnimator::duration() const
|
|
|
|
{
|
|
|
|
return m_duration;
|
|
|
|
}
|
|
|
|
|
2020-08-09 10:43:52 +02:00
|
|
|
inline bool QskAnimator::autoRepeat() const
|
|
|
|
{
|
|
|
|
return m_autoRepeat;
|
|
|
|
}
|
|
|
|
|
2017-07-21 18:21:34 +02:00
|
|
|
#endif
|