| 1 | // Copyright (C) 2025 The Qt Company Ltd. |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #include "qquicklayeritem_p.h" |
| 5 | #include <QtQuick/private/qquickitem_p.h> |
| 6 | |
| 7 | QT_BEGIN_NAMESPACE |
| 8 | |
| 9 | /*! |
| 10 | \qmltype LayerItem |
| 11 | \inqmlmodule Qt.labs.lottieqt.VectorImageHelpers |
| 12 | \brief An Item that provides access to its transformation matrix as a property. |
| 13 | |
| 14 | The LayerItem type maintains a \c transformMatrix property, which at any time will contain the |
| 15 | combination of the item's own transform with all its ancestors' transforms. It is used in |
| 16 | particular to support linked transforms in certain vector graphics formats. As any type in |
| 17 | the \c VectorImageHelpers module, it is only intended to be used in code generated by |
| 18 | \l VectorImage and related tools. |
| 19 | */ |
| 20 | QQuickLayerItem::QQuickLayerItem(QQuickItem *parent) |
| 21 | : QQuickItem(parent) |
| 22 | { |
| 23 | } |
| 24 | |
| 25 | /*! |
| 26 | \qmlproperty matrix4x4 Qt.labs.lottieqt.VectorImageHelpers::LayerItem::transformMatrix |
| 27 | |
| 28 | The result of combining this item's transform with the transforms of its entire |
| 29 | ancestor chain. |
| 30 | */ |
| 31 | QMatrix4x4 QQuickLayerItem::transformMatrix() |
| 32 | { |
| 33 | Q_D(const QQuickItem); |
| 34 | if (m_transformDirty) { |
| 35 | m_transformDirty = false; |
| 36 | QTransform xf; |
| 37 | d->itemToParentTransform(&xf); |
| 38 | m_transform = xf; |
| 39 | } |
| 40 | return m_transform; |
| 41 | } |
| 42 | |
| 43 | void QQuickLayerItem::itemChange(ItemChange change, const ItemChangeData &value) |
| 44 | { |
| 45 | if (change == ItemTransformHasChanged) { |
| 46 | m_transformDirty = true; |
| 47 | emit transformMatrixChanged(); |
| 48 | } |
| 49 | |
| 50 | QQuickItem::itemChange(change, value); |
| 51 | } |
| 52 | |
| 53 | QT_END_NAMESPACE |
| 54 | |
| 55 | #include <moc_qquicklayeritem_p.cpp> |
| 56 |
