1 | // Copyright (C) 2016 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 | #include "quick3dmorphinganimation_p.h" |
5 | |
6 | QT_BEGIN_NAMESPACE |
7 | |
8 | namespace Qt3DAnimation { |
9 | namespace Quick { |
10 | |
11 | QQuick3DMorphingAnimation::QQuick3DMorphingAnimation(QObject *parent) |
12 | : QObject(parent) |
13 | { |
14 | } |
15 | |
16 | QQmlListProperty<Qt3DAnimation::QMorphTarget> QQuick3DMorphingAnimation::morphTargets() |
17 | { |
18 | using qt_size_type = qsizetype; |
19 | using ListContentType = Qt3DAnimation::QMorphTarget; |
20 | auto appendFunction = [](QQmlListProperty<ListContentType> *list, ListContentType *morphTarget) { |
21 | QQuick3DMorphingAnimation *animation = qobject_cast<QQuick3DMorphingAnimation *>(object: list->object); |
22 | if (animation) |
23 | animation->parentMorphingAnimation()->addMorphTarget(target: morphTarget); |
24 | }; |
25 | auto countFunction = [](QQmlListProperty<ListContentType> *list) -> qt_size_type { |
26 | QQuick3DMorphingAnimation *animation = qobject_cast<QQuick3DMorphingAnimation *>(object: list->object); |
27 | if (animation) |
28 | return animation->parentMorphingAnimation()->morphTargetList().size(); |
29 | return 0; |
30 | }; |
31 | auto atFunction = [](QQmlListProperty<ListContentType> *list, qt_size_type index) -> ListContentType * { |
32 | QQuick3DMorphingAnimation *animation = qobject_cast<QQuick3DMorphingAnimation *>(object: list->object); |
33 | if (animation) { |
34 | return qobject_cast<Qt3DAnimation::QMorphTarget *>( |
35 | object: animation->parentMorphingAnimation()->morphTargetList().at(i: index)); |
36 | } |
37 | return nullptr; |
38 | }; |
39 | auto clearFunction = [](QQmlListProperty<ListContentType> *list) { |
40 | QQuick3DMorphingAnimation *animation = qobject_cast<QQuick3DMorphingAnimation *>(object: list->object); |
41 | if (animation) |
42 | animation->parentMorphingAnimation()->setMorphTargets({}); |
43 | }; |
44 | |
45 | return QQmlListProperty<ListContentType>(this, nullptr, appendFunction, countFunction, atFunction, clearFunction); |
46 | } |
47 | |
48 | } // namespace Quick |
49 | } // namespace Qt3DAnimation |
50 | |
51 | QT_END_NAMESPACE |
52 | |
53 | #include "moc_quick3dmorphinganimation_p.cpp" |
54 |