1 | // Copyright (C) 2015 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 <Qt3DQuickRender/private/quick3dstateset_p.h> |
5 | |
6 | QT_BEGIN_NAMESPACE |
7 | |
8 | namespace Qt3DRender { |
9 | namespace Render { |
10 | namespace Quick { |
11 | |
12 | Quick3DStateSet::Quick3DStateSet(QObject *parent) |
13 | : QObject(parent) |
14 | { |
15 | } |
16 | |
17 | Quick3DStateSet::~Quick3DStateSet() |
18 | { |
19 | } |
20 | |
21 | QQmlListProperty<QRenderState> Quick3DStateSet::renderStateList() |
22 | { |
23 | using qt_size_type = qsizetype; |
24 | using ListContentType = QRenderState; |
25 | auto appendFunction = [](QQmlListProperty<ListContentType> *list, ListContentType *state) { |
26 | Quick3DStateSet *stateSet = qobject_cast<Quick3DStateSet *>(object: list->object); |
27 | stateSet->parentStateSet()->addRenderState(state); |
28 | }; |
29 | auto countFunction = [](QQmlListProperty<ListContentType> *list) -> qt_size_type { |
30 | Quick3DStateSet *stateSet = qobject_cast<Quick3DStateSet *>(object: list->object); |
31 | return stateSet->parentStateSet()->renderStates().size(); |
32 | }; |
33 | auto atFunction = [](QQmlListProperty<ListContentType> *list, qt_size_type index) -> ListContentType * { |
34 | Quick3DStateSet *stateSet = qobject_cast<Quick3DStateSet *>(object: list->object); |
35 | return stateSet->parentStateSet()->renderStates().at(i: index); |
36 | }; |
37 | auto clearFunction = [](QQmlListProperty<ListContentType> *list) { |
38 | Quick3DStateSet *stateSet = qobject_cast<Quick3DStateSet *>(object: list->object); |
39 | const auto states = stateSet->parentStateSet()->renderStates(); |
40 | for (QRenderState *s : states) |
41 | stateSet->parentStateSet()->removeRenderState(state: s); |
42 | }; |
43 | |
44 | return QQmlListProperty<ListContentType>(this, nullptr, appendFunction, countFunction, atFunction, clearFunction); |
45 | } |
46 | |
47 | } // namespace Quick |
48 | } // namespace Render |
49 | } // namespace Qt3DRender |
50 | |
51 | QT_END_NAMESPACE |
52 | |
53 | #include "moc_quick3dstateset_p.cpp" |
54 | |
55 |