aboutsummaryrefslogtreecommitdiffstats
path: root/src/quickvectorimage/helpers/qquicklayeritem.cpp
blob: fa916b10ef753e037855740016843350ad80e33d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright (C) 2025 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#include "qquicklayeritem_p.h"
#include <QtQuick/private/qquickitem_p.h>

QT_BEGIN_NAMESPACE

/*!
    \qmltype LayerItem
    \inqmlmodule QtQuick.VectorImage.Helpers
    \brief An Item that provides access to its transformation matrix as a property.

    The LayerItem type maintains a \c transformMatrix property, which at any time will contain the
    combination of the item's own transform with all its ancestors' transforms. It is used in
    particular to support linked transforms in certain vector graphics formats. As any type in
    the \c VectorImage.Helpers module, it is only intended to be used in code generated by
    \l VectorImage and related tools.
*/
QQuickLayerItem::QQuickLayerItem(QQuickItem *parent)
    : QQuickItem(parent)
{
}

/*!
    \qmlproperty matrix4x4 QtQuick.VectorImage.Helpers::LayerItem::transformMatrix

    The result of combining this item's transform with the transforms of its entire
    ancestor chain.
*/
QMatrix4x4 QQuickLayerItem::transformMatrix()
{
    Q_D(const QQuickItem);
    if (m_transformDirty) {
        m_transformDirty = false;
        QTransform xf;
        d->itemToParentTransform(&xf);
        m_transform = xf;
    }
    return m_transform;
}

void QQuickLayerItem::itemChange(ItemChange change, const ItemChangeData &value)
{
    if (change == ItemTransformHasChanged) {
        m_transformDirty = true;
        emit transformMatrixChanged();
    }

    QQuickItem::itemChange(change, value);
}

QT_END_NAMESPACE

#include <moc_qquicklayeritem_p.cpp>