Mac: Cleaner transient scrollbar rendering
authorGabriel de Dietrich <gabriel.dedietrich@digia.com>
Mon, 3 Dec 2012 14:55:15 +0000 (15:55 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Thu, 6 Dec 2012 15:45:52 +0000 (16:45 +0100)
Change-Id: I617588012aa5166775c3c6301ee70043b22553a3
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
src/widgets/styles/qmacstyle_mac.mm

index 89ea4d5..ba34a74 100644 (file)
@@ -4982,12 +4982,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
 
                 [scroller setControlSize:(tdi.kind == kThemeSmallScrollBar ? NSMiniControlSize
                                                                            : NSRegularControlSize)];
-                if (isHorizontal)
-                    [scroller setBounds:NSMakeRect(0, -1,
-                                                   slider->rect.width(), slider->rect.height())];
-                else
-                    [scroller setBounds:NSMakeRect(-1, 0,
-                                                   slider->rect.width(), slider->rect.height())];
+                [scroller setBounds:NSMakeRect(0, 0, slider->rect.width(), slider->rect.height())];
                 [scroller setScrollerStyle:NSScrollerStyleOverlay];
 
                 // first we draw only the track, by using a disabled scroller
@@ -4996,10 +4991,9 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
                                                             NULL);
                     CGContextSetAlpha(cg, opacity);
 
-                    [scroller setFrame:NSMakeRect(0, 0, slider->rect.width(), slider->rect.height())];
-                    [scroller setEnabled:NO];
-                    [scroller displayRectIgnoringOpacity:[scroller bounds]
-                                               inContext:[NSGraphicsContext currentContext]];
+                    [scroller setFrame:[scroller bounds]];
+                    [scroller setEnabled:(slider->state & State_Enabled) ? YES : NO];
+                    [scroller drawKnobSlotInRect:[scroller bounds] highlight:NO];
 
                     CGContextEndTransparencyLayer(cg);
                 }
@@ -5023,18 +5017,17 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
                     const qreal width = qMax<qreal>(minKnobWidth, plannedWidth);
                     const qreal totalWidth = slider->rect.width() + plannedWidth - width;
                     [scroller setFrame:NSMakeRect(0, 0, width, slider->rect.height())];
-                    CGContextTranslateCTM(cg, value * totalWidth, 0);
+                    CGContextTranslateCTM(cg, value * totalWidth, 1);
                 } else {
                     const qreal plannedHeight = proportion * slider->rect.height();
                     const qreal height = qMax<qreal>(minKnobWidth, plannedHeight);
                     const qreal totalHeight = slider->rect.height() + plannedHeight - height;
                     [scroller setFrame:NSMakeRect(0, 0, slider->rect.width(), height)];
-                    CGContextTranslateCTM(cg, 0, value * totalHeight);
+                    CGContextTranslateCTM(cg, 1, value * totalHeight);
                 }
                 if (length > 0.0) {
                     [scroller layout];
-                    [scroller displayRectIgnoringOpacity:[scroller bounds]
-                                               inContext:[NSGraphicsContext currentContext]];
+                    [scroller drawKnob];
                 }
 
                 CGContextEndTransparencyLayer(cg);