| 1 | /**************************************************************************** |
| 2 | ** |
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. |
| 4 | ** Contact: https://www.qt.io/licensing/ |
| 5 | ** |
| 6 | ** This file is part of the Qt Data Visualization module of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:GPL$ |
| 9 | ** Commercial License Usage |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in |
| 11 | ** accordance with the commercial license agreement provided with the |
| 12 | ** Software or, alternatively, in accordance with the terms contained in |
| 13 | ** a written agreement between you and The Qt Company. For licensing terms |
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
| 15 | ** information use the contact form at https://www.qt.io/contact-us. |
| 16 | ** |
| 17 | ** GNU General Public License Usage |
| 18 | ** Alternatively, this file may be used under the terms of the GNU |
| 19 | ** General Public License version 3 or (at your option) any later version |
| 20 | ** approved by the KDE Free Qt Foundation. The licenses are as published by |
| 21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 |
| 22 | ** included in the packaging of this file. Please review the following |
| 23 | ** information to ensure the GNU General Public License requirements will |
| 24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
| 25 | ** |
| 26 | ** $QT_END_LICENSE$ |
| 27 | ** |
| 28 | ****************************************************************************/ |
| 29 | |
| 30 | #ifndef Q3DTHEME_H |
| 31 | #define Q3DTHEME_H |
| 32 | |
| 33 | #include <QtDataVisualization/qdatavisualizationglobal.h> |
| 34 | #include <QtCore/QObject> |
| 35 | #include <QtGui/QLinearGradient> |
| 36 | #include <QtGui/QFont> |
| 37 | #include <QtGui/QColor> |
| 38 | |
| 39 | QT_BEGIN_NAMESPACE_DATAVISUALIZATION |
| 40 | |
| 41 | class Q3DThemePrivate; |
| 42 | |
| 43 | class QT_DATAVISUALIZATION_EXPORT Q3DTheme : public QObject |
| 44 | { |
| 45 | Q_OBJECT |
| 46 | Q_ENUMS(ColorStyle) |
| 47 | Q_ENUMS(Theme) |
| 48 | Q_PROPERTY(Theme type READ type WRITE setType NOTIFY typeChanged) |
| 49 | Q_PROPERTY(QList<QColor> baseColors READ baseColors WRITE setBaseColors NOTIFY baseColorsChanged) |
| 50 | Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged) |
| 51 | Q_PROPERTY(QColor windowColor READ windowColor WRITE setWindowColor NOTIFY windowColorChanged) |
| 52 | Q_PROPERTY(QColor labelTextColor READ labelTextColor WRITE setLabelTextColor NOTIFY labelTextColorChanged) |
| 53 | Q_PROPERTY(QColor labelBackgroundColor READ labelBackgroundColor WRITE setLabelBackgroundColor NOTIFY labelBackgroundColorChanged) |
| 54 | Q_PROPERTY(QColor gridLineColor READ gridLineColor WRITE setGridLineColor NOTIFY gridLineColorChanged) |
| 55 | Q_PROPERTY(QColor singleHighlightColor READ singleHighlightColor WRITE setSingleHighlightColor NOTIFY singleHighlightColorChanged) |
| 56 | Q_PROPERTY(QColor multiHighlightColor READ multiHighlightColor WRITE setMultiHighlightColor NOTIFY multiHighlightColorChanged) |
| 57 | Q_PROPERTY(QColor lightColor READ lightColor WRITE setLightColor NOTIFY lightColorChanged) |
| 58 | Q_PROPERTY(QList<QLinearGradient> baseGradients READ baseGradients WRITE setBaseGradients NOTIFY baseGradientsChanged) |
| 59 | Q_PROPERTY(QLinearGradient singleHighlightGradient READ singleHighlightGradient WRITE setSingleHighlightGradient NOTIFY singleHighlightGradientChanged) |
| 60 | Q_PROPERTY(QLinearGradient multiHighlightGradient READ multiHighlightGradient WRITE setMultiHighlightGradient NOTIFY multiHighlightGradientChanged) |
| 61 | Q_PROPERTY(float lightStrength READ lightStrength WRITE setLightStrength NOTIFY lightStrengthChanged) |
| 62 | Q_PROPERTY(float ambientLightStrength READ ambientLightStrength WRITE setAmbientLightStrength NOTIFY ambientLightStrengthChanged) |
| 63 | Q_PROPERTY(float highlightLightStrength READ highlightLightStrength WRITE setHighlightLightStrength NOTIFY highlightLightStrengthChanged) |
| 64 | Q_PROPERTY(bool labelBorderEnabled READ isLabelBorderEnabled WRITE setLabelBorderEnabled NOTIFY labelBorderEnabledChanged) |
| 65 | Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged) |
| 66 | Q_PROPERTY(bool backgroundEnabled READ isBackgroundEnabled WRITE setBackgroundEnabled NOTIFY backgroundEnabledChanged) |
| 67 | Q_PROPERTY(bool gridEnabled READ isGridEnabled WRITE setGridEnabled NOTIFY gridEnabledChanged) |
| 68 | Q_PROPERTY(bool labelBackgroundEnabled READ isLabelBackgroundEnabled WRITE setLabelBackgroundEnabled NOTIFY labelBackgroundEnabledChanged) |
| 69 | Q_PROPERTY(ColorStyle colorStyle READ colorStyle WRITE setColorStyle NOTIFY colorStyleChanged) |
| 70 | |
| 71 | public: |
| 72 | enum ColorStyle { |
| 73 | ColorStyleUniform = 0, |
| 74 | ColorStyleObjectGradient, |
| 75 | ColorStyleRangeGradient |
| 76 | }; |
| 77 | |
| 78 | enum Theme { |
| 79 | ThemeQt, |
| 80 | ThemePrimaryColors, |
| 81 | ThemeDigia, |
| 82 | ThemeStoneMoss, |
| 83 | ThemeArmyBlue, |
| 84 | ThemeRetro, |
| 85 | ThemeEbony, |
| 86 | ThemeIsabelle, |
| 87 | ThemeUserDefined |
| 88 | }; |
| 89 | |
| 90 | public: |
| 91 | explicit Q3DTheme(QObject *parent = nullptr); |
| 92 | explicit Q3DTheme(Theme themeType, QObject *parent = nullptr); |
| 93 | virtual ~Q3DTheme(); |
| 94 | |
| 95 | void setType(Theme themeType); |
| 96 | Theme type() const; |
| 97 | |
| 98 | void setBaseColors(const QList<QColor> &colors); |
| 99 | QList<QColor> baseColors() const; |
| 100 | |
| 101 | void setBackgroundColor(const QColor &color); |
| 102 | QColor backgroundColor() const; |
| 103 | |
| 104 | void setWindowColor(const QColor &color); |
| 105 | QColor windowColor() const; |
| 106 | |
| 107 | void setLabelTextColor(const QColor &color); |
| 108 | QColor labelTextColor() const; |
| 109 | |
| 110 | void setLabelBackgroundColor(const QColor &color); |
| 111 | QColor labelBackgroundColor() const; |
| 112 | |
| 113 | void setGridLineColor(const QColor &color); |
| 114 | QColor gridLineColor() const; |
| 115 | |
| 116 | void setSingleHighlightColor(const QColor &color); |
| 117 | QColor singleHighlightColor() const; |
| 118 | |
| 119 | void setMultiHighlightColor(const QColor &color); |
| 120 | QColor multiHighlightColor() const; |
| 121 | |
| 122 | void setLightColor(const QColor &color); |
| 123 | QColor lightColor() const; |
| 124 | |
| 125 | void setBaseGradients(const QList<QLinearGradient> &gradients); |
| 126 | QList<QLinearGradient> baseGradients() const; |
| 127 | |
| 128 | void setSingleHighlightGradient(const QLinearGradient &gradient); |
| 129 | QLinearGradient singleHighlightGradient() const; |
| 130 | |
| 131 | void setMultiHighlightGradient(const QLinearGradient &gradient); |
| 132 | QLinearGradient multiHighlightGradient() const; |
| 133 | |
| 134 | void setLightStrength(float strength); |
| 135 | float lightStrength() const; |
| 136 | |
| 137 | void setAmbientLightStrength(float strength); |
| 138 | float ambientLightStrength() const; |
| 139 | |
| 140 | void setHighlightLightStrength(float strength); |
| 141 | float highlightLightStrength() const; |
| 142 | |
| 143 | void setLabelBorderEnabled(bool enabled); |
| 144 | bool isLabelBorderEnabled() const; |
| 145 | |
| 146 | void setFont(const QFont &font); |
| 147 | QFont font() const; |
| 148 | |
| 149 | void setBackgroundEnabled(bool enabled); |
| 150 | bool isBackgroundEnabled() const; |
| 151 | |
| 152 | void setGridEnabled(bool enabled); |
| 153 | bool isGridEnabled() const; |
| 154 | |
| 155 | void setLabelBackgroundEnabled(bool enabled); |
| 156 | bool isLabelBackgroundEnabled() const; |
| 157 | |
| 158 | void setColorStyle(ColorStyle style); |
| 159 | ColorStyle colorStyle() const; |
| 160 | |
| 161 | Q_SIGNALS: |
| 162 | void typeChanged(Q3DTheme::Theme themeType); |
| 163 | void baseColorsChanged(const QList<QColor> &colors); |
| 164 | void backgroundColorChanged(const QColor &color); |
| 165 | void windowColorChanged(const QColor &color); |
| 166 | void labelTextColorChanged(const QColor &color); |
| 167 | void labelBackgroundColorChanged(const QColor &color); |
| 168 | void gridLineColorChanged(const QColor &color); |
| 169 | void singleHighlightColorChanged(const QColor &color); |
| 170 | void multiHighlightColorChanged(const QColor &color); |
| 171 | void lightColorChanged(const QColor &color); |
| 172 | void baseGradientsChanged(const QList<QLinearGradient> &gradients); |
| 173 | void singleHighlightGradientChanged(const QLinearGradient &gradient); |
| 174 | void multiHighlightGradientChanged(const QLinearGradient &gradient); |
| 175 | void lightStrengthChanged(float strength); |
| 176 | void ambientLightStrengthChanged(float strength); |
| 177 | void highlightLightStrengthChanged(float strength); |
| 178 | void labelBorderEnabledChanged(bool enabled); |
| 179 | void fontChanged(const QFont &font); |
| 180 | void backgroundEnabledChanged(bool enabled); |
| 181 | void gridEnabledChanged(bool enabled); |
| 182 | void labelBackgroundEnabledChanged(bool enabled); |
| 183 | void colorStyleChanged(Q3DTheme::ColorStyle style); |
| 184 | |
| 185 | protected: |
| 186 | explicit Q3DTheme(Q3DThemePrivate *d, Theme themeType, QObject *parent = nullptr); |
| 187 | |
| 188 | QScopedPointer<Q3DThemePrivate> d_ptr; |
| 189 | |
| 190 | private: |
| 191 | Q_DISABLE_COPY(Q3DTheme) |
| 192 | |
| 193 | friend class ThemeManager; |
| 194 | friend class Abstract3DRenderer; |
| 195 | friend class Bars3DController; |
| 196 | friend class AbstractDeclarative; |
| 197 | friend class Abstract3DController; |
| 198 | }; |
| 199 | |
| 200 | QT_END_NAMESPACE_DATAVISUALIZATION |
| 201 | |
| 202 | #endif |
| 203 | |