Rename Qt Quick-specific classes to QQuick*
[profile/ivi/qtdeclarative.git] / src / declarative / particles / qsgtargetaffector_p.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
6 **
7 ** This file is part of the Declarative module of the Qt Toolkit.
8 **
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 **
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 **
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
29 **
30 ** Other Usage
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #ifndef QSGTARGETAFFECTOR_H
43 #define QSGTARGETAFFECTOR_H
44
45 #include "qsgparticleaffector_p.h"
46
47 class QSGTargetAffector : public QSGParticleAffector
48 {
49     Q_OBJECT
50     Q_PROPERTY(int targetX READ targetX WRITE setTargetX NOTIFY targetXChanged)
51     Q_PROPERTY(int targetY READ targetY WRITE setTargetY NOTIFY targetYChanged)
52     Q_PROPERTY(int targetWidth READ targetWidth WRITE setTargetWidth NOTIFY targetWidthChanged)
53     Q_PROPERTY(int targetHeight READ targetHeight WRITE setTargetHeight NOTIFY targetHeightChanged)
54     Q_PROPERTY(QSGParticleExtruder* targetShape READ targetShape WRITE setTargetShape NOTIFY targetShapeChanged)
55     Q_PROPERTY(int targetTime READ targetTime WRITE setTargetTime NOTIFY targetTimeChanged)
56
57 public:
58     explicit QSGTargetAffector(QQuickItem *parent = 0);
59
60     int targetX() const
61     {
62         return m_targetX;
63     }
64
65     int targetY() const
66     {
67         return m_targetY;
68     }
69
70     int targetWidth() const
71     {
72         return m_targetWidth;
73     }
74
75     int targetHeight() const
76     {
77         return m_targetHeight;
78     }
79
80     QSGParticleExtruder* targetShape() const
81     {
82         return m_targetShape;
83     }
84
85     int targetTime() const
86     {
87         return m_targetTime;
88     }
89
90 signals:
91
92     void targetXChanged(int arg);
93
94     void targetYChanged(int arg);
95
96     void targetWidthChanged(int arg);
97
98     void targetHeightChanged(int arg);
99
100     void targetShapeChanged(QSGParticleExtruder* arg);
101
102     void targetTimeChanged(int arg);
103
104 public slots:
105     void setTargetX(int arg)
106     {
107         if (m_targetX != arg) {
108             m_targetX = arg;
109             emit targetXChanged(arg);
110         }
111     }
112
113     void setTargetY(int arg)
114     {
115         if (m_targetY != arg) {
116             m_targetY = arg;
117             emit targetYChanged(arg);
118         }
119     }
120
121     void setTargetWidth(int arg)
122     {
123         if (m_targetWidth != arg) {
124             m_targetWidth = arg;
125             emit targetWidthChanged(arg);
126         }
127     }
128
129     void setTargetHeight(int arg)
130     {
131         if (m_targetHeight != arg) {
132             m_targetHeight = arg;
133             emit targetHeightChanged(arg);
134         }
135     }
136
137     void setTargetShape(QSGParticleExtruder* arg)
138     {
139         if (m_targetShape != arg) {
140             m_targetShape = arg;
141             emit targetShapeChanged(arg);
142         }
143     }
144
145     void setTargetTime(int arg)
146     {
147         if (m_targetTime != arg) {
148             m_targetTime = arg;
149             emit targetTimeChanged(arg);
150         }
151     }
152
153 protected:
154     virtual void reset(QSGParticleData*);
155     virtual bool affectParticle(QSGParticleData *d, qreal dt);
156 private:
157     int m_targetX;
158     int m_targetY;
159     int m_targetWidth;
160     int m_targetHeight;
161     QSGParticleExtruder* m_defaultShape;
162     QSGParticleExtruder* m_targetShape;
163     int m_targetTime;
164
165     QHash<QPair<int, int>, QPointF> m_targets;
166 };
167
168 #endif // QSGTARGETAFFECTOR_H