1 | // Copyright (C) 2020 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #ifndef QSTYLEANIMATION_P_H |
5 | #define QSTYLEANIMATION_P_H |
6 | |
7 | #include <QtWidgets/private/qtwidgetsglobal_p.h> |
8 | #include "qabstractanimation.h" |
9 | #include "qdatetime.h" |
10 | #include "qimage.h" |
11 | |
12 | QT_REQUIRE_CONFIG(animation); |
13 | |
14 | QT_BEGIN_NAMESPACE |
15 | |
16 | // |
17 | // W A R N I N G |
18 | // ------------- |
19 | // |
20 | // This file is not part of the Qt API. It exists for the convenience of |
21 | // qcommonstyle.cpp. This header file may change from version to version |
22 | // without notice, or even be removed. |
23 | // |
24 | // We mean it. |
25 | // |
26 | |
27 | class Q_WIDGETS_EXPORT QStyleAnimation : public QAbstractAnimation |
28 | { |
29 | Q_OBJECT |
30 | |
31 | public: |
32 | QStyleAnimation(QObject *target); |
33 | virtual ~QStyleAnimation(); |
34 | |
35 | QObject *target() const; |
36 | |
37 | int duration() const override; |
38 | void setDuration(int duration); |
39 | |
40 | int delay() const; |
41 | void setDelay(int delay); |
42 | |
43 | QTime startTime() const; |
44 | void setStartTime(QTime time); |
45 | |
46 | enum FrameRate { |
47 | DefaultFps, |
48 | SixtyFps, |
49 | ThirtyFps, |
50 | TwentyFps, |
51 | FifteenFps |
52 | }; |
53 | |
54 | FrameRate frameRate() const; |
55 | void setFrameRate(FrameRate fps); |
56 | |
57 | void updateTarget(); |
58 | |
59 | public Q_SLOTS: |
60 | void start(); |
61 | |
62 | protected: |
63 | virtual bool isUpdateNeeded() const; |
64 | virtual void updateCurrentTime(int time) override; |
65 | |
66 | private: |
67 | int _delay; |
68 | int _duration; |
69 | QTime _startTime; |
70 | FrameRate _fps; |
71 | int _skip; |
72 | }; |
73 | |
74 | class Q_WIDGETS_EXPORT QProgressStyleAnimation : public QStyleAnimation |
75 | { |
76 | Q_OBJECT |
77 | |
78 | public: |
79 | QProgressStyleAnimation(int speed, QObject *target); |
80 | |
81 | int animationStep() const; |
82 | int progressStep(int width) const; |
83 | |
84 | int speed() const; |
85 | void setSpeed(int speed); |
86 | |
87 | protected: |
88 | bool isUpdateNeeded() const override; |
89 | |
90 | private: |
91 | int _speed; |
92 | mutable int _step; |
93 | }; |
94 | |
95 | class Q_WIDGETS_EXPORT QNumberStyleAnimation : public QStyleAnimation |
96 | { |
97 | Q_OBJECT |
98 | |
99 | public: |
100 | QNumberStyleAnimation(QObject *target); |
101 | |
102 | qreal startValue() const; |
103 | void setStartValue(qreal value); |
104 | |
105 | qreal endValue() const; |
106 | void setEndValue(qreal value); |
107 | |
108 | qreal currentValue() const; |
109 | |
110 | protected: |
111 | bool isUpdateNeeded() const override; |
112 | |
113 | private: |
114 | qreal _start; |
115 | qreal _end; |
116 | mutable qreal _prev; |
117 | }; |
118 | |
119 | class Q_WIDGETS_EXPORT QBlendStyleAnimation : public QStyleAnimation |
120 | { |
121 | Q_OBJECT |
122 | |
123 | public: |
124 | enum Type { Transition, Pulse }; |
125 | |
126 | QBlendStyleAnimation(Type type, QObject *target); |
127 | |
128 | QImage startImage() const; |
129 | void setStartImage(const QImage& image); |
130 | |
131 | QImage endImage() const; |
132 | void setEndImage(const QImage& image); |
133 | |
134 | QImage currentImage() const; |
135 | |
136 | protected: |
137 | virtual void updateCurrentTime(int time) override; |
138 | |
139 | private: |
140 | Type _type; |
141 | QImage _start; |
142 | QImage _end; |
143 | QImage _current; |
144 | }; |
145 | |
146 | class Q_WIDGETS_EXPORT QScrollbarStyleAnimation : public QNumberStyleAnimation |
147 | { |
148 | Q_OBJECT |
149 | |
150 | public: |
151 | enum Mode { Activating, Deactivating }; |
152 | |
153 | QScrollbarStyleAnimation(Mode mode, QObject *target); |
154 | |
155 | Mode mode() const; |
156 | |
157 | bool wasActive() const; |
158 | void setActive(bool active); |
159 | |
160 | private slots: |
161 | void updateCurrentTime(int time) override; |
162 | |
163 | private: |
164 | Mode _mode; |
165 | bool _active; |
166 | }; |
167 | |
168 | QT_END_NAMESPACE |
169 | |
170 | #endif // QSTYLEANIMATION_P_H |
171 | |