qskinny/src/layouts/QskStackBoxAnimator.h

145 lines
3.3 KiB
C
Raw Normal View History

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_STACK_BOX_ANIMATOR_H
#define QSK_STACK_BOX_ANIMATOR_H
2018-08-03 08:15:28 +02:00
#include "QskAnimator.h"
2017-07-21 18:21:34 +02:00
#include "QskNamespace.h"
2018-08-03 08:30:23 +02:00
2018-07-19 14:10:48 +02:00
#include <qobject.h>
2017-07-21 18:21:34 +02:00
class QskStackBox;
class QQuickItem;
2017-07-21 18:21:34 +02:00
class QSK_EXPORT QskStackBoxAnimator : public QObject, public QskAnimator
{
Q_OBJECT
2018-08-03 08:15:28 +02:00
public:
QskStackBoxAnimator( QskStackBox* );
2018-07-31 17:32:25 +02:00
~QskStackBoxAnimator() override;
2017-07-21 18:21:34 +02:00
void setStartIndex( int index );
void setEndIndex( int index );
int startIndex() const;
int endIndex() const;
2022-01-04 13:50:40 +01:00
qreal transientIndex() const;
2018-08-03 08:15:28 +02:00
protected:
2017-07-21 18:21:34 +02:00
QskStackBox* stackBox() const;
QQuickItem* itemAt( int index ) const;
2017-07-21 18:21:34 +02:00
2018-08-03 08:15:28 +02:00
private:
2022-01-04 13:50:40 +01:00
void advance( qreal value ) override final;
virtual void advanceIndex( qreal value ) = 0;
2017-07-21 18:21:34 +02:00
int m_startIndex;
int m_endIndex;
2022-01-04 13:50:40 +01:00
qreal m_transientIndex;
2017-07-21 18:21:34 +02:00
};
class QSK_EXPORT QskStackBoxAnimator1 : public QskStackBoxAnimator
{
Q_OBJECT
Q_PROPERTY( Qt::Orientation orientation READ orientation WRITE setOrientation )
2018-08-03 08:15:28 +02:00
public:
QskStackBoxAnimator1( QskStackBox* );
2018-07-31 17:32:25 +02:00
~QskStackBoxAnimator1() override;
2017-07-21 18:21:34 +02:00
void setOrientation( Qt::Orientation );
Qt::Orientation orientation() const;
2018-08-03 08:15:28 +02:00
protected:
bool eventFilter( QObject*, QEvent* ) override;
2018-07-31 17:32:25 +02:00
void setup() override;
2022-01-04 13:50:40 +01:00
void advanceIndex( qreal value ) override;
2018-07-31 17:32:25 +02:00
void done() override;
2017-07-21 18:21:34 +02:00
2018-08-03 08:15:28 +02:00
private:
qreal m_itemOffset[ 2 ];
2017-07-21 18:21:34 +02:00
Qt::Orientation m_orientation : 2;
Qsk::Direction m_direction : 4;
bool m_isDirty : 1;
2017-07-21 18:21:34 +02:00
bool m_hasClip : 1;
};
2022-07-19 16:50:40 +02:00
class QSK_EXPORT QskStackBoxAnimator2 : public QskStackBoxAnimator
{
Q_OBJECT
Q_PROPERTY( Qt::Orientation orientation READ orientation WRITE setOrientation )
Q_PROPERTY( bool inverted READ isInverted WRITE setInverted )
2022-07-19 16:50:40 +02:00
public:
QskStackBoxAnimator2( QskStackBox* );
~QskStackBoxAnimator2() override;
void setOrientation( Qt::Orientation );
Qt::Orientation orientation() const;
void setInverted( bool );
bool isInverted() const;
2022-07-19 16:50:40 +02:00
protected:
void setup() override;
void advanceIndex( qreal value ) override;
void done() override;
private:
Qt::Orientation m_orientation : 2;
bool m_inverted : 1;
2022-07-19 16:50:40 +02:00
};
2017-07-21 18:21:34 +02:00
class QSK_EXPORT QskStackBoxAnimator3 : public QskStackBoxAnimator
{
Q_OBJECT
2018-08-03 08:15:28 +02:00
public:
QskStackBoxAnimator3( QskStackBox* );
2018-07-31 17:32:25 +02:00
~QskStackBoxAnimator3() override;
2017-07-21 18:21:34 +02:00
2018-08-03 08:15:28 +02:00
protected:
2018-07-31 17:32:25 +02:00
void setup() override;
2022-01-04 13:50:40 +01:00
void advanceIndex( qreal value ) override;
2018-07-31 17:32:25 +02:00
void done() override;
2017-07-21 18:21:34 +02:00
};
2022-08-01 11:28:19 +02:00
class QSK_EXPORT QskStackBoxAnimator4 : public QskStackBoxAnimator
{
Q_OBJECT
Q_PROPERTY( Qt::Orientation orientation READ orientation WRITE setOrientation )
Q_PROPERTY( bool inverted READ isInverted WRITE setInverted )
public:
QskStackBoxAnimator4( QskStackBox* );
~QskStackBoxAnimator4() override;
void setOrientation( Qt::Orientation );
Qt::Orientation orientation() const;
void setInverted( bool );
bool isInverted() const;
protected:
void setup() override;
void advanceIndex( qreal value ) override;
void done() override;
private:
Qt::Orientation m_orientation : 2;
bool m_inverted : 1;
};
2017-07-21 18:21:34 +02:00
#endif