diff options
Diffstat (limited to 'src/widgets/styles/qwindowsvistastyle.cpp')
-rw-r--r-- | src/widgets/styles/qwindowsvistastyle.cpp | 111 |
1 files changed, 4 insertions, 107 deletions
diff --git a/src/widgets/styles/qwindowsvistastyle.cpp b/src/widgets/styles/qwindowsvistastyle.cpp index b20e6f5ea5..f6648bed24 100644 --- a/src/widgets/styles/qwindowsvistastyle.cpp +++ b/src/widgets/styles/qwindowsvistastyle.cpp @@ -235,119 +235,16 @@ static int buttonStateId(int flags, int partId) return stateId; } -void QWindowsVistaAnimation::paint(QPainter *painter, const QStyleOption *option) -{ - Q_UNUSED(option); - Q_UNUSED(painter); -} - bool QWindowsVistaAnimation::isUpdateNeeded() const { return QWindowsVistaStylePrivate::useVista(); } -/*! \internal - - Helperfunction to paint the current transition state between two - animation frames. - - The result is a blended image consisting of ((alpha)*_primaryImage) - + ((1-alpha)*_secondaryImage) - -*/ -void QWindowsVistaAnimation::drawBlendedImage(QPainter *painter, QRect rect, float alpha) { - if (_secondaryImage.isNull() || _primaryImage.isNull()) - return; - - if (_tempImage.isNull()) - _tempImage = _secondaryImage; - - const int a = qRound(alpha*256); - const int ia = 256 - a; - const int sw = _primaryImage.width(); - const int sh = _primaryImage.height(); - const int bpl = _primaryImage.bytesPerLine(); - switch(_primaryImage.depth()) { - case 32: - { - uchar *mixed_data = _tempImage.bits(); - const uchar *back_data = _primaryImage.bits(); - const uchar *front_data = _secondaryImage.bits(); - for (int sy = 0; sy < sh; sy++) { - quint32* mixed = (quint32*)mixed_data; - const quint32* back = (const quint32*)back_data; - const quint32* front = (const quint32*)front_data; - for (int sx = 0; sx < sw; sx++) { - quint32 bp = back[sx]; - quint32 fp = front[sx]; - mixed[sx] = qRgba ((qRed(bp)*ia + qRed(fp)*a)>>8, - (qGreen(bp)*ia + qGreen(fp)*a)>>8, - (qBlue(bp)*ia + qBlue(fp)*a)>>8, - (qAlpha(bp)*ia + qAlpha(fp)*a)>>8); - } - mixed_data += bpl; - back_data += bpl; - front_data += bpl; - } - } - default: - break; - } - painter->drawImage(rect, _tempImage); -} - -/*! \internal - Paints a transition state. The result will be a mix between the - initial and final state of the transition, depending on the time - difference between startTime and current time. -*/ -void QWindowsVistaTransition::paint(QPainter *painter, const QStyleOption *option) -{ - float alpha = 1.0; - if (_duration > 0) { - QTime current = QTime::currentTime(); - - if (startTime() > current) - setStartTime(current); - - int timeDiff = startTime().msecsTo(current); - alpha = timeDiff/(float)_duration; - if (timeDiff > _duration) { - stop(); - alpha = 1.0; - } - } - else { - stop(); - } - drawBlendedImage(painter, option->rect, alpha); -} - -/*! \internal - Paints a pulse. The result will be a mix between the primary and - secondary pulse images depending on the time difference between - startTime and current time. -*/ -void QWindowsVistaPulse::paint(QPainter *painter, const QStyleOption *option) +void QWindowsVistaAnimation::paint(QPainter *painter, const QStyleOption *option) { - float alpha = 1.0; - if (_duration > 0) { - QTime current = QTime::currentTime(); - - if (startTime() > current) - setStartTime(current); - - int timeDiff = startTime().msecsTo(current) % _duration*2; - if (timeDiff > _duration) - timeDiff = _duration*2 - timeDiff; - alpha = timeDiff/(float)_duration; - } else { - stop(); - } - drawBlendedImage(painter, option->rect, alpha); + painter->drawImage(option->rect, currentImage()); } - /*! \internal @@ -1088,8 +985,8 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption theme.stateId = PBS_DEFAULTED_ANIMATING; theme.painter = &alternatePainter; d->drawBackground(theme); - pulse->setPrimaryImage(startImage); - pulse->setAlternateImage(alternateImage); + pulse->setStartImage(startImage); + pulse->setEndImage(alternateImage); pulse->setStartTime(QTime::currentTime()); pulse->setDuration(2000); d->startAnimation(pulse); |