1/****************************************************************************
2**
3** Copyright (C) 2020 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the QtWidgets module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#ifndef QSTYLEANIMATION_P_H
41#define QSTYLEANIMATION_P_H
42
43#include <QtWidgets/private/qtwidgetsglobal_p.h>
44#include "qabstractanimation.h"
45#include "qdatetime.h"
46#include "qimage.h"
47
48QT_REQUIRE_CONFIG(animation);
49
50QT_BEGIN_NAMESPACE
51
52//
53// W A R N I N G
54// -------------
55//
56// This file is not part of the Qt API. It exists for the convenience of
57// qcommonstyle.cpp. This header file may change from version to version
58// without notice, or even be removed.
59//
60// We mean it.
61//
62
63class Q_WIDGETS_EXPORT QStyleAnimation : public QAbstractAnimation
64{
65 Q_OBJECT
66
67public:
68 QStyleAnimation(QObject *target);
69 virtual ~QStyleAnimation();
70
71 QObject *target() const;
72
73 int duration() const override;
74 void setDuration(int duration);
75
76 int delay() const;
77 void setDelay(int delay);
78
79 QTime startTime() const;
80 void setStartTime(QTime time);
81
82 enum FrameRate {
83 DefaultFps,
84 SixtyFps,
85 ThirtyFps,
86 TwentyFps,
87 FifteenFps
88 };
89
90 FrameRate frameRate() const;
91 void setFrameRate(FrameRate fps);
92
93 void updateTarget();
94
95public Q_SLOTS:
96 void start();
97
98protected:
99 virtual bool isUpdateNeeded() const;
100 virtual void updateCurrentTime(int time) override;
101
102private:
103 int _delay;
104 int _duration;
105 QTime _startTime;
106 FrameRate _fps;
107 int _skip;
108};
109
110class Q_WIDGETS_EXPORT QProgressStyleAnimation : public QStyleAnimation
111{
112 Q_OBJECT
113
114public:
115 QProgressStyleAnimation(int speed, QObject *target);
116
117 int animationStep() const;
118 int progressStep(int width) const;
119
120 int speed() const;
121 void setSpeed(int speed);
122
123protected:
124 bool isUpdateNeeded() const override;
125
126private:
127 int _speed;
128 mutable int _step;
129};
130
131class Q_WIDGETS_EXPORT QNumberStyleAnimation : public QStyleAnimation
132{
133 Q_OBJECT
134
135public:
136 QNumberStyleAnimation(QObject *target);
137
138 qreal startValue() const;
139 void setStartValue(qreal value);
140
141 qreal endValue() const;
142 void setEndValue(qreal value);
143
144 qreal currentValue() const;
145
146protected:
147 bool isUpdateNeeded() const override;
148
149private:
150 qreal _start;
151 qreal _end;
152 mutable qreal _prev;
153};
154
155class Q_WIDGETS_EXPORT QBlendStyleAnimation : public QStyleAnimation
156{
157 Q_OBJECT
158
159public:
160 enum Type { Transition, Pulse };
161
162 QBlendStyleAnimation(Type type, QObject *target);
163
164 QImage startImage() const;
165 void setStartImage(const QImage& image);
166
167 QImage endImage() const;
168 void setEndImage(const QImage& image);
169
170 QImage currentImage() const;
171
172protected:
173 virtual void updateCurrentTime(int time) override;
174
175private:
176 Type _type;
177 QImage _start;
178 QImage _end;
179 QImage _current;
180};
181
182class Q_WIDGETS_EXPORT QScrollbarStyleAnimation : public QNumberStyleAnimation
183{
184 Q_OBJECT
185
186public:
187 enum Mode { Activating, Deactivating };
188
189 QScrollbarStyleAnimation(Mode mode, QObject *target);
190
191 Mode mode() const;
192
193 bool wasActive() const;
194 void setActive(bool active);
195
196private slots:
197 void updateCurrentTime(int time) override;
198
199private:
200 Mode _mode;
201 bool _active;
202};
203
204QT_END_NAMESPACE
205
206#endif // QSTYLEANIMATION_P_H
207