Revise QMacStyle scrollbar animation handling

Skip animations whether styleObject is not set.

Task-number: QTBUG-27895
Change-Id: I1d2e4655b735627b672bc85f773605adcd375418
Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
This commit is contained in:
J-P Nurmi 2012-11-29 21:18:25 +01:00 committed by The Qt Project
parent 2ffb9b489a
commit f52177829a

View File

@ -4906,17 +4906,9 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
if (cc == CC_ScrollBar && proxy()->styleHint(SH_ScrollBar_Transient)) {
QObject *styleObject = opt->styleObject;
// Qt generally excepts styleObject to be set during draw calls, but
// this is not always done. Create a temprary object in that case to
// prevent crashing. This will disable scroll bar animations.
bool deleteStyleObject = false;
if (!styleObject) {
deleteStyleObject = true;
styleObject = new QObject;
}
bool wasActive = false;
CGFloat opacity = 1.0;
if (QObject *styleObject = opt->styleObject) {
int oldPos = styleObject->property("_q_stylepos").toInt();
int oldMin = styleObject->property("_q_stylemin").toInt();
int oldMax = styleObject->property("_q_stylemax").toInt();
@ -4928,7 +4920,6 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
// its sibling are both inactive (ie. not pressed/hovered/moved)
bool transient = !opt->activeSubControls && !(slider->state & State_On);
CGFloat opacity = 0.0;
if (!transient ||
oldPos != slider->sliderPosition ||
oldMin != slider->minimum ||
@ -4937,10 +4928,6 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
oldState != slider->state ||
oldActiveControls != slider->activeSubControls) {
// if the scrollbar is transient or its attributes, geometry or
// state has changed, the opacity is reset back to 100% opaque
opacity = 1.0;
styleObject->setProperty("_q_stylepos", slider->sliderPosition);
styleObject->setProperty("_q_stylemin", slider->minimum);
styleObject->setProperty("_q_stylemax", slider->maximum);
@ -4969,8 +4956,11 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
// the active look even if it's no longer active while fading out
if (oldActiveControls)
anim->setActive(true);
wasActive = anim->wasActive();
opacity = anim->currentValue();
}
}
const bool isHorizontal = slider->orientation == Qt::Horizontal;
@ -5000,7 +4990,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
[scroller setScrollerStyle:NSScrollerStyleOverlay];
// first we draw only the track, by using a disabled scroller
if (opt->activeSubControls || (anim && anim->wasActive())) {
if (opt->activeSubControls || wasActive) {
CGContextBeginTransparencyLayerWithRect(cg, qt_hirectForQRect(slider->rect),
NULL);
CGContextSetAlpha(cg, opacity);
@ -5050,10 +5040,6 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
[NSGraphicsContext restoreGraphicsState];
CGContextRestoreGState(cg);
if (deleteStyleObject) {
delete styleObject;
}
} else
#endif
{