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 COLORGRADIENT_P_H
15#define COLORGRADIENT_P_H
16
17#include <private/datavisualizationglobal_p.h>
18#include <QtGui/QColor>
19#include <QtQml/qqml.h>
20
21QT_BEGIN_NAMESPACE
22
23class ColorGradientStop : public QObject
24{
25 Q_OBJECT
26
27 Q_PROPERTY(qreal position READ position WRITE setPosition NOTIFY positionChanged)
28 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
29
30 QML_ELEMENT
31 QML_ADDED_IN_VERSION(1, 0)
32
33public:
34 ColorGradientStop(QObject *parent = 0);
35
36 qreal position() const;
37 void setPosition(qreal position);
38
39 QColor color() const;
40 void setColor(const QColor &color);
41
42Q_SIGNALS:
43 void positionChanged(qreal position);
44 void colorChanged(const QColor &color);
45
46private:
47 void updateGradient();
48
49private:
50 qreal m_position;
51 QColor m_color;
52};
53
54class ColorGradient : public QObject
55{
56 Q_OBJECT
57
58 Q_PROPERTY(QQmlListProperty<ColorGradientStop> stops READ stops)
59 Q_CLASSINFO("DefaultProperty", "stops")
60
61 QML_ELEMENT
62 QML_ADDED_IN_VERSION(1, 0)
63
64public:
65 ColorGradient(QObject *parent = 0);
66 ~ColorGradient();
67
68 QQmlListProperty<ColorGradientStop> stops();
69
70 void doUpdate();
71 QList<ColorGradientStop *> m_stops;
72
73Q_SIGNALS:
74 void updated();
75};
76
77QT_END_NAMESPACE
78
79#endif
80

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