qstyleanimation.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/styles/qstyleanimation.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7static const qreal ScrollBarFadeOutDuration = 200.0;-
8static const qreal ScrollBarFadeOutDelay = 450.0;-
9-
10QStyleAnimation::QStyleAnimation(QObject *target) : QAbstractAnimation(target),-
11 _delay(0), _duration(-1), _startTime(QTime::currentTime()), _fps(ThirtyFps), _skip(0)-
12{-
13}
never executed: end of block
0
14-
15QStyleAnimation::~QStyleAnimation()-
16{-
17}-
18-
19QObject *QStyleAnimation::target() const-
20{-
21 return
never executed: return parent();
parent();
never executed: return parent();
0
22}-
23-
24int QStyleAnimation::duration() const-
25{-
26 return
never executed: return _duration;
_duration;
never executed: return _duration;
0
27}-
28-
29void QStyleAnimation::setDuration(int duration)-
30{-
31 _duration = duration;-
32}
never executed: end of block
0
33-
34int QStyleAnimation::delay() const-
35{-
36 return
never executed: return _delay;
_delay;
never executed: return _delay;
0
37}-
38-
39void QStyleAnimation::setDelay(int delay)-
40{-
41 _delay = delay;-
42}
never executed: end of block
0
43-
44QTime QStyleAnimation::startTime() const-
45{-
46 return
never executed: return _startTime;
_startTime;
never executed: return _startTime;
0
47}-
48-
49void QStyleAnimation::setStartTime(const QTime &time)-
50{-
51 _startTime = time;-
52}
never executed: end of block
0
53-
54QStyleAnimation::FrameRate QStyleAnimation::frameRate() const-
55{-
56 return
never executed: return _fps;
_fps;
never executed: return _fps;
0
57}-
58-
59void QStyleAnimation::setFrameRate(FrameRate fps)-
60{-
61 _fps = fps;-
62}
never executed: end of block
0
63-
64void QStyleAnimation::updateTarget()-
65{-
66 QEvent event(QEvent::StyleAnimationUpdate);-
67 event.setAccepted(false);-
68 QCoreApplication::sendEvent(target(), &event);-
69 if (!event.isAccepted()
!event.isAccepted()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
70 stop();
never executed: stop();
0
71}
never executed: end of block
0
72-
73void QStyleAnimation::start()-
74{-
75 _skip = 0;-
76 QAbstractAnimation::start(DeleteWhenStopped);-
77}
never executed: end of block
0
78-
79bool QStyleAnimation::isUpdateNeeded() const-
80{-
81 return
never executed: return currentTime() > _delay;
currentTime() > _delay;
never executed: return currentTime() > _delay;
0
82}-
83-
84void QStyleAnimation::updateCurrentTime(int)-
85{-
86 if (++
++_skip >= _fpsDescription
TRUEnever evaluated
FALSEnever evaluated
_skip >= _fps
++_skip >= _fpsDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
87 _skip = 0;-
88 if (target()
target()Description
TRUEnever evaluated
FALSEnever evaluated
&& isUpdateNeeded()
isUpdateNeeded()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
89 updateTarget();
never executed: updateTarget();
0
90 }
never executed: end of block
0
91}
never executed: end of block
0
92-
93QProgressStyleAnimation::QProgressStyleAnimation(int speed, QObject *target) :-
94 QStyleAnimation(target), _speed(speed), _step(-1)-
95{-
96}
never executed: end of block
0
97-
98int QProgressStyleAnimation::animationStep() const-
99{-
100 return
never executed: return currentTime() / (1000.0 / _speed);
currentTime() / (1000.0 / _speed);
never executed: return currentTime() / (1000.0 / _speed);
0
101}-
102-
103int QProgressStyleAnimation::progressStep(int width) const-
104{-
105 int step = animationStep();-
106 int progress = (step * width / _speed) % width;-
107 if (((
((step * width...dth)) >= widthDescription
TRUEnever evaluated
FALSEnever evaluated
step * width / _speed) % (2 * width)) >= width
((step * width...dth)) >= widthDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
108 progress = width - progress;
never executed: progress = width - progress;
0
109 return
never executed: return progress;
progress;
never executed: return progress;
0
110}-
111-
112int QProgressStyleAnimation::speed() const-
113{-
114 return
never executed: return _speed;
_speed;
never executed: return _speed;
0
115}-
116-
117void QProgressStyleAnimation::setSpeed(int speed)-
118{-
119 _speed = speed;-
120}
never executed: end of block
0
121-
122bool QProgressStyleAnimation::isUpdateNeeded() const-
123{-
124 if (QStyleAnimation::isUpdateNeeded()
QStyleAnimatio...UpdateNeeded()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
125 int current = animationStep();-
126 if (_step == -1
_step == -1Description
TRUEnever evaluated
FALSEnever evaluated
|| _step != current
_step != currentDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
127 {-
128 _step = current;-
129 return
never executed: return true;
true;
never executed: return true;
0
130 }-
131 }
never executed: end of block
0
132 return
never executed: return false;
false;
never executed: return false;
0
133}-
134-
135QNumberStyleAnimation::QNumberStyleAnimation(QObject *target) :-
136 QStyleAnimation(target), _start(0.0), _end(1.0), _prev(0.0)-
137{-
138 setDuration(250);-
139}
never executed: end of block
0
140-
141qreal QNumberStyleAnimation::startValue() const-
142{-
143 return
never executed: return _start;
_start;
never executed: return _start;
0
144}-
145-
146void QNumberStyleAnimation::setStartValue(qreal value)-
147{-
148 _start = value;-
149}
never executed: end of block
0
150-
151qreal QNumberStyleAnimation::endValue() const-
152{-
153 return
never executed: return _end;
_end;
never executed: return _end;
0
154}-
155-
156void QNumberStyleAnimation::setEndValue(qreal value)-
157{-
158 _end = value;-
159}
never executed: end of block
0
160-
161qreal QNumberStyleAnimation::currentValue() const-
162{-
163 qreal step = qreal(currentTime() - delay()) / (duration() - delay());-
164 return
never executed: return _start + qMax(qreal(0), step) * (_end - _start);
_start + qMax(qreal(0), step) * (_end - _start);
never executed: return _start + qMax(qreal(0), step) * (_end - _start);
0
165}-
166-
167bool QNumberStyleAnimation::isUpdateNeeded() const-
168{-
169 if (QStyleAnimation::isUpdateNeeded()
QStyleAnimatio...UpdateNeeded()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
170 qreal current = currentValue();-
171 if (!qFuzzyCompare(_prev, current)
!qFuzzyCompare(_prev, current)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
172 {-
173 _prev = current;-
174 return
never executed: return true;
true;
never executed: return true;
0
175 }-
176 }
never executed: end of block
0
177 return
never executed: return false;
false;
never executed: return false;
0
178}-
179-
180QBlendStyleAnimation::QBlendStyleAnimation(Type type, QObject *target) :-
181 QStyleAnimation(target), _type(type)-
182{-
183 setDuration(250);-
184}
never executed: end of block
0
185-
186QImage QBlendStyleAnimation::startImage() const-
187{-
188 return
never executed: return _start;
_start;
never executed: return _start;
0
189}-
190-
191void QBlendStyleAnimation::setStartImage(const QImage& image)-
192{-
193 _start = image;-
194}
never executed: end of block
0
195-
196QImage QBlendStyleAnimation::endImage() const-
197{-
198 return
never executed: return _end;
_end;
never executed: return _end;
0
199}-
200-
201void QBlendStyleAnimation::setEndImage(const QImage& image)-
202{-
203 _end = image;-
204}
never executed: end of block
0
205-
206QImage QBlendStyleAnimation::currentImage() const-
207{-
208 return
never executed: return _current;
_current;
never executed: return _current;
0
209}-
210static QImage blendedImage(const QImage &start, const QImage &end, float alpha)-
211{-
212 if (start.isNull()
start.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
|| end.isNull()
end.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
213 return
never executed: return QImage();
QImage();
never executed: return QImage();
0
214-
215 QImage blended;-
216 const int a = qRound(alpha*256);-
217 const int ia = 256 - a;-
218 const int sw = start.width();-
219 const int sh = start.height();-
220 const int bpl = start.bytesPerLine();-
221 switch (start.depth()) {-
222 case
never executed: case 32:
32:
never executed: case 32:
0
223 {-
224 blended = QImage(sw, sh, start.format());-
225 blended.setDevicePixelRatio(start.devicePixelRatio());-
226 uchar *mixed_data = blended.bits();-
227 const uchar *back_data = start.bits();-
228 const uchar *front_data = end.bits();-
229 for (int sy = 0; sy < sh
sy < shDescription
TRUEnever evaluated
FALSEnever evaluated
; sy++) {
0
230 quint32* mixed = (quint32*)mixed_data;-
231 const quint32* back = (const quint32*)back_data;-
232 const quint32* front = (const quint32*)front_data;-
233 for (int sx = 0; sx < sw
sx < swDescription
TRUEnever evaluated
FALSEnever evaluated
; sx++) {
0
234 quint32 bp = back[sx];-
235 quint32 fp = front[sx];-
236 mixed[sx] = qRgba ((qRed(bp)*ia + qRed(fp)*a)>>8,-
237 (qGreen(bp)*ia + qGreen(fp)*a)>>8,-
238 (qBlue(bp)*ia + qBlue(fp)*a)>>8,-
239 (qAlpha(bp)*ia + qAlpha(fp)*a)>>8);-
240 }
never executed: end of block
0
241 mixed_data += bpl;-
242 back_data += bpl;-
243 front_data += bpl;-
244 }
never executed: end of block
0
245 }-
246 default
never executed: default:
:
never executed: default:
code before this statement never executed: default:
0
247 break;
never executed: break;
0
248 }-
249 return
never executed: return blended;
blended;
never executed: return blended;
0
250}-
251-
252void QBlendStyleAnimation::updateCurrentTime(int time)-
253{-
254 QStyleAnimation::updateCurrentTime(time);-
255-
256 float alpha = 1.0;-
257 if (duration() > 0
duration() > 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
258 if (_type == Pulse
_type == PulseDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
259 time = time % duration() * 2;-
260 if (time > duration()
time > duration()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
261 time = duration() * 2 - time;
never executed: time = duration() * 2 - time;
0
262 }
never executed: end of block
0
263-
264 alpha = time / static_cast<float>(duration());-
265-
266 if (_type == Transition
_type == TransitionDescription
TRUEnever evaluated
FALSEnever evaluated
&& time > duration()
time > duration()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
267 alpha = 1.0;-
268 stop();-
269 }
never executed: end of block
0
270 }
never executed: end of block
else if (time > 0
time > 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
271 stop();-
272 }
never executed: end of block
0
273-
274 _current = blendedImage(_start, _end, alpha);-
275}
never executed: end of block
0
276-
277QScrollbarStyleAnimation::QScrollbarStyleAnimation(Mode mode, QObject *target) : QNumberStyleAnimation(target), _mode(mode), _active(false)-
278{-
279 switch (mode) {-
280 case
never executed: case Activating:
Activating:
never executed: case Activating:
0
281 setDuration(ScrollBarFadeOutDuration);-
282 setStartValue(0.0);-
283 setEndValue(1.0);-
284 break;
never executed: break;
0
285 case
never executed: case Deactivating:
Deactivating:
never executed: case Deactivating:
0
286 setDuration(ScrollBarFadeOutDelay + ScrollBarFadeOutDuration);-
287 setDelay(ScrollBarFadeOutDelay);-
288 setStartValue(1.0);-
289 setEndValue(0.0);-
290 break;
never executed: break;
0
291 }-
292}
never executed: end of block
0
293-
294QScrollbarStyleAnimation::Mode QScrollbarStyleAnimation::mode() const-
295{-
296 return
never executed: return _mode;
_mode;
never executed: return _mode;
0
297}-
298-
299bool QScrollbarStyleAnimation::wasActive() const-
300{-
301 return
never executed: return _active;
_active;
never executed: return _active;
0
302}-
303-
304void QScrollbarStyleAnimation::setActive(bool active)-
305{-
306 _active = active;-
307}
never executed: end of block
0
308-
309void QScrollbarStyleAnimation::updateCurrentTime(int time)-
310{-
311 QNumberStyleAnimation::updateCurrentTime(time);-
312 if (_mode == Deactivating
_mode == DeactivatingDescription
TRUEnever evaluated
FALSEnever evaluated
&& qFuzzyIsNull(currentValue())
qFuzzyIsNull(currentValue())Description
TRUEnever evaluated
FALSEnever evaluated
)
0
313 target()->setProperty("visible", false);
never executed: target()->setProperty("visible", false);
0
314}
never executed: end of block
0
315-
316-
317-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9