diff options
author | Gabriel de Dietrich <gabriel.dedietrich@qt.io> | 2017-05-15 13:23:08 -0700 |
---|---|---|
committer | Gabriel de Dietrich <gabriel.dedietrich@qt.io> | 2017-05-15 22:39:59 +0000 |
commit | cdc5f7ab5cdadff42e7736f66c823debbc0d85fc (patch) | |
tree | 243f115647811ce0b095c77618233182d1aa6e4f /src/plugins/styles | |
parent | d422ba6b4a151f8be808e212d8189eb48ff0d059 (diff) |
QMacStyle: Move NSScrollers into cocoaControl() logic
This patch amends b1131074199aae97.
Change-Id: Ib305554763457ae4b5a441e41947304cff2853a2
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
Diffstat (limited to 'src/plugins/styles')
-rw-r--r-- | src/plugins/styles/mac/qmacstyle_mac.mm | 21 | ||||
-rw-r--r-- | src/plugins/styles/mac/qmacstyle_mac_p_p.h | 5 |
2 files changed, 11 insertions, 15 deletions
diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index d66e9440c2..d4eb7141bd 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -1873,6 +1873,12 @@ NSView *QMacStylePrivate::cocoaControl(QCocoaWidget widget) const bv = [[NSPopUpButton alloc] init]; else if (widget.first == QCocoaComboBox) bv = [[NSComboBox alloc] init]; + else if (widget.first == QCocoaHorizontalScroller) + bv = [[NSScroller alloc] initWithFrame:NSMakeRect(0, 0, 200, 20)]; + else if (widget.first == QCocoaVerticalScroller) + // Cocoa sets the orientation from the view's frame + // at construction time, and it cannot be changed later. + bv = [[NSScroller alloc] initWithFrame:NSMakeRect(0, 0, 20, 200)]; else if (widget.first == QCocoaHorizontalSlider) bv = [[NSSlider alloc] init]; else if (widget.first == QCocoaVerticalSlider) @@ -2145,12 +2151,6 @@ QMacStyle::QMacStyle() name:NSPreferredScrollerStyleDidChangeNotification object:nil]; - // Create scroller objects. Scroller internal direction setup happens - // on initWithFrame and cannot be changed later on. Create two scrollers - // initialized with fake geometry. Correct geometry is set at draw time. - d->horizontalScroller = [[NSScroller alloc] initWithFrame:NSMakeRect(0, 0, 200, 20)]; - d->verticalScroller = [[NSScroller alloc] initWithFrame:NSMakeRect(0, 0, 20, 200)]; - d->indicatorBranchButtonCell = nil; } @@ -2159,9 +2159,6 @@ QMacStyle::~QMacStyle() Q_D(QMacStyle); QMacAutoReleasePool pool; - [d->horizontalScroller release]; - [d->verticalScroller release]; - NotificationReceiver *receiver = static_cast<NotificationReceiver *>(d->receiver); [[NSNotificationCenter defaultCenter] removeObserver:receiver]; [receiver release]; @@ -5383,7 +5380,9 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex d->setupNSGraphicsContext(cg, NO); - NSScroller *scroller = isHorizontal ? d->horizontalScroller : d-> verticalScroller; + const QCocoaWidget cw(isHorizontal ? QCocoaHorizontalScroller : QCocoaVerticalScroller, + tdi.kind == kThemeSmallScrollBar ? QStyleHelper::SizeMini : QStyleHelper::SizeLarge); + NSScroller *scroller = static_cast<NSScroller *>(d->cocoaControl(cw)); // mac os behaviour: as soon as one color channel is >= 128, // the bg is considered bright, scroller is dark const QColor bgColor = QStyleHelper::backgroundColor(opt->palette, widget); @@ -5394,8 +5393,6 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex else [scroller setKnobStyle:NSScrollerKnobStyleDefault]; - [scroller setControlSize:(tdi.kind == kThemeSmallScrollBar ? NSMiniControlSize - : NSRegularControlSize)]; [scroller setBounds:NSMakeRect(0, 0, slider->rect.width(), slider->rect.height())]; [scroller setScrollerStyle:NSScrollerStyleOverlay]; diff --git a/src/plugins/styles/mac/qmacstyle_mac_p_p.h b/src/plugins/styles/mac/qmacstyle_mac_p_p.h index f7295da2b8..68d77deb06 100644 --- a/src/plugins/styles/mac/qmacstyle_mac_p_p.h +++ b/src/plugins/styles/mac/qmacstyle_mac_p_p.h @@ -118,7 +118,6 @@ Q_FORWARD_DECLARE_MUTABLE_CG_TYPE(CGContext); Q_FORWARD_DECLARE_OBJC_CLASS(NSView); -Q_FORWARD_DECLARE_OBJC_CLASS(NSScroller); QT_BEGIN_NAMESPACE @@ -143,6 +142,8 @@ enum QCocoaWidgetKind { QCocoaPullDownButton, // QPushButton with menu QCocoaPushButton, QCocoaRadioButton, + QCocoaHorizontalScroller, + QCocoaVerticalScroller, QCocoaHorizontalSlider, QCocoaVerticalSlider }; @@ -251,8 +252,6 @@ public: CFAbsoluteTime defaultButtonStart; bool mouseDown; void* receiver; - NSScroller *horizontalScroller; - NSScroller *verticalScroller; void *indicatorBranchButtonCell; NSView *backingStoreNSView; QHash<QCocoaWidget, NSView *> cocoaControls; |