diff options
author | Jens Bache-Wiig <jbache@trolltech.com> | 2010-05-20 14:45:53 (GMT) |
---|---|---|
committer | Jens Bache-Wiig <jbache@trolltech.com> | 2010-05-20 14:47:00 (GMT) |
commit | 8846348738a3cab1a4b59b27f81e27bc17da02ff (patch) | |
tree | 6232d726702e67729c561afb96166fa00f656cd9 /src/gui/styles | |
parent | d987e048f542a4c85c640b36d116bb408dd029fd (diff) | |
download | Qt-8846348738a3cab1a4b59b27f81e27bc17da02ff.zip Qt-8846348738a3cab1a4b59b27f81e27bc17da02ff.tar.gz Qt-8846348738a3cab1a4b59b27f81e27bc17da02ff.tar.bz2 |
Improve look and feel of itemviews on mac
These fixes are neccessary and requested by Qt Creator and
should go into 4.7.0. The fixes involved is:
- positioning of disclosure arrow in treeviews
- spacing between icon and text label
- added 2 pixel spacing between item view items
Note that native cocoa views tend to use 3 pixel spacing.
We considered this and decided on leaving it at 2 which is what
you see in finder list views, XCode among other places.
It also makes the change a bit less radical.
Reviewed-by:cduclos
Task-number:QTBUG-10190
Diffstat (limited to 'src/gui/styles')
-rw-r--r-- | src/gui/styles/qmacstyle_mac.mm | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm index 0f01bd5..e82e638 100644 --- a/src/gui/styles/qmacstyle_mac.mm +++ b/src/gui/styles/qmacstyle_mac.mm @@ -132,6 +132,8 @@ static const QColor titlebarSeparatorLineInactive(131, 131, 131); static const QColor mainWindowGradientBegin(240, 240, 240); static const QColor mainWindowGradientEnd(200, 200, 200); +static const int DisclosureOffset = 4; + #if (MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_5) enum { kThemePushButtonTextured = 31, @@ -3100,7 +3102,7 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai else bi.value = opt->direction == Qt::LeftToRight ? kThemeDisclosureRight : kThemeDisclosureLeft; bi.adornment = kThemeAdornmentNone; - HIRect hirect = qt_hirectForQRect(opt->rect); + HIRect hirect = qt_hirectForQRect(opt->rect.adjusted(DisclosureOffset,0,-DisclosureOffset,0)); HIThemeDrawButton(&hirect, &bi, cg, kHIThemeOrientationNormal, 0); break; } @@ -4353,6 +4355,15 @@ QRect QMacStyle::subElementRect(SubElement sr, const QStyleOption *opt, int controlSize = getControlSize(opt, widget); switch (sr) { + case SE_ItemViewItemText: + if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(opt)) { + int fw = proxy()->pixelMetric(PM_FocusFrameHMargin, opt, widget); + // We add the focusframeargin between icon and text in commonstyle + rect = QCommonStyle::subElementRect(sr, opt, widget); + if (vopt->features & QStyleOptionViewItemV2::HasDecoration) + rect.adjust(-fw, 0, 0, 0); + } + break; case SE_ToolBoxTabContents: rect = QCommonStyle::subElementRect(sr, opt, widget); break; @@ -4370,9 +4381,9 @@ QRect QMacStyle::subElementRect(SubElement sr, const QStyleOption *opt, case SE_HeaderLabel: if (qstyleoption_cast<const QStyleOptionHeader *>(opt)) { rect = QWindowsStyle::subElementRect(sr, opt, widget); - if (widget && widget->height() <= qt_mac_aqua_get_metric(kThemeMetricListHeaderHeight)){ - // We need to allow the text a bit more space when the header is as - // small as kThemeMetricListHeaderHeight, otherwise it gets clipped: + if (widget && widget->height() <= 22){ + // We need to allow the text a bit more space when the header is + // small, otherwise it gets clipped: rect.setY(0); rect.setHeight(widget->height()); } @@ -4399,8 +4410,9 @@ QRect QMacStyle::subElementRect(SubElement sr, const QStyleOption *opt, HIRect outRect; HIThemeGetButtonShape(&inRect, &bdi, &shape); ptrHIShapeGetBounds(shape, &outRect); - rect = QRect(int(outRect.origin.x), int(outRect.origin.y), - int(contentRect.origin.x - outRect.origin.x), int(outRect.size.height)); + rect = QRect(int(outRect.origin.x + DisclosureOffset), int(outRect.origin.y), + int(contentRect.origin.x - outRect.origin.x + DisclosureOffset), + int(outRect.size.height)); break; } case SE_TabWidgetLeftCorner: @@ -5789,6 +5801,13 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, sz = sz.expandedTo(QSize(sz.width(), minimumSize)); } break; + case CT_ItemViewItem: + if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(opt)) { + sz = QCommonStyle::sizeFromContents(ct, vopt, csz, widget); + sz.setHeight(sz.height() + 2); + } + break; + default: sz = QWindowsStyle::sizeFromContents(ct, opt, csz, widget); } |