summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNorwegian Rock Cat <qt-info@nokia.com>2009-03-25 13:16:09 (GMT)
committerNorwegian Rock Cat <qt-info@nokia.com>2009-03-25 13:29:16 (GMT)
commit21560a591358512fe321b07b49dbbcfab7ea355d (patch)
treef2e2e42df443fe81810c40a1782f648468fb6c49 /src
parent6a1d87870a6e9374bc5157f16f29232180546dfa (diff)
downloadQt-21560a591358512fe321b07b49dbbcfab7ea355d.zip
Qt-21560a591358512fe321b07b49dbbcfab7ea355d.tar.gz
Qt-21560a591358512fe321b07b49dbbcfab7ea355d.tar.bz2
Better look of toolbar items on Leopard.
Toolbar text items have a embossing on Leopard, so we should do that. However, they have a different look when "pressed" depending on whether or not they have an icons. We are very close to this effect (depending on how transparency rounding goes). Steps have also been taken so that the Tiger look is preserved. This is step one in several of getting the toolbars to look better on Leopard and friends. Task-number: 248006 Reviewed-by: Jens Bache-Wiig
Diffstat (limited to 'src')
-rw-r--r--src/gui/styles/qmacstyle_mac.mm63
1 files changed, 45 insertions, 18 deletions
diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm
index a3f5cfe..8b60489 100644
--- a/src/gui/styles/qmacstyle_mac.mm
+++ b/src/gui/styles/qmacstyle_mac.mm
@@ -3629,7 +3629,10 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
QRect cr = tb->rect;
int shiftX = 0;
int shiftY = 0;
- if (tb->state & (State_Sunken | State_On)) {
+ bool needText = false;
+ int alignment = 0;
+ bool down = tb->state & (State_Sunken | State_On);
+ if (down) {
shiftX = pixelMetric(PM_ButtonShiftHorizontal, tb, w);
shiftY = pixelMetric(PM_ButtonShiftVertical, tb, w);
}
@@ -3637,30 +3640,29 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
// The text is a bit bolder and gets a drop shadow and the icons are also darkened.
// This doesn't really fit into any particular case in QIcon, so we
// do the majority of the work ourselves.
- if (tb->state & State_Sunken
- && !(tb->features & QStyleOptionToolButton::Arrow)) {
+ if (!(tb->features & QStyleOptionToolButton::Arrow)) {
Qt::ToolButtonStyle tbstyle = tb->toolButtonStyle;
if (tb->icon.isNull() && !tb->text.isEmpty())
tbstyle = Qt::ToolButtonTextOnly;
switch (tbstyle) {
- case Qt::ToolButtonTextOnly:
- drawItemText(p, cr, Qt::AlignCenter, tb->palette,
- tb->state & State_Enabled, tb->text);
- break;
+ case Qt::ToolButtonTextOnly: {
+ needText = true;
+ alignment = Qt::AlignCenter;
+ break; }
case Qt::ToolButtonIconOnly:
case Qt::ToolButtonTextBesideIcon:
case Qt::ToolButtonTextUnderIcon: {
QRect pr = cr;
QIcon::Mode iconMode = (tb->state & State_Enabled) ? QIcon::Normal
- : QIcon::Disabled;
+ : QIcon::Disabled;
QIcon::State iconState = (tb->state & State_On) ? QIcon::On
- : QIcon::Off;
+ : QIcon::Off;
QPixmap pixmap = tb->icon.pixmap(tb->rect.size().boundedTo(tb->iconSize), iconMode, iconState);
// Draw the text if it's needed.
if (tb->toolButtonStyle != Qt::ToolButtonIconOnly) {
- int alignment = 0;
+ needText = true;
if (tb->toolButtonStyle == Qt::ToolButtonTextUnderIcon) {
pr.setHeight(pixmap.size().height() + 6);
cr.adjust(0, pr.bottom(), 0, -3);
@@ -3670,18 +3672,43 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
cr.adjust(pr.right(), 0, 0, 0);
alignment |= Qt::AlignLeft | Qt::AlignVCenter;
}
- cr.translate(shiftX, shiftY);
- drawItemText(p, cr, alignment, tb->palette,
- tb->state & State_Enabled, tb->text);
- cr.adjust(0, 3, 0, -3); // the drop shadow
- drawItemText(p, cr, alignment, tb->palette,
- tb->state & State_Enabled, tb->text);
}
- pr.translate(shiftX, shiftY);
- pixmap = darkenPixmap(pixmap);
+ if (down) {
+ pr.translate(shiftX, shiftY);
+ pixmap = darkenPixmap(pixmap);
+ }
drawItemPixmap(p, pr, Qt::AlignCenter, pixmap);
break; }
}
+
+ if (needText) {
+ QPalette pal = tb->palette;
+ QPalette::ColorRole role = QPalette::NoRole;
+ if (down)
+ cr.translate(shiftX, shiftY);
+ if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5
+ && (tbstyle == Qt::ToolButtonTextOnly
+ || (tbstyle != Qt::ToolButtonTextOnly && !down))) {
+ QPen pen = p->pen();
+ QColor light = down ? Qt::black : Qt::white;
+ light.setAlphaF(0.375f);
+ p->setPen(light);
+ p->drawText(cr.adjusted(0, 1, 0, 1), alignment, tb->text);
+ p->setPen(pen);
+ if (down && tbstyle == Qt::ToolButtonTextOnly) {
+ pal = QApplication::palette("QMenu");
+ pal.setCurrentColorGroup(tb->palette.currentColorGroup());
+ role = QPalette::HighlightedText;
+ }
+ }
+ drawItemText(p, cr, alignment, pal,
+ tb->state & State_Enabled, tb->text, role);
+ if (QSysInfo::MacintoshVersion < QSysInfo::MV_10_5 && down) {
+ // Draw a "drop shadow" in earlier versions.
+ drawItemText(p, cr.adjusted(0, 1, 0, 1), alignment,
+ tb->palette, tb->state & State_Enabled, tb->text);
+ }
+ }
} else {
QWindowsStyle::drawControl(ce, &myTb, p, w);
}