QSkinny 0.8.0
C++/Qt UI toolkit
Loading...
Searching...
No Matches
QskFlickAnimator.h
1/******************************************************************************
2 * QSkinny - Copyright (C) The authors
3 * SPDX-License-Identifier: BSD-3-Clause
4 *****************************************************************************/
5
6#ifndef QSK_FLICK_ANIMATOR_H
7#define QSK_FLICK_ANIMATOR_H
8
9#include "QskAnimator.h"
10
11class QSK_EXPORT QskFlickAnimator : public QskAnimator
12{
13 public:
15 ~QskFlickAnimator() override;
16
17 void setAngle( qreal degrees );
18 qreal angle() const;
19
20 void setVelocity( qreal );
21 qreal velocity() const;
22
23 qreal animatedVelocity() const;
24
25 void flick( qreal degrees, qreal velocity );
26 void accelerate( qreal degrees, qreal velocity );
27
28 protected:
29 void setup() override;
30 void advance( qreal value ) override final;
31 void done() override;
32
33 virtual void translate( qreal dx, qreal dy ) = 0;
34
35 private:
36 qreal m_velocity[ 2 ];
37
38 qreal m_degrees;
39 qreal m_cos;
40 qreal m_sin;
41
42 int m_elapsed;
43};
44
45inline qreal QskFlickAnimator::angle() const
46{
47 return m_degrees;
48}
49
50inline qreal QskFlickAnimator::velocity() const
51{
52 return m_velocity[ 0 ];
53}
54
55inline qreal QskFlickAnimator::animatedVelocity() const
56{
57 return m_velocity[ 1 ];
58}
59
60#endif