1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4//
5// W A R N I N G
6// -------------
7//
8// This file is not part of the QtDataVisualization API. It exists purely as an
9// implementation detail. This header file may change from version to
10// version without notice, or even be removed.
11//
12// We mean it.
13
14#ifndef DECLARATIVETHEME_P_H
15#define DECLARATIVETHEME_P_H
16
17#include <private/datavisualizationglobal_p.h>
18#include <private/q3dtheme_p.h>
19
20#include "declarativecolor_p.h"
21#include "colorgradient_p.h"
22
23#include <QtQml/qqml.h>
24#include <QtQml/qqmlparserstatus.h>
25
26QT_BEGIN_NAMESPACE
27
28class DeclarativeTheme3D : public Q3DTheme, public QQmlParserStatus
29{
30 Q_OBJECT
31 Q_INTERFACES(QQmlParserStatus)
32 Q_PROPERTY(QQmlListProperty<QObject> themeChildren READ themeChildren)
33 Q_PROPERTY(QQmlListProperty<DeclarativeColor> baseColors READ baseColors)
34 Q_PROPERTY(QQmlListProperty<ColorGradient> baseGradients READ baseGradients)
35 Q_PROPERTY(ColorGradient *singleHighlightGradient READ singleHighlightGradient WRITE setSingleHighlightGradient NOTIFY singleHighlightGradientChanged)
36 Q_PROPERTY(ColorGradient *multiHighlightGradient READ multiHighlightGradient WRITE setMultiHighlightGradient NOTIFY multiHighlightGradientChanged)
37 Q_CLASSINFO("DefaultProperty", "themeChildren")
38 QML_NAMED_ELEMENT(Theme3D)
39 QML_ADDED_IN_VERSION(1, 0)
40
41public:
42 DeclarativeTheme3D(QObject *parent = 0);
43 virtual ~DeclarativeTheme3D();
44
45 QQmlListProperty<QObject> themeChildren();
46 static void appendThemeChildren(QQmlListProperty<QObject> *list, QObject *element);
47
48 QQmlListProperty<DeclarativeColor> baseColors();
49 static void appendBaseColorsFunc(QQmlListProperty<DeclarativeColor> *list,
50 DeclarativeColor *color);
51 static qsizetype countBaseColorsFunc(QQmlListProperty<DeclarativeColor> *list);
52 static DeclarativeColor *atBaseColorsFunc(QQmlListProperty<DeclarativeColor> *list,
53 qsizetype index);
54 static void clearBaseColorsFunc(QQmlListProperty<DeclarativeColor> *list);
55
56 QQmlListProperty<ColorGradient> baseGradients();
57 static void appendBaseGradientsFunc(QQmlListProperty<ColorGradient> *list,
58 ColorGradient *gradient);
59 static qsizetype countBaseGradientsFunc(QQmlListProperty<ColorGradient> *list);
60 static ColorGradient *atBaseGradientsFunc(QQmlListProperty<ColorGradient> *list,
61 qsizetype index);
62 static void clearBaseGradientsFunc(QQmlListProperty<ColorGradient> *list);
63
64 void setSingleHighlightGradient(ColorGradient *gradient);
65 ColorGradient *singleHighlightGradient() const;
66
67 void setMultiHighlightGradient(ColorGradient *gradient);
68 ColorGradient *multiHighlightGradient() const;
69
70 // From QQmlParserStatus
71 void classBegin() override;
72 void componentComplete() override;
73
74Q_SIGNALS:
75 void singleHighlightGradientChanged(ColorGradient *gradient);
76 void multiHighlightGradientChanged(ColorGradient *gradient);
77
78protected:
79 void handleTypeChange(Theme themeType);
80 void handleBaseColorUpdate();
81 void handleBaseGradientUpdate();
82 void handleSingleHLGradientUpdate();
83 void handleMultiHLGradientUpdate();
84
85 enum GradientType {
86 GradientTypeBase = 0,
87 GradientTypeSingleHL,
88 GradientTypeMultiHL
89 };
90
91private:
92 void addColor(DeclarativeColor *color);
93 QList<DeclarativeColor *> colorList();
94 void clearColors();
95 void clearDummyColors();
96
97 void addGradient(ColorGradient *gradient);
98 QList<ColorGradient *> gradientList();
99 void clearGradients();
100 void clearDummyGradients();
101
102 void setThemeGradient(ColorGradient *gradient, GradientType type);
103 QLinearGradient convertGradient(ColorGradient *gradient);
104 ColorGradient *convertGradient(const QLinearGradient &gradient);
105
106 QList<DeclarativeColor *> m_colors; // Not owned
107 QList<ColorGradient *> m_gradients; // Not owned
108 ColorGradient *m_singleHLGradient; // Not owned
109 ColorGradient *m_multiHLGradient; // Not owned
110
111 bool m_dummyGradients;
112 bool m_dummyColors;
113};
114
115QT_END_NAMESPACE
116
117#endif
118

source code of qtdatavis3d/src/datavisualizationqml/declarativetheme_p.h