From e746a954501e8b9eaee572414314a17ae2929573 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomi=20Korpip=C3=A4=C3=A4?= Date: Wed, 18 Sep 2013 13:34:18 +0300 Subject: Theme draft 3 Task-number: QTRD-2277 + added control over label borders to theme Change-Id: Ib0047233d920bcf8cdaf5cc6165d9d17513b209a Change-Id: Ib0047233d920bcf8cdaf5cc6165d9d17513b209a Reviewed-by: Mika Salmela --- src/datavisualization/engine/drawer.cpp | 1 + src/datavisualization/engine/selectionpointer.cpp | 3 +- src/datavisualization/engine/theme.cpp | 37 ++++++++++++++++------- src/datavisualization/engine/theme_p.h | 1 + src/datavisualization/utils/utils.cpp | 12 ++++++-- src/datavisualization/utils/utils_p.h | 1 + 6 files changed, 40 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/datavisualization/engine/drawer.cpp b/src/datavisualization/engine/drawer.cpp index c4cff622..7fcf581f 100644 --- a/src/datavisualization/engine/drawer.cpp +++ b/src/datavisualization/engine/drawer.cpp @@ -349,6 +349,7 @@ void Drawer::generateLabelItem(LabelItem &item, const QString &text, int widestL m_theme.m_textBackgroundColor, m_theme.m_textColor, m_transparency, + m_theme.m_labelBorders, widestLabel); // Set label size diff --git a/src/datavisualization/engine/selectionpointer.cpp b/src/datavisualization/engine/selectionpointer.cpp index ecd47b93..0dfe3bb2 100644 --- a/src/datavisualization/engine/selectionpointer.cpp +++ b/src/datavisualization/engine/selectionpointer.cpp @@ -213,7 +213,8 @@ void SelectionPointer::setLabel(QString label) label, m_cachedTheme.m_textBackgroundColor, m_cachedTheme.m_textColor, - m_labelTransparency); + m_labelTransparency, + m_cachedTheme.m_labelBorders); // Set label size m_labelItem.setSize(image.size()); diff --git a/src/datavisualization/engine/theme.cpp b/src/datavisualization/engine/theme.cpp index ccdc2401..220f59ce 100644 --- a/src/datavisualization/engine/theme.cpp +++ b/src/datavisualization/engine/theme.cpp @@ -41,7 +41,8 @@ Theme::Theme() m_lightStrength(4.0f), m_ambientStrength(0.3f), m_highlightLightStrength(8.0f), - m_uniformColor(true) + m_uniformColor(true), + m_labelBorders(false) { // Default values for surface gradient m_surfaceGradient.setColorAt(0.0, Qt::green); @@ -92,7 +93,6 @@ void Theme::useColorTheme(QDataVis::ColorTheme colorTheme) m_lightStrength = 4.0f; m_ambientStrength = 0.3f; m_highlightLightStrength = 6.0f; - m_uniformColor = true; #elif defined(Q_OS_LINUX) m_baseColor = QColor(QRgb(0x60a6e6)); m_heightColor = QColor(QRgb(0xfc5751)); @@ -108,7 +108,6 @@ void Theme::useColorTheme(QDataVis::ColorTheme colorTheme) m_lightStrength = 4.0f; m_ambientStrength = 0.3f; m_highlightLightStrength = 6.0f; - m_uniformColor = true; #elif defined(Q_OS_MAC) m_baseColor = QColor(QRgb(0x60a6e6)); m_heightColor = QColor(QRgb(0xfc5751)); @@ -124,7 +123,6 @@ void Theme::useColorTheme(QDataVis::ColorTheme colorTheme) m_lightStrength = 4.0f; m_ambientStrength = 0.3f; m_highlightLightStrength = 6.0f; - m_uniformColor = true; #else m_baseColor = QColor(QRgb(0x60a6e6)); m_heightColor = QColor(QRgb(0xfc5751)); @@ -140,8 +138,9 @@ void Theme::useColorTheme(QDataVis::ColorTheme colorTheme) m_lightStrength = 4.0f; m_ambientStrength = 0.3f; m_highlightLightStrength = 6.0f; - m_uniformColor = true; #endif + m_uniformColor = true; + m_labelBorders = true; break; } case QDataVis::ThemeBlueCerulean: { @@ -161,6 +160,7 @@ void Theme::useColorTheme(QDataVis::ColorTheme colorTheme) m_ambientStrength = 0.2f; m_highlightLightStrength = 10.0f; m_uniformColor = true; + m_labelBorders = false; break; } case QDataVis::ThemeBlueIcy: { @@ -182,6 +182,7 @@ void Theme::useColorTheme(QDataVis::ColorTheme colorTheme) m_ambientStrength = 0.3f; m_highlightLightStrength = 8.0f; m_uniformColor = true; + m_labelBorders = false; break; } case QDataVis::ThemeBlueNcs: { @@ -203,6 +204,7 @@ void Theme::useColorTheme(QDataVis::ColorTheme colorTheme) m_ambientStrength = 0.2f; m_highlightLightStrength = 6.0f; m_uniformColor = true; + m_labelBorders = false; break; } case QDataVis::ThemeBrownSand: { @@ -223,6 +225,7 @@ void Theme::useColorTheme(QDataVis::ColorTheme colorTheme) m_ambientStrength = 0.3f; m_highlightLightStrength = 8.0f; m_uniformColor = false; + m_labelBorders = false; break; } case QDataVis::ThemeDark: { @@ -242,6 +245,7 @@ void Theme::useColorTheme(QDataVis::ColorTheme colorTheme) m_ambientStrength = 0.2f; m_highlightLightStrength = 8.0f; m_uniformColor = false; + m_labelBorders = true; break; } case QDataVis::ThemeHighContrast: { @@ -264,6 +268,7 @@ void Theme::useColorTheme(QDataVis::ColorTheme colorTheme) m_ambientStrength = 0.3f; m_highlightLightStrength = 10.0f; m_uniformColor = false; + m_labelBorders = true; break; } case QDataVis::ThemeLight: { @@ -285,6 +290,7 @@ void Theme::useColorTheme(QDataVis::ColorTheme colorTheme) m_ambientStrength = 0.3f; m_highlightLightStrength = 7.0f; m_uniformColor = true; + m_labelBorders = false; break; } case QDataVis::ThemeQt: { @@ -302,7 +308,8 @@ void Theme::useColorTheme(QDataVis::ColorTheme colorTheme) m_lightStrength = 5.0f; m_ambientStrength = 0.5f; m_highlightLightStrength = 5.0f; - m_uniformColor = false; + m_uniformColor = true; + m_labelBorders = true; break; } case QDataVis::ThemePrimaryColors: { @@ -312,7 +319,7 @@ void Theme::useColorTheme(QDataVis::ColorTheme colorTheme) m_backgroundColor = QColor(QRgb(0xffffff)); m_windowColor = QColor(QRgb(0xffffff)); m_textColor = QColor(QRgb(0x000000)); - m_textBackgroundColor = QColor(0xff, 0xff, 0xff, 0x01); + m_textBackgroundColor = QColor(0xff, 0xff, 0xff, 0x99); m_gridLine = QColor(QRgb(0xd7d6d5)); m_highlightBarColor = QColor(QRgb(0x27beee)); m_highlightRowColor = QColor(QRgb(0xee1414)); @@ -320,7 +327,8 @@ void Theme::useColorTheme(QDataVis::ColorTheme colorTheme) m_lightStrength = 5.0f; m_ambientStrength = 0.5f; m_highlightLightStrength = 5.0f; - m_uniformColor = false; + m_uniformColor = true; + m_labelBorders = false; break; } case QDataVis::ThemeDigia: { @@ -339,6 +347,7 @@ void Theme::useColorTheme(QDataVis::ColorTheme colorTheme) m_ambientStrength = 0.5f; m_highlightLightStrength = 5.0f; m_uniformColor = false; + m_labelBorders = false; break; } case QDataVis::ThemeStoneMoss: { @@ -356,7 +365,8 @@ void Theme::useColorTheme(QDataVis::ColorTheme colorTheme) m_lightStrength = 5.0f; m_ambientStrength = 0.5f; m_highlightLightStrength = 5.0f; - m_uniformColor = false; + m_uniformColor = true; + m_labelBorders = true; break; } case QDataVis::ThemeArmyBlue: { @@ -375,6 +385,7 @@ void Theme::useColorTheme(QDataVis::ColorTheme colorTheme) m_ambientStrength = 0.5f; m_highlightLightStrength = 5.0f; m_uniformColor = false; + m_labelBorders = false; break; } case QDataVis::ThemeRetro: { @@ -393,6 +404,7 @@ void Theme::useColorTheme(QDataVis::ColorTheme colorTheme) m_ambientStrength = 0.5f; m_highlightLightStrength = 5.0f; m_uniformColor = false; + m_labelBorders = false; break; } case QDataVis::ThemeEbony: { @@ -410,7 +422,8 @@ void Theme::useColorTheme(QDataVis::ColorTheme colorTheme) m_lightStrength = 5.0f; m_ambientStrength = 0.5f; m_highlightLightStrength = 5.0f; - m_uniformColor = false; + m_uniformColor = true; + m_labelBorders = false; break; } case QDataVis::ThemeIsabelle: { @@ -428,7 +441,8 @@ void Theme::useColorTheme(QDataVis::ColorTheme colorTheme) m_lightStrength = 5.0f; m_ambientStrength = 0.5f; m_highlightLightStrength = 5.0f; - m_uniformColor = false; + m_uniformColor = true; + m_labelBorders = false; break; } default: @@ -455,6 +469,7 @@ void Theme::setFromTheme(Theme &theme) m_ambientStrength = theme.m_ambientStrength; m_highlightLightStrength = theme.m_highlightLightStrength; m_uniformColor = theme.m_uniformColor; + m_labelBorders = theme.m_labelBorders; } QT_DATAVISUALIZATION_END_NAMESPACE diff --git a/src/datavisualization/engine/theme_p.h b/src/datavisualization/engine/theme_p.h index a22ca513..246ebf93 100644 --- a/src/datavisualization/engine/theme_p.h +++ b/src/datavisualization/engine/theme_p.h @@ -74,6 +74,7 @@ private: float m_ambientStrength; float m_highlightLightStrength; bool m_uniformColor; + bool m_labelBorders; }; QT_DATAVISUALIZATION_END_NAMESPACE diff --git a/src/datavisualization/utils/utils.cpp b/src/datavisualization/utils/utils.cpp index 9fbf6859..eaefad97 100644 --- a/src/datavisualization/utils/utils.cpp +++ b/src/datavisualization/utils/utils.cpp @@ -46,7 +46,7 @@ QVector3D Utils::vectorFromColor(const QColor &color) QImage Utils::printTextToImage(const QFont &font, const QString &text, const QColor &bgrColor, const QColor &txtColor, QDataVis::LabelTransparency transparency, - int maxLabelWidth) + bool borders, int maxLabelWidth) { GLuint paddingWidth = 15; GLuint paddingHeight = 15; @@ -108,7 +108,10 @@ QImage Utils::printTextToImage(const QFont &font, const QString &text, const QCo } case QDataVis::TransparencyFromTheme: { painter.setBrush(QBrush(bgrColor)); - painter.setPen(bgrColor); + if (borders) + painter.setPen(QPen(QBrush(txtColor), 5, Qt::SolidLine, Qt::SquareCap, Qt::RoundJoin)); + else + painter.setPen(bgrColor); painter.drawRoundedRect(0, 0, labelSize.width(), labelSize.height(), 10.0, 10.0f); painter.setFont(valueFont); painter.setPen(txtColor); @@ -121,7 +124,10 @@ QImage Utils::printTextToImage(const QFont &font, const QString &text, const QCo } case QDataVis::TransparencyNone: { painter.setBrush(QBrush(bgrColor)); - painter.setPen(bgrColor); + if (borders) + painter.setPen(QPen(QBrush(txtColor), 7.5)); + else + painter.setPen(bgrColor); painter.drawRect(0, 0, labelSize.width(), labelSize.height()); painter.setFont(valueFont); painter.setPen(txtColor); diff --git a/src/datavisualization/utils/utils_p.h b/src/datavisualization/utils/utils_p.h index 4cbd8f35..6e40eea7 100644 --- a/src/datavisualization/utils/utils_p.h +++ b/src/datavisualization/utils/utils_p.h @@ -60,6 +60,7 @@ public: const QColor &bgrColor, const QColor &txtColor, QDataVis::LabelTransparency transparency, + bool borders = false, int maxLabelWidth = 0); static QVector3D getSelection(QPoint mousepos, int height); -- cgit v1.2.3