1 /****************************************************************************
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the Declarative module of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** No Commercial Usage
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** GNU Lesser General Public License Usage
17 ** Alternatively, this file may be used under the terms of the GNU Lesser
18 ** General Public License version 2.1 as published by the Free Software
19 ** Foundation and appearing in the file LICENSE.LGPL included in the
20 ** packaging of this file. Please review the following information to
21 ** ensure the GNU Lesser General Public License version 2.1 requirements
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 ** In addition, as a special exception, Nokia gives you certain additional
25 ** rights. These rights are described in the Nokia Qt LGPL Exception
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
40 ****************************************************************************/
42 #ifndef ITEMPARTICLE_H
43 #define ITEMPARTICLE_H
51 QT_MODULE(Declarative)
52 class QSGVisualDataModel;
53 class ItemParticleAttached;
55 class ItemParticle : public ParticleType
59 Q_PROPERTY(bool fade READ fade WRITE setFade NOTIFY fadeChanged)
61 explicit ItemParticle(QSGItem *parent = 0);
63 bool fade() const { return m_fade; }
65 virtual QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *);
66 virtual void load(ParticleData*);
67 virtual void reload(ParticleData*);
68 virtual void setCount(int c);
71 static ItemParticleAttached *qmlAttachedProperties(QObject *object);
76 void freeze(QSGItem* item);
77 void unfreeze(QSGItem* item);
78 void take(QSGItem* item,bool prioritize=false);//take by modelparticle
79 void give(QSGItem* item);//give from modelparticle
81 void setFade(bool arg){if(arg == m_fade) return; m_fade = arg; emit fadeChanged();}
84 void prepareNextFrame();
86 QList<QPointer<QSGItem> > m_deletables;
90 QList<QSGItem*> m_pendingItems;
91 QVector<QSGItem*> m_items;
92 QVector<ParticleData*> m_data;
94 QList<int> m_available;
95 QSet<QSGItem*> m_stasis;
100 class ItemParticleAttached : public QObject
103 Q_PROPERTY(ItemParticle* particle READ particle CONSTANT);
105 ItemParticleAttached(QObject* parent)
106 : QObject(parent), m_mp(0)
108 ItemParticle* particle() {return m_mp;}
109 void detach(){emit detached();}
110 void attach(){emit attached();}
113 friend class ItemParticle;
121 QML_DECLARE_TYPEINFO(ItemParticle, QML_HAS_ATTACHED_PROPERTIES)
124 #endif // ITEMPARTICLE_H