diff options
author | Sami Merila <sami.merila@nokia.com> | 2010-06-15 12:34:01 (GMT) |
---|---|---|
committer | Sami Merila <sami.merila@nokia.com> | 2010-06-15 12:34:01 (GMT) |
commit | 86b13101afe31934eddb0c904ac6d2815cd39e5e (patch) | |
tree | b4d00417865d8bde218a4369fe7eb2db3ba35dfe /src/gui/styles | |
parent | 239c601ce150e38d01022b2f34244a6532f82b6c (diff) | |
download | Qt-86b13101afe31934eddb0c904ac6d2815cd39e5e.zip Qt-86b13101afe31934eddb0c904ac6d2815cd39e5e.tar.gz Qt-86b13101afe31934eddb0c904ac6d2815cd39e5e.tar.bz2 |
Stylus menu for Share (QT app) is different from native S60 apps
This is part two of the fix.
This fix makes the menu item to be layoutted always with space reserved
for checkbox indicator, even if the menu item is not having one
(just like native side). Also, the right and left "gap areas"
(between menu border and menu item highlight) match the native side
more closely now. There is still some difference if using QMenu
(instead of QComboBoxListView), since we can't just ignore margin
set from widget.
Also, the Sym^3 "separator lines" are now started from correct position.
Finally, the menu item height now matches the native side.
Task-number: QT-3295
Reviewed-by: Alessandro Portale
Diffstat (limited to 'src/gui/styles')
-rw-r--r-- | src/gui/styles/qs60style.cpp | 66 |
1 files changed, 35 insertions, 31 deletions
diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 9745d9c..1a8dd78 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -1768,40 +1768,41 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, //todo: move the vertical spacing stuff into subElementRect const int vSpacing = QS60StylePrivate::pixelMetric(PM_LayoutVerticalSpacing); QStyleOptionMenuItem optionCheckBox; - if (checkable){ - const int hSpacing = QS60StylePrivate::pixelMetric(PM_LayoutHorizontalSpacing); - optionCheckBox.QStyleOptionMenuItem::operator=(*menuItem); - optionCheckBox.rect.setWidth(pixelMetric(PM_IndicatorWidth)); - optionCheckBox.rect.setHeight(pixelMetric(PM_IndicatorHeight)); - optionCheckBox.rect.moveCenter(QPoint( - optionCheckBox.rect.center().x(), - menuItem->rect.center().y())); - const int moveByX = optionCheckBox.rect.width() + vSpacing + - pixelMetric(PM_DefaultFrameWidth) + 1; - if (optionMenuItem.direction == Qt::LeftToRight) { - if (iconRect.isValid()) { - iconRect.translate(moveByX, 0); - iconRect.setWidth(iconRect.width() + vSpacing); - } - if (textRect.isValid()) { - textRect.translate(moveByX, 0); - textRect.setWidth(textRect.width() - moveByX - vSpacing); - } - optionCheckBox.rect.translate(vSpacing >> 1, hSpacing >> 1); - } else { - if (textRect.isValid()) - textRect.setWidth(textRect.width() - moveByX); - if (iconRect.isValid()) { - iconRect.setWidth(iconRect.width() + vSpacing); - iconRect.translate(-optionCheckBox.rect.width() - vSpacing, 0); - } - optionCheckBox.rect.translate(textRect.width() + iconRect.width(), 0); + + //Regardless of checkbox visibility, make room for it, this mirrors native implementation, + //where text and icon placement is static regardless of content of menu item. + const int hSpacing = QS60StylePrivate::pixelMetric(PM_LayoutHorizontalSpacing); + optionCheckBox.QStyleOptionMenuItem::operator=(*menuItem); + optionCheckBox.rect.setWidth(pixelMetric(PM_IndicatorWidth)); + optionCheckBox.rect.setHeight(pixelMetric(PM_IndicatorHeight)); + optionCheckBox.rect.moveCenter(QPoint( + optionCheckBox.rect.center().x(), + menuItem->rect.center().y())); + const int moveByX = optionCheckBox.rect.width() + vSpacing + + pixelMetric(PM_DefaultFrameWidth); + if (optionMenuItem.direction == Qt::LeftToRight) { + if (iconRect.isValid()) { + iconRect.translate(moveByX, 0); + iconRect.setWidth(iconRect.width() + vSpacing); + } + if (textRect.isValid()) { + textRect.translate(moveByX, 0); + textRect.setWidth(textRect.width() - moveByX - vSpacing); + } + optionCheckBox.rect.translate(vSpacing + pixelMetric(PM_DefaultFrameWidth), hSpacing >> 1); + } else { + if (textRect.isValid()) + textRect.setWidth(textRect.width() - moveByX); + if (iconRect.isValid()) { + iconRect.setWidth(iconRect.width() + vSpacing); + iconRect.translate(-optionCheckBox.rect.width() - vSpacing, 0); } + optionCheckBox.rect.translate(textRect.width() + iconRect.width(), 0); } const bool selected = (option->state & State_Selected) && (option->state & State_Enabled); - const int spacing = pixelMetric(PM_DefaultFrameWidth) * 2; if (selected) { + const int spacing = pixelMetric(PM_DefaultFrameWidth) * 2; int start; int end; if (QApplication::layoutDirection() == Qt::LeftToRight) { start = optionMenuItem.rect.left() + spacing; @@ -1872,6 +1873,7 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, //In Sym^3, native menu items have "lines" between them if (QS60StylePrivate::isSingleClickUi()) { const QColor lineColorAlpha = QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnLineColors, 15, 0); + const int spacing = QS60StylePrivate::pixelMetric(PM_FrameCornerWidth); //native platform sets each color byte to same value for "line 16" which just defines alpha for //menuitem lines; lets use first byte "red". QColor lineColor = optionMenuItem.palette.text().color(); @@ -2281,6 +2283,8 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti if (QS60StylePrivate::canDrawThemeBackground(option->palette.base(), widget) && option->palette.window().texture().cacheKey() == QS60StylePrivate::m_themePalette->window().texture().cacheKey()) + //todo: for combobox listviews, the background should include area for menu scrollers, + //but this produces drawing issues as we need to turn clipping off. QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_PopupBackground, painter, option->rect, flags); else commonStyleDraws = true; @@ -2597,11 +2601,11 @@ QSize QS60Style::sizeFromContents(ContentsType ct, const QStyleOption *opt, } sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget); //native items have small empty areas at the beginning and end of menu item - sz.setWidth(sz.width() + 2 * pixelMetric(PM_MenuHMargin)); + sz.setWidth(sz.width() + 2 * pixelMetric(PM_MenuHMargin) + 2 * QS60StylePrivate::pixelMetric(PM_FrameCornerWidth)); if (QS60StylePrivate::isTouchSupported()) //Make itemview easier to use in touch devices //QCommonStyle does not adjust height with horizontal margin, it only adjusts width - sz.setHeight(sz.height() + 2 * pixelMetric(PM_FocusFrameVMargin)); + sz.setHeight(sz.height() + 2 * pixelMetric(PM_FocusFrameVMargin) - 8); //QCommonstyle adds 8 to height that this style handles through PM values break; #ifndef QT_NO_COMBOBOX case CT_ComboBox: { |