1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#include "colorgradient_p.h"
5
6QT_BEGIN_NAMESPACE
7
8ColorGradientStop::ColorGradientStop(QObject *parent)
9 : QObject(parent)
10{
11}
12
13qreal ColorGradientStop::position() const
14{
15 return m_position;
16}
17
18void ColorGradientStop::setPosition(qreal position)
19{
20 m_position = position;
21 updateGradient();
22 emit positionChanged(position);
23}
24
25QColor ColorGradientStop::color() const
26{
27 return m_color;
28}
29
30void ColorGradientStop::setColor(const QColor &color)
31{
32 m_color = color;
33 updateGradient();
34 emit colorChanged(color);
35}
36
37void ColorGradientStop::updateGradient()
38{
39 if (ColorGradient *grad = qobject_cast<ColorGradient*>(object: parent()))
40 grad->doUpdate();
41}
42
43ColorGradient::ColorGradient(QObject *parent)
44: QObject(parent)
45{
46}
47
48ColorGradient::~ColorGradient()
49{
50}
51
52QQmlListProperty<ColorGradientStop> ColorGradient::stops()
53{
54 return QQmlListProperty<ColorGradientStop>(this, &m_stops);
55}
56
57void ColorGradient::doUpdate()
58{
59 emit updated();
60}
61
62QT_END_NAMESPACE
63

source code of qtdatavis3d/src/datavisualizationqml/colorgradient.cpp