1 | // Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB). |
---|---|
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 "qclipblendvalue.h" |
5 | #include "qclipblendvalue_p.h" |
6 | #include <Qt3DAnimation/qabstractanimationclip.h> |
7 | |
8 | QT_BEGIN_NAMESPACE |
9 | |
10 | namespace Qt3DAnimation { |
11 | |
12 | QClipBlendValuePrivate::QClipBlendValuePrivate() |
13 | : QAbstractClipBlendNodePrivate() |
14 | , m_clip(nullptr) |
15 | { |
16 | } |
17 | |
18 | /*! |
19 | \class Qt3DAnimation::QClipBlendValue |
20 | \inherits Qt3DAnimation::QAbstractClipBlendNode |
21 | \inmodule Qt3DAnimation |
22 | \brief Class used for including a clip in a blend tree. |
23 | */ |
24 | /*! |
25 | \qmltype ClipBlendValue |
26 | \instantiates Qt3DAnimation::QClipBlendValue |
27 | \inqmlmodule Qt3D.Animation |
28 | \brief Type used for including a clip in a blend tree. |
29 | */ |
30 | /*! |
31 | \property Qt3DAnimation::QClipBlendValue::clip |
32 | |
33 | The animation clip that needs to be included in the blend tree. |
34 | */ |
35 | /*! |
36 | \qmlproperty AbstractAnimationClip ClipBlendValue::clip |
37 | |
38 | The animation clip that needs to be included in the blend tree. |
39 | */ |
40 | QClipBlendValue::QClipBlendValue(Qt3DCore::QNode *parent) |
41 | : QAbstractClipBlendNode(*new QClipBlendValuePrivate(), parent) |
42 | { |
43 | } |
44 | |
45 | QClipBlendValue::QClipBlendValue(Qt3DAnimation::QAbstractAnimationClip *clip, |
46 | Qt3DCore::QNode *parent) |
47 | : QAbstractClipBlendNode(*new QClipBlendValuePrivate(), parent) |
48 | { |
49 | setClip(clip); |
50 | } |
51 | |
52 | QClipBlendValue::QClipBlendValue(QClipBlendValuePrivate &dd, Qt3DCore::QNode *parent) |
53 | : QAbstractClipBlendNode(dd, parent) |
54 | { |
55 | } |
56 | |
57 | QClipBlendValue::~QClipBlendValue() |
58 | { |
59 | } |
60 | |
61 | Qt3DAnimation::QAbstractAnimationClip *QClipBlendValue::clip() const |
62 | { |
63 | Q_D(const QClipBlendValue); |
64 | return d->m_clip; |
65 | } |
66 | |
67 | void QClipBlendValue::setClip(Qt3DAnimation::QAbstractAnimationClip *clip) |
68 | { |
69 | Q_D(QClipBlendValue); |
70 | if (d->m_clip == clip) |
71 | return; |
72 | |
73 | if (d->m_clip) |
74 | d->unregisterDestructionHelper(node: d->m_clip); |
75 | |
76 | if (clip && !clip->parent()) |
77 | clip->setParent(this); |
78 | d->m_clip = clip; |
79 | |
80 | // Ensures proper bookkeeping |
81 | if (d->m_clip) |
82 | d->registerDestructionHelper(node: d->m_clip, func: &QClipBlendValue::setClip, d->m_clip); |
83 | emit clipChanged(clip); |
84 | } |
85 | |
86 | } // namespace Qt3DAnimation |
87 | |
88 | QT_END_NAMESPACE |
89 | |
90 | #include "moc_qclipblendvalue.cpp" |
91 |