1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QQUICKMATERIALRIPPLE_P_H
5#define QQUICKMATERIALRIPPLE_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtQuick/qquickitem.h>
19#include <QtGui/qcolor.h>
20#include <QtCore/private/qglobal_p.h>
21
22QT_BEGIN_NAMESPACE
23
24class QQuickMaterialRipple : public QQuickItem
25{
26 Q_OBJECT
27 Q_PROPERTY(QColor color READ color WRITE setColor FINAL)
28 Q_PROPERTY(qreal clipRadius READ clipRadius WRITE setClipRadius FINAL)
29 Q_PROPERTY(bool pressed READ isPressed WRITE setPressed FINAL)
30 Q_PROPERTY(bool active READ isActive WRITE setActive FINAL)
31 Q_PROPERTY(QQuickItem *anchor READ anchor WRITE setAnchor FINAL)
32 Q_PROPERTY(Trigger trigger READ trigger WRITE setTrigger FINAL)
33 QML_NAMED_ELEMENT(Ripple)
34 QML_ADDED_IN_VERSION(2, 0)
35
36public:
37 QQuickMaterialRipple(QQuickItem *parent = nullptr);
38
39 QColor color() const;
40 void setColor(const QColor &color);
41
42 qreal clipRadius() const;
43 void setClipRadius(qreal radius);
44
45 bool isActive() const;
46 void setActive(bool active);
47
48 bool isPressed() const;
49 void setPressed(bool pressed);
50
51 enum Trigger { Press, Release };
52 Q_ENUM (Trigger)
53
54 Trigger trigger() const;
55 void setTrigger(Trigger trigger);
56
57 QPointF anchorPoint() const;
58
59 QQuickItem *anchor() const;
60 void setAnchor(QQuickItem *anchor);
61
62 qreal diameter() const;
63
64protected:
65 void itemChange(ItemChange change, const ItemChangeData &data) override;
66 QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) override;
67 void timerEvent(QTimerEvent *event) override;
68
69 void prepareWave();
70 void enterWave();
71 void exitWave();
72
73private:
74 bool m_active = false;
75 bool m_pressed = false;
76 int m_waves = 0;
77 int m_enterDelay = 0;
78 Trigger m_trigger = Press;
79 qreal m_clipRadius = 0.0;
80 QColor m_color;
81 QQuickItem *m_anchor = nullptr;
82};
83
84QT_END_NAMESPACE
85
86QML_DECLARE_TYPE(QQuickMaterialRipple)
87
88#endif // QQUICKMATERIALRIPPLE_P_H
89

source code of qtdeclarative/src/quickcontrols/material/impl/qquickmaterialripple_p.h