16QStyleAnimation::QStyleAnimation(QObject *target) : QAbstractAnimation(target),
17 _delay(0), _duration(-1), _startTime(QTime::currentTime()), _fps(ThirtyFps), _skip(0)
173bool QNumberStyleAnimation::isUpdateNeeded()
const
175 if (QStyleAnimation::isUpdateNeeded()) {
176 qreal current = currentValue();
177 if (!qFuzzyCompare(_prev, current))
226 if (start.isNull() || end.isNull())
230 const int a = qRound(alpha*256);
231 const int ia = 256 - a;
232 const int sw = start.width();
233 const int sh = start.height();
234 const qsizetype bpl = start.bytesPerLine();
235 switch (start.depth()) {
238 blended = QImage(sw, sh, start.format());
239 blended.setDevicePixelRatio(start.devicePixelRatio());
240 uchar *mixed_data = blended.bits();
241 const uchar *back_data = start.bits();
242 const uchar *front_data = end.bits();
243 for (
int sy = 0; sy < sh; sy++) {
244 quint32* mixed = (quint32*)mixed_data;
245 const quint32* back = (
const quint32*)back_data;
246 const quint32* front = (
const quint32*)front_data;
247 for (
int sx = 0; sx < sw; sx++) {
248 quint32 bp = back[sx];
249 quint32 fp = front[sx];
250 mixed[sx] = qRgba ((qRed(bp)*ia + qRed(fp)*a)>>8,
251 (qGreen(bp)*ia + qGreen(fp)*a)>>8,
252 (qBlue(bp)*ia + qBlue(fp)*a)>>8,
253 (qAlpha(bp)*ia + qAlpha(fp)*a)>>8);
267void QBlendStyleAnimation::updateCurrentTime(
int time)
269 QStyleAnimation::updateCurrentTime(time);
272 if (duration() > 0) {
273 if (_type == Pulse) {
274 time = time % duration() * 2;
275 if (time > duration())
276 time = duration() * 2 - time;
279 alpha = time /
static_cast<
float>(duration());
281 if (_type == Transition && time > duration()) {
285 }
else if (time > 0) {
289 _current = blendedImage(_start, _end, alpha);
292QScrollbarStyleAnimation::QScrollbarStyleAnimation(Mode mode, QObject *target) : QNumberStyleAnimation(target), _mode(mode), _active(
false)
296 setDuration(ScrollBarFadeOutDuration);
301 setDuration(ScrollBarFadeOutDelay + ScrollBarFadeOutDuration);
302 setDelay(ScrollBarFadeOutDelay);