44 start(qRound(1000.0 * qSqrt(ripple->diameter() / 2.0 / WAVE_TOUCH_DOWN_ACCELERATION)));
46 QSGOpacityNode *opacityNode =
new QSGOpacityNode;
47 appendChildNode(opacityNode);
49 QQuickItemPrivate *d = QQuickItemPrivate::get(ripple);
50 QSGInternalRectangleNode *rectNode = d->sceneGraphContext()->createInternalRectangleNode();
51 rectNode->setAntialiasing(
true);
52 opacityNode->appendChildNode(rectNode);
68 p = time /
static_cast<qreal>(duration());
70 m_value = m_from + (m_to - m_from) * p;
73 const qreal dx = (1.0 - p) * (m_anchor.x() - m_bounds.width() / 2);
74 const qreal dy = (1.0 - p) * (m_anchor.y() - m_bounds.height() / 2);
77 m.translate(qRound((m_bounds.width() - m_value) / 2 + dx),
78 qRound((m_bounds.height() - m_value) / 2 + dy));
81 QSGOpacityNode *opacityNode =
static_cast<QSGOpacityNode *>(firstChild());
82 Q_ASSERT(opacityNode->type() == QSGNode::OpacityNodeType);
86 opacityNode->setOpacity(opacity);
88 QSGInternalRectangleNode *rectNode =
static_cast<QSGInternalRectangleNode *>(opacityNode->firstChild());
89 Q_ASSERT(rectNode->type() == QSGNode::GeometryNodeType);
90 rectNode->setRect(QRectF(0, 0, m_value, m_value));
91 rectNode->setRadius(m_value / 2);
97 QQuickMaterialRipple *ripple =
static_cast<QQuickMaterialRipple *>(item);
98 m_to = ripple->diameter();
99 m_anchor = ripple->anchorPoint();
100 m_bounds = ripple->boundingRect();
102 QSGOpacityNode *opacityNode =
static_cast<QSGOpacityNode *>(firstChild());
103 Q_ASSERT(opacityNode->type() == QSGNode::OpacityNodeType);
105 QSGInternalRectangleNode *rectNode =
static_cast<QSGInternalRectangleNode *>(opacityNode->firstChild());
106 Q_ASSERT(rectNode->type() == QSGNode::GeometryNodeType);
107 rectNode->setColor(ripple->color());
125 : QQuickAnimatedNode(ripple)
129 QSGOpacityNode *opacityNode =
new QSGOpacityNode;
130 opacityNode->setOpacity(0.0);
131 appendChildNode(opacityNode);
133 QQuickItemPrivate *d = QQuickItemPrivate::get(ripple);
134 QSGInternalRectangleNode *rectNode = d->sceneGraphContext()->createInternalRectangleNode();
135 rectNode->setAntialiasing(
true);
136 opacityNode->appendChildNode(rectNode);
152 QQuickMaterialRipple *ripple =
static_cast<QQuickMaterialRipple *>(item);
153 if (m_active != ripple->isActive()) {
154 m_active = ripple->isActive();
159 QSGOpacityNode *opacityNode =
static_cast<QSGOpacityNode *>(firstChild());
160 Q_ASSERT(opacityNode->type() == QSGNode::OpacityNodeType);
162 QSGInternalRectangleNode *rectNode =
static_cast<QSGInternalRectangleNode *>(opacityNode->firstChild());
163 Q_ASSERT(rectNode->type() == QSGNode::GeometryNodeType);
165 const qreal w = ripple->width();
166 const qreal h = ripple->height();
167 const qreal sz = qSqrt(w * w + h * h);
170 if (qFuzzyIsNull(ripple->clipRadius())) {
171 matrix.translate(qRound((w - sz) / 2), qRound((h - sz) / 2));
172 rectNode->setRect(QRectF(0, 0, sz, sz));
173 rectNode->setRadius(sz / 2);
175 rectNode->setRect(QRectF(0, 0, w, h));
176 rectNode->setRadius(ripple->clipRadius());
180 rectNode->setColor(ripple->color());
272QPointF QQuickMaterialRipple::anchorPoint()
const
274 const QRectF bounds = boundingRect();
275 const QPointF center = bounds.center();
279 QPointF anchorPoint = bounds.center();
280 if (QQuickAbstractButton *button = qobject_cast<QQuickAbstractButton *>(m_anchor))
281 anchorPoint = QQuickAbstractButtonPrivate::get(button)->pressPoint;
282 anchorPoint = mapFromItem(m_anchor, anchorPoint);
286 const qreal r = qSqrt(bounds.width() * bounds.width() + bounds.height() * bounds.height()) / 2;
287 if (QLineF(center, anchorPoint).length() < r)
293 const qreal p = qAtan2(anchorPoint.y() - center.y(), anchorPoint.x() - center.x());
294 return QPointF(center.x() + r * qCos(p), center.y() + r * qSin(p));
319QSGNode *QQuickMaterialRipple::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
321 QQuickItemPrivate *d = QQuickItemPrivate::get(
this);
322 QQuickDefaultClipNode *clipNode = d->clipNode();
324 clipNode->setRadius(m_clipRadius);
325 clipNode->setRect(boundingRect());
329 QSGNode *container = oldNode;
331 container =
new QSGNode;
334 if (!backgroundNode) {
335 backgroundNode =
new QQuickMaterialRippleBackgroundNode(
this);
336 backgroundNode->setObjectName(objectName());
337 container->appendChildNode(backgroundNode);
339 backgroundNode->sync(
this);
347 container->appendChildNode(enterNode);
349 enterNode->sync(
this);
354 int j = container->childCount() - 1 - m_waves;
359 exitNode->sync(
this);