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 "quick3dkeyframeanimation_p.h"
5
6QT_BEGIN_NAMESPACE
7
8namespace Qt3DAnimation {
9namespace Quick {
10
11QQuick3DKeyframeAnimation::QQuick3DKeyframeAnimation(QObject *parent)
12 : QObject(parent)
13{
14}
15
16QQmlListProperty<Qt3DCore::QTransform> QQuick3DKeyframeAnimation::keyframes()
17{
18 using qt_size_type = qsizetype;
19 using ListContentType = Qt3DCore::QTransform;
20 auto appendFunction = [](QQmlListProperty<ListContentType> *list, ListContentType *transform) {
21 QQuick3DKeyframeAnimation *keyframeAnimation
22 = qobject_cast<QQuick3DKeyframeAnimation *>(object: list->object);
23 if (keyframeAnimation)
24 keyframeAnimation->parentKeyframeAnimation()->addKeyframe(keyframe: transform);
25 };
26 auto countFunction = [](QQmlListProperty<ListContentType> *list) -> qt_size_type {
27 QQuick3DKeyframeAnimation *keyframeAnimation
28 = qobject_cast<QQuick3DKeyframeAnimation *>(object: list->object);
29 if (keyframeAnimation)
30 return keyframeAnimation->parentKeyframeAnimation()->keyframeList().size();
31 return 0;
32 };
33 auto atFunction = [](QQmlListProperty<ListContentType> *list, qt_size_type index) -> ListContentType * {
34 QQuick3DKeyframeAnimation *keyframeAnimation
35 = qobject_cast<QQuick3DKeyframeAnimation *>(object: list->object);
36 if (keyframeAnimation)
37 return qobject_cast<Qt3DCore::QTransform *>(object: keyframeAnimation->parentKeyframeAnimation()->keyframeList().at(i: index));
38 return nullptr;
39 };
40 auto clearFunction = [](QQmlListProperty<ListContentType> *list) {
41 QQuick3DKeyframeAnimation *keyframeAnimation
42 = qobject_cast<QQuick3DKeyframeAnimation *>(object: list->object);
43 if (keyframeAnimation) {
44 QList<Qt3DCore::QTransform *> emptyList;
45 keyframeAnimation->parentKeyframeAnimation()->setKeyframes(emptyList);
46 }
47 };
48
49 return QQmlListProperty<ListContentType>(this, nullptr, appendFunction, countFunction, atFunction, clearFunction);
50}
51
52} // namespace Quick
53} // namespace Qt3DAnimation
54
55QT_END_NAMESPACE
56
57#include "moc_quick3dkeyframeanimation_p.cpp"
58

source code of qt3d/src/quick3d/quick3danimation/items/quick3dkeyframeanimation.cpp