aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Alpert <alan.alpert@nokia.com>2011-09-06 10:40:21 +1000
committerQt by Nokia <qt-info@nokia.com>2011-09-08 08:16:48 +0200
commit1aa012a1c83ce8905e5440d3e7ae11192dc73878 (patch)
tree813b36a8637c21e9f33c858daed24b57e2b2115e
parent63982ebb2cd0aa28c456e25cc9edb400b5b881d9 (diff)
Particles module refactoring en masse
All the little changes in one commit. StochasticDirection -> Direction AngledDirection -> AngleDirection TargetedDirection -> TargetDirection QSGCustomParticle is now Affector's implementation (C++ only refactor) FollowEmitter -> TrailEmitter Kill -> Age and gained lifeLeft property ModelParticle is removed, use ItemParticle instead. Added RectangleShape to replace Shape for the case of Rectangles Abstract Types are no longer createable, despite sensible defaults. GLSL variables in CustomParticle now begin with qt_ JS variables are now such that x,vx,ax are current (old ones are now initialX, initialVX, initialAX). Same for y. A few more were extended. Emitter::emitCap -> Emitter::maximumEmitted. Set to -1 for noCap: false Emitter::noCap is gone. Emitter::emitting -> Emitter::enabled Affector::active -> Affector::enabled Affector::collisionParticles -> Affector::whenCollidingWith Affector::signal is gone. PointAttractor -> Attractor Attractor/Wander::physics -> ::affectedParameter ParticleSystem::fastForward is gone ParticleSystem::startTime is gone (use Emitter::startTime) ParticleSystem::clear -> ParticleSystem::empty And various Doc fixes. Change-Id: Ia3b02b987f692e6f1bd14c42e575381bdfb7bbb5 Reviewed-on: http://codereview.qt-project.org/4231 Reviewed-by: Alan Alpert <alan.alpert@nokia.com>
-rw-r--r--examples/declarative/flickr/content/ImageDetails.qml47
-rw-r--r--examples/declarative/flickr/content/Progress.qml4
-rw-r--r--examples/declarative/flickr/content/StreamView.qml107
-rw-r--r--examples/declarative/flickr/content/UnifiedDelegate.qml8
-rw-r--r--examples/declarative/flickr/flickr.qml74
-rw-r--r--examples/declarative/particles/allsmiles/plain.qml2
-rw-r--r--examples/declarative/particles/allsmiles/smile.qml12
-rw-r--r--examples/declarative/particles/allsmiles/smilefactory.qml14
-rw-r--r--examples/declarative/particles/allsmiles/spriteparticles.qml2
-rw-r--r--examples/declarative/particles/allsmiles/spritestateparticles.qml3
-rw-r--r--examples/declarative/particles/allsmiles/spritevariedparticles.qml3
-rw-r--r--examples/declarative/particles/allsmiles/ultraparticles.qml3
-rw-r--r--examples/declarative/particles/asteroid/asteroid.qml1
-rw-r--r--examples/declarative/particles/asteroid/blackhole.qml19
-rw-r--r--examples/declarative/particles/custom/blurparticles.qml6
-rw-r--r--examples/declarative/particles/custom/custom.qml31
-rw-r--r--examples/declarative/particles/custom/delegates.qml2
-rw-r--r--examples/declarative/particles/custom/fallingleaves.qml18
-rw-r--r--examples/declarative/particles/custom/shader.qml20
-rw-r--r--examples/declarative/particles/exampleslauncher.qml5
-rw-r--r--examples/declarative/particles/modelparticles/bubbles.qml82
-rw-r--r--examples/declarative/particles/modelparticles/content/Delegate.qml88
-rw-r--r--examples/declarative/particles/modelparticles/content/Delegate2.qml79
-rw-r--r--examples/declarative/particles/modelparticles/content/ExpandingDelegate.qml204
-rw-r--r--examples/declarative/particles/modelparticles/content/RssModel.qml53
-rw-r--r--examples/declarative/particles/modelparticles/content/bubble.pngbin3413 -> 0 bytes
-rw-r--r--examples/declarative/particles/modelparticles/content/script.js27
-rw-r--r--examples/declarative/particles/modelparticles/gridsplosion.qml144
-rw-r--r--examples/declarative/particles/modelparticles/package.qml91
-rw-r--r--examples/declarative/particles/modelparticles/stream.qml276
-rw-r--r--examples/declarative/particles/snow/snow.qml11
-rw-r--r--examples/declarative/particles/spaceexplorer/content/helpers.js8
-rw-r--r--examples/declarative/particles/spaceexplorer/content/particle4.pngbin1799 -> 0 bytes
-rw-r--r--examples/declarative/particles/spaceexplorer/content/powerupScore.pngbin83169 -> 0 bytes
-rw-r--r--examples/declarative/particles/spaceexplorer/content/powerupScore_gone.pngbin140 -> 0 bytes
-rw-r--r--examples/declarative/particles/spaceexplorer/content/powerupScore_got.pngbin81528 -> 0 bytes
-rw-r--r--examples/declarative/particles/spaceexplorer/content/rocket.pngbin7315 -> 0 bytes
-rw-r--r--examples/declarative/particles/spaceexplorer/content/rocket2.pngbin1918 -> 0 bytes
-rw-r--r--examples/declarative/particles/spaceexplorer/content/rocketEye.pngbin2073 -> 0 bytes
-rw-r--r--examples/declarative/particles/spaceexplorer/content/star.pngbin1550 -> 0 bytes
-rw-r--r--examples/declarative/particles/spaceexplorer/spaceexplorer.qml417
-rw-r--r--examples/declarative/particles/trails/combustion.qml8
-rw-r--r--examples/declarative/particles/trails/dynamicemitters.qml6
-rw-r--r--examples/declarative/particles/trails/fireballs.qml6
-rw-r--r--examples/declarative/particles/trails/fireworks.qml17
-rw-r--r--examples/declarative/particles/trails/layered.qml2
-rw-r--r--examples/declarative/particles/trails/list.qml4
-rw-r--r--examples/declarative/particles/trails/overburst.qml10
-rw-r--r--examples/declarative/particles/trails/portal.qml10
-rw-r--r--examples/declarative/particles/trails/shimmer.qml1
-rw-r--r--examples/declarative/particles/trails/trails.qml8
-rw-r--r--examples/declarative/particles/trails/turbulence.qml10
-rw-r--r--examples/declarative/plasmapatrol/content/BlasterHardpoint.qml10
-rw-r--r--examples/declarative/plasmapatrol/content/CannonHardpoint.qml6
-rw-r--r--examples/declarative/plasmapatrol/content/Cruiser.qml10
-rw-r--r--examples/declarative/plasmapatrol/content/Frigate.qml4
-rw-r--r--examples/declarative/plasmapatrol/content/LaserHardpoint.qml8
-rw-r--r--examples/declarative/plasmapatrol/content/PlasmaPatrolParticles.qml10
-rw-r--r--examples/declarative/plasmapatrol/content/Sloop.qml4
-rw-r--r--examples/declarative/plasmapatrol/plasmapatrol.qml4
-rw-r--r--examples/declarative/samegame/SamegameCore/BoomBlock.qml6
-rw-r--r--src/declarative/particles/particles.pri30
-rw-r--r--src/declarative/particles/qsgage.cpp81
-rw-r--r--src/declarative/particles/qsgage_p.h (renamed from src/declarative/particles/qsgkill.cpp)57
-rw-r--r--src/declarative/particles/qsgangledirection.cpp (renamed from src/declarative/particles/qsgangleddirection.cpp)22
-rw-r--r--src/declarative/particles/qsgangledirection_p.h (renamed from src/declarative/particles/qsgangleddirection_p.h)6
-rw-r--r--src/declarative/particles/qsgcumulativedirection.cpp10
-rw-r--r--src/declarative/particles/qsgcumulativedirection_p.h10
-rw-r--r--src/declarative/particles/qsgcustomaffector.cpp80
-rw-r--r--src/declarative/particles/qsgcustomaffector_p.h (renamed from src/declarative/particles/qsgkill_p.h)26
-rw-r--r--src/declarative/particles/qsgcustomparticle.cpp94
-rw-r--r--src/declarative/particles/qsgdirection.cpp (renamed from src/declarative/particles/qsgstochasticdirection.cpp)10
-rw-r--r--src/declarative/particles/qsgdirection_p.h (renamed from src/declarative/particles/qsgstochasticdirection_p.h)4
-rw-r--r--src/declarative/particles/qsgimageparticle.cpp6
-rw-r--r--src/declarative/particles/qsgimageparticle_p.h22
-rw-r--r--src/declarative/particles/qsgmodelparticle.cpp335
-rw-r--r--src/declarative/particles/qsgmodelparticle_p.h140
-rw-r--r--src/declarative/particles/qsgparticleaffector.cpp54
-rw-r--r--src/declarative/particles/qsgparticleaffector_p.h62
-rw-r--r--src/declarative/particles/qsgparticleemitter.cpp65
-rw-r--r--src/declarative/particles/qsgparticleemitter_p.h184
-rw-r--r--src/declarative/particles/qsgparticleextruder.cpp22
-rw-r--r--src/declarative/particles/qsgparticleextruder_p.h19
-rw-r--r--src/declarative/particles/qsgparticlepainter.cpp4
-rw-r--r--src/declarative/particles/qsgparticlesmodule.cpp34
-rw-r--r--src/declarative/particles/qsgparticlesystem.cpp81
-rw-r--r--src/declarative/particles/qsgparticlesystem_p.h32
-rw-r--r--src/declarative/particles/qsgpointattractor.cpp42
-rw-r--r--src/declarative/particles/qsgpointattractor_p.h20
-rw-r--r--src/declarative/particles/qsgpointdirection.cpp4
-rw-r--r--src/declarative/particles/qsgpointdirection_p.h4
-rw-r--r--src/declarative/particles/qsgrectangleextruder.cpp86
-rw-r--r--src/declarative/particles/qsgrectangleextruder_p.h88
-rw-r--r--src/declarative/particles/qsgtargetdirection.cpp (renamed from src/declarative/particles/qsgtargeteddirection.cpp)28
-rw-r--r--src/declarative/particles/qsgtargetdirection_p.h (renamed from src/declarative/particles/qsgtargeteddirection_p.h)6
-rw-r--r--src/declarative/particles/qsgtrailemitter.cpp (renamed from src/declarative/particles/qsgfollowemitter.cpp)46
-rw-r--r--src/declarative/particles/qsgtrailemitter_p.h (renamed from src/declarative/particles/qsgfollowemitter_p.h)7
-rw-r--r--src/declarative/particles/qsgturbulence.cpp2
-rw-r--r--src/declarative/particles/qsgv8particledata.cpp58
-rw-r--r--src/declarative/particles/qsgwander.cpp33
-rw-r--r--src/declarative/particles/qsgwander_p.h22
101 files changed, 1102 insertions, 2839 deletions
diff --git a/examples/declarative/flickr/content/ImageDetails.qml b/examples/declarative/flickr/content/ImageDetails.qml
index d45f8e80e9..8d3cdfb494 100644
--- a/examples/declarative/flickr/content/ImageDetails.qml
+++ b/examples/declarative/flickr/content/ImageDetails.qml
@@ -164,7 +164,7 @@ Flipable {
anchors.fill: parent
frequency: 100
strength: 250
- active: false
+ enabled: false
}
Item{
@@ -180,7 +180,7 @@ Flipable {
function imageOutAnim(){
bigImage.visible = false;
noiseIn.visible = false;
- turbulence.active = true;
+ turbulence.enabled = true;
endEffectTimer.start();
pixelEmitter.burst(2048);
}
@@ -190,7 +190,7 @@ Flipable {
repeat: false
running: false
onTriggered:{
- turbulence.active = false;
+ turbulence.enabled = false;
noiseIn.visible = false;
bigImage.visible = true;
}
@@ -245,7 +245,7 @@ Flipable {
size: 4
lifeSpan: flipDuration
emitRate: 2048
- emitting: false
+ enabled: false
}
CustomParticle{
id: blowOut
@@ -253,54 +253,23 @@ Flipable {
property real maxWidth: effectBox.width
property real maxHeight: effectBox.height
vertexShader:"
- attribute highp vec2 vPos;
- attribute highp vec2 vTex;
- attribute highp vec4 vData; // x = time, y = lifeSpan, z = size, w = endSize
- attribute highp vec4 vVec; // x,y = constant speed, z,w = acceleration
- attribute highp float r;
-
uniform highp float maxWidth;
uniform highp float maxHeight;
- uniform highp mat4 qt_Matrix;
- uniform highp float timestamp;
- uniform lowp float qt_Opacity;
-
varying highp vec2 fTex2;
- varying lowp float fFade;
void main() {
- fTex2 = vec2(vPos.x / maxWidth, vPos.y / maxHeight);
- highp float size = vData.z;
- highp float endSize = vData.w;
-
- highp float t = (timestamp - vData.x) / vData.y;
-
- highp float currentSize = mix(size, endSize, t * t);
-
- if (t < 0. || t > 1.)
- currentSize = 0.;
-
- highp vec2 pos = vPos
- - currentSize / 2. + currentSize * vTex // adjust size
- + vVec.xy * t * vData.y // apply speed vector..
- + 0.5 * vVec.zw * pow(t * vData.y, 2.);
-
- gl_Position = qt_Matrix * vec4(pos.x, pos.y, 0, 1);
-
- highp float fadeIn = min(t * 10., 1.);
- highp float fadeOut = 1. - max(0., min((t - 0.75) * 4., 1.));
-
- fFade = 1.0;//fadeIn * fadeOut * qt_Opacity;
+ defaultMain();
+ fTex2 = vec2(qt_ParticlePos.x / maxWidth, qt_ParticlePos.y / maxHeight);
}
"
property variant pictureTexture: pictureSource
fragmentShader: "
+ uniform lowp float qt_Opacity;
uniform sampler2D pictureTexture;
varying highp vec2 fTex2;
- varying highp float fFade;
void main() {
- gl_FragColor = texture2D(pictureTexture, fTex2) * fFade;
+ gl_FragColor = texture2D(pictureTexture, fTex2) * qt_Opacity;
}"
}
diff --git a/examples/declarative/flickr/content/Progress.qml b/examples/declarative/flickr/content/Progress.qml
index 28fa0c3bac..598ff7123c 100644
--- a/examples/declarative/flickr/content/Progress.qml
+++ b/examples/declarative/flickr/content/Progress.qml
@@ -69,14 +69,14 @@ Item{
Emitter{
y: 2; height: parent.height-4;
x: 2; width: Math.max(parent.width * progress - 4, 0);
- speed: AngledDirection{ angleVariation: 180; magnitudeVariation: 12 }
+ speed: AngleDirection{ angleVariation: 180; magnitudeVariation: 12 }
system: barSys
emitRate: width;
lifeSpan: 1000
size: 20
sizeVariation: 4
endSize: 12
- emitCap: parent.width;
+ maximumEmitted: parent.width;
}
Text {
diff --git a/examples/declarative/flickr/content/StreamView.qml b/examples/declarative/flickr/content/StreamView.qml
deleted file mode 100644
index 9aa6b746a8..0000000000
--- a/examples/declarative/flickr/content/StreamView.qml
+++ /dev/null
@@ -1,107 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtQuick.Particles 2.0
-
-Item{
- id: container
- property alias model: mp.model
- property alias delegate: mp.delegate
- property bool jumpStarted: false
- ParticleSystem{
- id: sys
- anchors.fill:parent
- }
- ModelParticle{
- id: mp
- fade: false
- system: sys
- anchors.fill: parent
- onModelCountChanged: {
- if(!jumpStarted && modelCount > 0){
- console.log("Jumping");
- jumpStarted = true;
- sys.fastForward(8000);
- }
- }
- }
- property real emitterSpacing: parent.width/3
- Emitter{
- system: sys
- width: emitterSpacing - 64
- x: emitterSpacing*0 + 32
- y: -128
- height: 32
- speed: PointDirection{ y: (container.height + 128)/12 }
- emitRate: 0.4
- lifeSpan: 1000000//eventually -1 should mean a million seconds for neatness
- emitCap: 15
- }
- Emitter{
- system: sys
- width: emitterSpacing - 64
- x: emitterSpacing*1 + 32
- y: -128
- height: 32
- speed: PointDirection{ y: (container.height + 128)/12 }
- emitRate: 0.4
- lifeSpan: 1000000//eventually -1 should mean a million seconds for neatness
- emitCap: 15
- }
- Emitter{
- system: sys
- width: emitterSpacing - 64
- x: emitterSpacing*2 + 32
- y: -128
- height: 32
- speed: PointDirection{ y: (container.height + 128)/12 }
- emitRate: 0.4
- lifeSpan: 1000000//eventually -1 should mean a million seconds for neatness
- emitCap: 15
- }
- Kill{
- system: sys
- y: container.height + 64
- width: container.width
- height: 6400
- }
-}
diff --git a/examples/declarative/flickr/content/UnifiedDelegate.qml b/examples/declarative/flickr/content/UnifiedDelegate.qml
index 24bd146b9f..5c8ce75d05 100644
--- a/examples/declarative/flickr/content/UnifiedDelegate.qml
+++ b/examples/declarative/flickr/content/UnifiedDelegate.qml
@@ -65,12 +65,6 @@ Package {
id: streamwrapper;
width: 80; height: 80
Package.name: "stream"
- function pleaseFreeze(){
- ModelParticle.particle.freeze(streamwrapper);
- }
- function pleaseUnfreeze(){
- ModelParticle.particle.unfreeze(streamwrapper);
- }
}
Item {
//anchors.centerIn: parent//Doesn't animate :(
@@ -112,7 +106,6 @@ Package {
transitions: [
Transition {
from: "Show"; to: "Details"
- ScriptAction{ script: streamwrapper.pleaseFreeze(); }
ParentAnimation {
via: foreground
NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad }
@@ -125,7 +118,6 @@ Package {
via: foreground
NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad }
}
- ScriptAction{ script: streamwrapper.pleaseUnfreeze(); }
}
}
]
diff --git a/examples/declarative/flickr/flickr.qml b/examples/declarative/flickr/flickr.qml
index a222b41341..14e4fcaedf 100644
--- a/examples/declarative/flickr/flickr.qml
+++ b/examples/declarative/flickr/flickr.qml
@@ -45,7 +45,7 @@ import "content"
Item {
id: screen; width: 320; height: 480
- property bool inGridView : false
+ property bool inGridView : true
Rectangle {
id: background
@@ -54,40 +54,38 @@ Item {
Image { source: "content/images/stripes.png"; fillMode: Image.Tile; anchors.fill: parent; opacity: 0.3 }
ParticleSystem {
id: bgParticles
- startTime: 16000
- }
- ImageParticle {
- particles: ["trail"]
- source: "content/images/particle.png"
- color: "#1A1A6F"
- alpha: 0.1
- colorVariation: 0.01
- blueVariation: 0.8
- system: bgParticles
- }
- Emitter {
- particle: "drops"
- width: parent.width
- emitRate: 0.5
- lifeSpan: 20000
- speed: PointDirection{
- y: {screen.height/18}
- }
- system: bgParticles
- }
- FollowEmitter {
- follow: "drops"
- particle: "trail"
- emitRatePerParticle: 18
- size: 32
- endSize: 0
- sizeVariation: 4
- lifeSpan: 1200
- system: bgParticles
anchors.fill: parent
- emitWidth: 16
- emitHeight: 16
- emitShape: EllipseShape{}
+ ImageParticle {
+ particles: ["trail"]
+ source: "content/images/particle.png"
+ color: "#1A1A6F"
+ alpha: 0.1
+ colorVariation: 0.01
+ blueVariation: 0.8
+ }
+ Emitter {
+ particle: "drops"
+ width: parent.width
+ emitRate: 0.5
+ lifeSpan: 20000
+ startTime: 16000
+ speed: PointDirection{
+ y: {screen.height/18}
+ }
+ }
+ TrailEmitter {
+ follow: "drops"
+ particle: "trail"
+ emitRatePerParticle: 18
+ size: 32
+ endSize: 0
+ sizeVariation: 4
+ lifeSpan: 1200
+ anchors.fill: parent
+ emitWidth: 16
+ emitHeight: 16
+ emitShape: EllipseShape{}
+ }
}
VisualDataModel{
@@ -107,14 +105,8 @@ Item {
cellWidth: (parent.width-2)/4; cellHeight: cellWidth; width: parent.width; height: parent.height
}
- StreamView{
- id: photoStreamView
- model: vdm.parts.stream
- width: parent.width; height: parent.height
- }
-
states: State {
- name: "GridView"; when: screen.inGridView == true
+ name: "GridView"; when: state.inGridView == true
}
transitions: Transition {
diff --git a/examples/declarative/particles/allsmiles/plain.qml b/examples/declarative/particles/allsmiles/plain.qml
index 890a5782d1..89198845b8 100644
--- a/examples/declarative/particles/allsmiles/plain.qml
+++ b/examples/declarative/particles/allsmiles/plain.qml
@@ -17,7 +17,7 @@ Rectangle{
emitRate: 1000
size: 20
lifeSpan: 10000
- speed: AngledDirection{angleVariation: 360; magnitudeVariation: 100;}
+ speed: AngleDirection{angleVariation: 360; magnitudeVariation: 100;}
}
MouseArea{
anchors.fill: parent
diff --git a/examples/declarative/particles/allsmiles/smile.qml b/examples/declarative/particles/allsmiles/smile.qml
index bfce60cc4a..e091d99e80 100644
--- a/examples/declarative/particles/allsmiles/smile.qml
+++ b/examples/declarative/particles/allsmiles/smile.qml
@@ -77,8 +77,8 @@ Rectangle{
uniform lowp float qt_Opacity;
void main() {
- fTex2 = vec2(vPos.x / maxWidth, vPos.y / maxHeight);
- highp float t = (timestamp - vData.x) / vData.y;
+ fTex2 = vec2(qt_ParticlePos.x / maxWidth, qt_ParticlePos.y / maxHeight);
+ highp float t = (qt_Timestamp - qt_ParticleData.x) / qt_ParticleData.y;
fFade = min(t*4., (1.-t*t)*.75) * qt_Opacity;
defaultMain();
}
@@ -88,19 +88,19 @@ Rectangle{
fragmentShader: "
uniform sampler2D particleTexture;
uniform sampler2D pictureTexture;
- varying highp vec2 fTex;
+ varying highp vec2 qt_TexCoord0;
varying highp vec2 fTex2;
varying lowp float fFade;
void main() {
- gl_FragColor = texture2D(pictureTexture, fTex2) * texture2D(particleTexture, fTex).w * fFade;
+ gl_FragColor = texture2D(pictureTexture, fTex2) * texture2D(particleTexture, qt_TexCoord0).w * fFade;
}"
}
Emitter{
id: emitter
system: sys
- emitting: false
+ enabled: false
lifeSpan: 4000
- emitCap: 1200
+ maximumEmitted: 1200
anchors.fill: parent
size: 32
speed: PointDirection{ xVariation: 12; yVariation: 12 }
diff --git a/examples/declarative/particles/allsmiles/smilefactory.qml b/examples/declarative/particles/allsmiles/smilefactory.qml
index 5b36eee3cd..fe651491b9 100644
--- a/examples/declarative/particles/allsmiles/smilefactory.qml
+++ b/examples/declarative/particles/allsmiles/smilefactory.qml
@@ -58,33 +58,33 @@ Rectangle{
system: sys
particles: ["goingDown"]
source: "content/squarefacespriteXX.png"
- rotation: 180
yVector: PointDirection{ y: 0.5; yVariation: 0.25; xVariation: 0.25; }
+ rotation: 180
}
Timer{
running: true
repeat: false
interval: 100
- onTriggered: emitA.emitting = true;
+ onTriggered: emitA.enabled = true;
}
Timer{
running: true
repeat: false
interval: 4200
- onTriggered: emitB.emitting = true;
+ onTriggered: emitB.enabled = true;
}
Timer{
running: true
repeat: false
interval: 8400
- onTriggered: emitC.emitting = true;
+ onTriggered: emitC.enabled = true;
}
Emitter{
id: emitA
x: 0
y: 120
system: sys
- emitting: false
+ enabled: false
particle: "goingRight"
speed: PointDirection{ x: 100 }
lifeSpan: 4000
@@ -96,7 +96,7 @@ Rectangle{
x: 400
y: 240
system: sys
- emitting: false
+ enabled: false
particle: "goingLeft"
speed: PointDirection{ x: -100 }
lifeSpan: 4000
@@ -108,7 +108,7 @@ Rectangle{
x: 0
y: 360
system: sys
- emitting: false
+ enabled: false
particle: "goingDown"
speed: PointDirection{ x: 100 }
lifeSpan: 4000
diff --git a/examples/declarative/particles/allsmiles/spriteparticles.qml b/examples/declarative/particles/allsmiles/spriteparticles.qml
index f5479f1570..705016e050 100644
--- a/examples/declarative/particles/allsmiles/spriteparticles.qml
+++ b/examples/declarative/particles/allsmiles/spriteparticles.qml
@@ -78,7 +78,6 @@ Rectangle{
id: particles2
emitRate: 6000
lifeSpan: 720
- emitting: true
size: 10
shape: mask
}
@@ -89,7 +88,6 @@ Rectangle{
id: particles
emitRate: 60
lifeSpan: 1440
- emitting: true
speed: PointDirection{xVariation: 10; yVariation: 10;}
size: 30
sizeVariation: 10
diff --git a/examples/declarative/particles/allsmiles/spritestateparticles.qml b/examples/declarative/particles/allsmiles/spritestateparticles.qml
index a599c69a63..06b78cdba4 100644
--- a/examples/declarative/particles/allsmiles/spritestateparticles.qml
+++ b/examples/declarative/particles/allsmiles/spritestateparticles.qml
@@ -172,8 +172,7 @@ Rectangle{
system: sys
emitRate: 16
lifeSpan: 10000
- emitting: true
- speed: AngledDirection{angle: 90; magnitude: 60; angleVariation: 5}
+ speed: AngleDirection{angle: 90; magnitude: 60; angleVariation: 5}
acceleration: PointDirection{ y: 10 }
size: 30
sizeVariation: 10
diff --git a/examples/declarative/particles/allsmiles/spritevariedparticles.qml b/examples/declarative/particles/allsmiles/spritevariedparticles.qml
index d6e13727ff..4696bfb4ff 100644
--- a/examples/declarative/particles/allsmiles/spritevariedparticles.qml
+++ b/examples/declarative/particles/allsmiles/spritevariedparticles.qml
@@ -98,8 +98,7 @@ Rectangle{
width: parent.width
emitRate: 16
lifeSpan: 8000
- emitting: true
- speed: AngledDirection{angle: 90; magnitude: 300; magnitudeVariation: 100; angleVariation: 5}
+ speed: AngleDirection{angle: 90; magnitude: 300; magnitudeVariation: 100; angleVariation: 5}
acceleration: PointDirection{ y: 10 }
size: 30
sizeVariation: 10
diff --git a/examples/declarative/particles/allsmiles/ultraparticles.qml b/examples/declarative/particles/allsmiles/ultraparticles.qml
index eda1c8f859..9094e83801 100644
--- a/examples/declarative/particles/allsmiles/ultraparticles.qml
+++ b/examples/declarative/particles/allsmiles/ultraparticles.qml
@@ -86,8 +86,7 @@ Rectangle{
id: particles
emitRate: 200
lifeSpan: 6000
- emitting: true
- speed: AngledDirection{angleVariation: 360; magnitude: 80; magnitudeVariation: 40}
+ speed: AngleDirection{angleVariation: 360; magnitude: 80; magnitudeVariation: 40}
size: 40
endSize: 80
}
diff --git a/examples/declarative/particles/asteroid/asteroid.qml b/examples/declarative/particles/asteroid/asteroid.qml
index 2ecfc42a98..ea2fabd51d 100644
--- a/examples/declarative/particles/asteroid/asteroid.qml
+++ b/examples/declarative/particles/asteroid/asteroid.qml
@@ -94,7 +94,6 @@ Item {
particle: "meteor"
emitRate: 12
lifeSpan: 5000
- emitting: true
acceleration: PointDirection{ xVariation: 80; yVariation: 80; }
size: 15
endSize: 300
diff --git a/examples/declarative/particles/asteroid/blackhole.qml b/examples/declarative/particles/asteroid/blackhole.qml
index 57474f955e..7e8a7a9edc 100644
--- a/examples/declarative/particles/asteroid/blackhole.qml
+++ b/examples/declarative/particles/asteroid/blackhole.qml
@@ -70,7 +70,7 @@ Rectangle{
system: particles
emitRate: 40
lifeSpan: 4000
- emitting: true
+ enabled: true
size: 30
sizeVariation: 10
speed: PointDirection{ x: 220; xVariation: 40 }
@@ -81,7 +81,7 @@ Rectangle{
system: particles
emitRate: 10
lifeSpan: 4000
- emitting: true
+ enabled: true
size: 30
sizeVariation: 10
speed: PointDirection{ x: 220; xVariation: 40 }
@@ -145,16 +145,16 @@ Rectangle{
colorVariation: 0.2
}
- PointAttractor{
+ Attractor{
id: gs; pointX: root.width/2; pointY: root.height/2; strength: 4000000;
system: particles
- physics: PointAttractor.Acceleration
- proportionalToDistance: PointAttractor.InverseQuadratic
+ affectedParameter: Attractor.Acceleration
+ proportionalToDistance: Attractor.InverseQuadratic
}
- Kill{
+ Age{
system: particles
- x: gs.x - 8;
- y: gs.y - 8;
+ x: gs.pointX - 8;
+ y: gs.pointY - 8;
width: 16
height: 16
}
@@ -174,7 +174,6 @@ Rectangle{
system: particles
emitRate: 200
lifeSpan: 1000
- emitting: true
size: 10
endSize: 4
sizeVariation: 4
@@ -187,7 +186,7 @@ Rectangle{
system: particles
emitRate: 32
lifeSpan: 2000
- emitting: spacePressed
+ enabled: spacePressed
size: 40
speed: PointDirection{ x: 256; }
x: parent.width
diff --git a/examples/declarative/particles/custom/blurparticles.qml b/examples/declarative/particles/custom/blurparticles.qml
index 238608c002..df0fa18971 100644
--- a/examples/declarative/particles/custom/blurparticles.qml
+++ b/examples/declarative/particles/custom/blurparticles.qml
@@ -75,7 +75,7 @@ Rectangle{
void main() {
defaultMain();
- highp float t = (timestamp - vData.x) / vData.y;
+ highp float t = (qt_Timestamp - qt_ParticleData.x) / qt_ParticleData.y;
highp float fadeIn = min(t * 10., 1.);
highp float fadeOut = 1. - max(0., min((t - 0.75) * 4., 1.));
@@ -126,11 +126,11 @@ Rectangle{
fragmentShader: "
uniform sampler2D source;
uniform sampler2D blurred;
- varying highp vec2 fTex;
+ varying highp vec2 qt_TexCoord0;
varying highp float fBlur;
varying highp float fFade;
void main() {
- gl_FragColor = mix(texture2D(source, fTex), texture2D(blurred, fTex), min(1.0,fBlur*3.0)) * fFade;
+ gl_FragColor = mix(texture2D(source, qt_TexCoord0), texture2D(blurred, qt_TexCoord0), min(1.0,fBlur*3.0)) * fFade;
}"
}
diff --git a/examples/declarative/particles/custom/custom.qml b/examples/declarative/particles/custom/custom.qml
index 4b75cf6ebe..50de60b332 100644
--- a/examples/declarative/particles/custom/custom.qml
+++ b/examples/declarative/particles/custom/custom.qml
@@ -5,6 +5,7 @@ ParticleSystem{
id: sys
width: 360
height: 600
+ running: true
Rectangle{
z: -1
anchors.fill: parent
@@ -33,14 +34,14 @@ ParticleSystem{
size: 12
anchors.centerIn: parent
onEmitParticle:{
- particle.size = Math.max(12,Math.min(492,Math.tan(particle.t/2)*24));
+ particle.startSize = Math.max(12,Math.min(492,Math.tan(particle.t/2)*24));
var theta = Math.floor(Math.random() * 6.0) / 6.0;
theta *= 2.0*Math.PI;
theta += sys.convert(sys.petalRotation);
- particle.vx = petalLength * Math.cos(theta);
- particle.vy = petalLength * Math.sin(theta);
- particle.ax = particle.vx * -0.5;
- particle.ay = particle.vy * -0.5;
+ particle.initialVX = petalLength * Math.cos(theta);
+ particle.initialVY = petalLength * Math.sin(theta);
+ particle.initialAX = particle.initialVX * -0.5;
+ particle.initialAY = particle.initialVY * -0.5;
}
}
CustomParticle{
@@ -50,21 +51,21 @@ ParticleSystem{
varying highp vec2 fPos;
void main() {
- fTex = vTex;
- highp float size = vData.z;
- highp float endSize = vData.w;
+ qt_TexCoord0 = qt_ParticleTex;
+ highp float size = qt_ParticleData.z;
+ highp float endSize = qt_ParticleData.w;
- highp float t = (timestamp - vData.x) / vData.y;
+ highp float t = (qt_Timestamp - qt_ParticleData.x) / qt_ParticleData.y;
highp float currentSize = mix(size, endSize, t * t);
if (t < 0. || t > 1.)
currentSize = 0.;
- highp vec2 pos = vPos
- - currentSize / 2. + currentSize * vTex // adjust size
- + vVec.xy * t * vData.y // apply speed vector..
- + 0.5 * vVec.zw * pow(t * vData.y, 2.);
+ highp vec2 pos = qt_ParticlePos
+ - currentSize / 2. + currentSize * qt_ParticleTex // adjust size
+ + qt_ParticleVec.xy * t * qt_ParticleData.y // apply speed vector..
+ + 0.5 * qt_ParticleVec.zw * pow(t * qt_ParticleData.y, 2.);
gl_Position = qt_Matrix * vec4(pos.x, pos.y, 0, 1);
@@ -78,9 +79,9 @@ ParticleSystem{
fragmentShader: "
varying highp vec2 fPos;
varying lowp float fFade;
- varying highp vec2 fTex;
+ varying highp vec2 qt_TexCoord0;
void main() {//*2 because this generates dark colors mostly
- highp vec2 circlePos = fTex*2.0 - vec2(1.0,1.0);
+ highp vec2 circlePos = qt_TexCoord0*2.0 - vec2(1.0,1.0);
highp float dist = length(circlePos);
highp float circleFactor = max(min(1.0 - dist, 1.0), 0.0);
gl_FragColor = vec4(fPos.x*2.0 - fPos.y, fPos.y*2.0 - fPos.x, fPos.x*fPos.y*2.0, 0.0) * circleFactor * fFade;
diff --git a/examples/declarative/particles/custom/delegates.qml b/examples/declarative/particles/custom/delegates.qml
index 4b01c66396..960a398fcb 100644
--- a/examples/declarative/particles/custom/delegates.qml
+++ b/examples/declarative/particles/custom/delegates.qml
@@ -75,7 +75,7 @@ Rectangle{
emitRate: 1
lifeSpan: 4800
lifeSpanVariation: 1600
- speed: AngledDirection{angleVariation: 360; magnitude: 40; magnitudeVariation: 20}
+ speed: AngleDirection{angleVariation: 360; magnitude: 40; magnitudeVariation: 20}
}
ItemParticle{
delegate: Text{
diff --git a/examples/declarative/particles/custom/fallingleaves.qml b/examples/declarative/particles/custom/fallingleaves.qml
index 3572490451..55fa77ffe9 100644
--- a/examples/declarative/particles/custom/fallingleaves.qml
+++ b/examples/declarative/particles/custom/fallingleaves.qml
@@ -53,6 +53,7 @@ Item {
particle.r -= particle.rotation * coefficient;
if (particle.r == 0.0)
particle.r -= particle.rotation * 0.000001;
+ particle.update = 1;
}
}
@@ -65,16 +66,17 @@ Item {
anchors.bottom: parent.bottom
onAffectParticle:{
var pseudoRand = (Math.floor(particle.t*1327) % 10) + 1;
- var yslow = pseudoRand * 0.001 + 1.01;
- var xslow = pseudoRand * 0.0005 + 1.0;
- if (particle.curVY < 1)
- particle.curVY == 0;
+ var yslow = pseudoRand * 0.01 + 1.01;
+ var xslow = pseudoRand * 0.005 + 1.0;
+ if (particle.vy < 1)
+ particle.vy = 0;
else
- particle.curVY = (particle.curVY / yslow);
- if (particle.curVX < 1)
- particle.curVX == 0;
+ particle.vy = (particle.vy / yslow);
+ if (particle.vx < 1)
+ particle.vx = 0;
else
- particle.curVX = (particle.curVX / xslow);
+ particle.vx = (particle.vx / xslow);
+ particle.update = 1;
}
}
ImageParticle{
diff --git a/examples/declarative/particles/custom/shader.qml b/examples/declarative/particles/custom/shader.qml
index 6253679cb7..df0e3660cf 100644
--- a/examples/declarative/particles/custom/shader.qml
+++ b/examples/declarative/particles/custom/shader.qml
@@ -33,21 +33,21 @@ ParticleSystem{
varying highp vec2 fPos;
void main() {
- fTex = vTex;
- highp float size = vData.z;
- highp float endSize = vData.w;
+ qt_TexCoord0 = qt_ParticleTex;
+ highp float size = qt_ParticleData.z;
+ highp float endSize = qt_ParticleData.w;
- highp float t = (timestamp - vData.x) / vData.y;
+ highp float t = (qt_Timestamp - qt_ParticleData.x) / qt_ParticleData.y;
highp float currentSize = mix(size, endSize, t * t);
if (t < 0. || t > 1.)
currentSize = 0.;
- highp vec2 pos = vPos
- - currentSize / 2. + currentSize * vTex // adjust size
- + vVec.xy * t * vData.y // apply speed vector..
- + 0.5 * vVec.zw * pow(t * vData.y, 2.);
+ highp vec2 pos = qt_ParticlePos
+ - currentSize / 2. + currentSize * qt_ParticleTex // adjust size
+ + qt_ParticleVec.xy * t * qt_ParticleData.y // apply speed vector..
+ + 0.5 * qt_ParticleVec.zw * pow(t * qt_ParticleData.y, 2.);
gl_Position = qt_Matrix * vec4(pos.x, pos.y, 0, 1);
@@ -61,9 +61,9 @@ ParticleSystem{
fragmentShader: "
varying highp vec2 fPos;
varying lowp float fFade;
- varying highp vec2 fTex;
+ varying highp vec2 qt_TexCoord0;
void main() {//*2 because this generates dark colors mostly
- highp vec2 circlePos = fTex*2.0 - vec2(1.0,1.0);
+ highp vec2 circlePos = qt_TexCoord0*2.0 - vec2(1.0,1.0);
highp float dist = length(circlePos);
highp float circleFactor = max(min(1.0 - dist, 1.0), 0.0);
gl_FragColor = vec4(fPos.x*2.0 - fPos.y, fPos.y*2.0 - fPos.x, fPos.x*fPos.y*2.0, 0.0) * circleFactor * fFade;
diff --git a/examples/declarative/particles/exampleslauncher.qml b/examples/declarative/particles/exampleslauncher.qml
index dfb966536a..91641e595b 100644
--- a/examples/declarative/particles/exampleslauncher.qml
+++ b/examples/declarative/particles/exampleslauncher.qml
@@ -55,17 +55,12 @@ Rectangle{
VisualDataModel{//TODO: Transitions between modes
id: vdm
model: [
- "../spaceexplorer/spaceexplorer.qml",
"../snow/snow.qml",
"../asteroid/asteroid.qml",
"../asteroid/blackhole.qml",
"../custom/blurparticles.qml",
"../custom/custom.qml",
"../custom/fallingleaves.qml",
- "../modelparticles/bubbles.qml",
- "../modelparticles/gridsplosion.qml",
- "../modelparticles/package.qml",
- "../modelparticles/stream.qml",
"../allsmiles/plain.qml",
"../allsmiles/smile.qml",
"../allsmiles/smilefactory.qml",
diff --git a/examples/declarative/particles/modelparticles/bubbles.qml b/examples/declarative/particles/modelparticles/bubbles.qml
deleted file mode 100644
index 23f0b82d01..0000000000
--- a/examples/declarative/particles/modelparticles/bubbles.qml
+++ /dev/null
@@ -1,82 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtQuick.Particles 2.0
-import "../../modelviews/listview/content" as OtherDemo
-import "content/script.js" as Script
-import "content"
-//Needs OtherDemo to be updated to QtQuick 2.0
-
-Item{
- id: root
- width: 400
- height: 400
- Rectangle{
- anchors.fill: parent
- color: "lightsteelblue"
- }
- ParticleSystem{
- id: sys;
- }
- Emitter{
- system: sys
- particle: "A"
- width: parent.width/2
- x: parent.width/4
- y:parent.height
- speed: PointDirection{ y: -64; yVariation: 16 }
- emitRate: 1
- lifeSpan: 8000
- }
- Wander{
- system: sys
- xVariance: 400
- pace: 200
- }
- ModelParticle{
- id: mp
- z: 0
- system: sys
- particles: ["A"]
- model: OtherDemo.RecipesModel{}
- delegate: ExpandingDelegate{}
- }
-}
diff --git a/examples/declarative/particles/modelparticles/content/Delegate.qml b/examples/declarative/particles/modelparticles/content/Delegate.qml
deleted file mode 100644
index ae1dffb63b..0000000000
--- a/examples/declarative/particles/modelparticles/content/Delegate.qml
+++ /dev/null
@@ -1,88 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-//![0]
-Package {
- Text { id: listDelegate; width: 200; height: 25; text: 'Empty'; Package.name: 'list' }
- Text { id: gridDelegate; width: 100; height: 50; text: 'Empty'; Package.name: 'grid' }
-
- Rectangle {
- id: wrapper
- width: 200; height: 25
- color: 'lightsteelblue'
-
- Text { text: display; anchors.centerIn: parent }
- MouseArea {
- anchors.fill: parent
- onClicked: {
- if (wrapper.state == 'inList')
- wrapper.state = 'inGrid';
- else
- wrapper.state = 'inList';
- }
- }
-
- state: 'inList'
- states: [
- State {
- name: 'inList'
- ParentChange { target: wrapper; parent: listDelegate }
- },
- State {
- name: 'inGrid'
- ParentChange {
- target: wrapper; parent: gridDelegate
- x: 0; y: 0; width: gridDelegate.width; height: gridDelegate.height
- }
- }
- ]
-
- transitions: [
- Transition {
- ParentAnimation {
- NumberAnimation { properties: 'x,y,width,height'; duration: 300 }
- }
- }
- ]
- }
-}
-//![0]
diff --git a/examples/declarative/particles/modelparticles/content/Delegate2.qml b/examples/declarative/particles/modelparticles/content/Delegate2.qml
deleted file mode 100644
index a05fa348b9..0000000000
--- a/examples/declarative/particles/modelparticles/content/Delegate2.qml
+++ /dev/null
@@ -1,79 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-//![0]
-Package {
- Item { id: gridDelegate; width: w; height: h; Package.name: 'grid' }
- Item { id: particleDelegate; width: w; height: h; Package.name: 'particles'
-
- Rectangle {
- id: wrapper
- width: w; height: h;
- color: col
- rotation: Math.random()*360
- Behavior on rotation{RotationAnimation{}}
-
- states: State{
- name: "gridded"
- when: root.inGrid
- PropertyChanges{
- target: wrapper
- rotation: 0
- }
- ParentChange{
- target: wrapper
- parent: gridDelegate
- x:0
- y:0
- }
- }
- transitions: [
- Transition {
- ParentAnimation {
- NumberAnimation { properties: 'x,y,width,height'; duration: 300 }
- }
- }
- ]
- }
- }
-}
-//![0]
diff --git a/examples/declarative/particles/modelparticles/content/ExpandingDelegate.qml b/examples/declarative/particles/modelparticles/content/ExpandingDelegate.qml
deleted file mode 100644
index e6fcb6dcf7..0000000000
--- a/examples/declarative/particles/modelparticles/content/ExpandingDelegate.qml
+++ /dev/null
@@ -1,204 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import "../../../modelviews/listview/content"
-
-// This example illustrates expanding a list item to show a more detailed view.
-
- // Delegate for the recipes. This delegate has two modes:
- // 1. List mode (default), which just shows the picture and title of the recipe.
- // 2. Details mode, which also shows the ingredients and method.
- Component {
- id: recipeDelegate
-
- Item {
- id: recipe
-
- // Create a property to contain the visibility of the details.
- // We can bind multiple element's opacity to this one property,
- // rather than having a "PropertyChanges" line for each element we
- // want to fade.
- property real detailsOpacity : 0
-
- //this bit changed for aesthetics
- width: 70
- height: 70
- // A simple rounded rectangle for the background
- Rectangle {
- id: background
- x: 2; y: 2; width: parent.width - x*2; height: parent.height - y*2
- color: "ivory"
- border.color: "orange"
- radius: 5
- }
- Image{
- anchors.fill:parent
- anchors.margins: -32
- source: "bubble.png"
- }
-
-
- // This mouse region covers the entire delegate.
- // When clicked it changes mode to 'Details'. If we are already
- // in Details mode, then no change will happen.
- MouseArea {
- anchors.fill: parent
- onClicked: recipe.state = 'Details';
- }
-
- // Lay out the page: picture, title and ingredients at the top, and method at the
- // bottom. Note that elements that should not be visible in the list
- // mode have their opacity set to recipe.detailsOpacity.
- Row {
- id: topLayout
- x: 10; y: 10; height: recipeImage.height; width: parent.width
- spacing: 10
-
- Image {
- id: recipeImage
- width: 50; height: 50
- source: "../../modelviews/listview/" + picture
- }
-
- Column {
- width: background.width - recipeImage.width - 20; height: recipeImage.height
- spacing: 5
-
- Text {
- text: title
- font.bold: true; font.pointSize: 16
- }
-
- Text {
- text: "Ingredients"
- font.pointSize: 12; font.bold: true
- opacity: recipe.detailsOpacity
- }
-
- Text {
- text: ingredients
- wrapMode: Text.WordWrap
- width: parent.width
- opacity: recipe.detailsOpacity
- }
- }
- }
-
- Item {
- id: details
- x: 10; width: parent.width - 20
- anchors { top: topLayout.bottom; topMargin: 10; bottom: parent.bottom; bottomMargin: 10 }
- opacity: recipe.detailsOpacity
-
- Text {
- id: methodTitle
- anchors.top: parent.top
- text: "Method"
- font.pointSize: 12; font.bold: true
- }
-
- Flickable {
- id: flick
- width: parent.width
- anchors { top: methodTitle.bottom; bottom: parent.bottom }
- contentHeight: methodText.height
- clip: true
-
- Text { id: methodText; text: method; wrapMode: Text.WordWrap; width: details.width }
- }
-
- Image {
- anchors { right: flick.right; top: flick.top }
- source: "../../modelviews/listview/" + "content/pics/moreUp.png"
- opacity: flick.atYBeginning ? 0 : 1
- }
-
- Image {
- anchors { right: flick.right; bottom: flick.bottom }
- source: "../../modelviews/listview/" + "content/pics/moreDown.png"
- opacity: flick.atYEnd ? 0 : 1
- }
- }
-
- // A button to close the detailed view, i.e. set the state back to default ('').
- TextButton {
- y: 10
- anchors { right: background.right; rightMargin: 10 }
- opacity: recipe.detailsOpacity
- text: "Close"
-
- onClicked: recipe.state = '';
- }
-
- states: State {
- name: "Details"
-
- PropertyChanges { target: background; color: "white" }
- PropertyChanges { target: recipeImage; width: 130; height: 130 } // Make picture bigger
- PropertyChanges { target: recipe; detailsOpacity: 1; x: 0; opacity: 1 } // Make details visible
- PropertyChanges { target: recipe; height: root.height; width: root.height; x:0; y:0; z:100} // Fill the entire list area with the detailed view
-
- // Move the list so that this item is at the top.
- //PropertyChanges { target: recipe.ListView.view; explicit: true; contentY: recipe.y }
-
- // Disallow flicking while we're in detailed view
- //PropertyChanges { target: recipe.ListView.view; interactive: false }
- }
-
- transitions: Transition {
- //The only strictly necessary particle specific lines
- to: "Details"
- reversible: true
- ScriptAction{script:{
- if(state == "Details")
- mp.freeze(index);
- else
- mp.unfreeze(index);
- }
- }
- // Make the state changes smooth
- ParallelAnimation {
- ColorAnimation { property: "color"; duration: 500 }
- NumberAnimation { duration: 300; properties: "detailsOpacity,opacity,x,y,height,width" }
- }
- }
- }
- }
diff --git a/examples/declarative/particles/modelparticles/content/RssModel.qml b/examples/declarative/particles/modelparticles/content/RssModel.qml
deleted file mode 100644
index edb3ceac42..0000000000
--- a/examples/declarative/particles/modelparticles/content/RssModel.qml
+++ /dev/null
@@ -1,53 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-XmlListModel {
- property string tags : ""
-
- source: "http://api.flickr.com/services/feeds/photos_public.gne?"+(tags ? "tags="+tags+"&" : "")
- query: "/feed/entry"
- namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom';"
-
- XmlRole { name: "title"; query: "title/string()" }
- XmlRole { name: "content"; query: "content/string()" }
- XmlRole { name: "hq"; query: "link[@rel='enclosure']/@href/string()" }
-}
diff --git a/examples/declarative/particles/modelparticles/content/bubble.png b/examples/declarative/particles/modelparticles/content/bubble.png
deleted file mode 100644
index c7f479e9e3..0000000000
--- a/examples/declarative/particles/modelparticles/content/bubble.png
+++ /dev/null
Binary files differ
diff --git a/examples/declarative/particles/modelparticles/content/script.js b/examples/declarative/particles/modelparticles/content/script.js
deleted file mode 100644
index e8ef93a847..0000000000
--- a/examples/declarative/particles/modelparticles/content/script.js
+++ /dev/null
@@ -1,27 +0,0 @@
-.pragma library
-
-function getWidth(string) {
- return (string.match(/width=\"([0-9]+)\"/))[1]
-}
-
-function getHeight(string) {
- return (string.match(/height=\"([0-9]+)\"/))[1]
-}
-
-function getImagePath(string) {
- var pattern = /src=\"http:\/\/(\S+)\"/
- return (string.match(pattern))[1]
-}
-
-function calculateScale(width, height, cellSize) {
- var widthScale = (cellSize * 1.0) / width
- var heightScale = (cellSize * 1.0) / height
- var scale = 0
-
- if (widthScale <= heightScale) {
- scale = widthScale;
- } else if (heightScale < widthScale) {
- scale = heightScale;
- }
- return scale;
-}
diff --git a/examples/declarative/particles/modelparticles/gridsplosion.qml b/examples/declarative/particles/modelparticles/gridsplosion.qml
deleted file mode 100644
index 9232eb426d..0000000000
--- a/examples/declarative/particles/modelparticles/gridsplosion.qml
+++ /dev/null
@@ -1,144 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtQuick.Particles 2.0
-import "content"
-
-Rectangle{
- id: root
- width: 240
- height: 240
- property bool inGrid: false
- ParticleSystem{ id: sys }
- Emitter{
- system: sys
- id: burster;
- emitting: false
- emitRate: 1000
- lifeSpan: 50000
- emitCap: 100;
- speed: PointDirection{xVariation: 400; yVariation: 400}
- anchors.centerIn: parent
- Timer{
- interval: 1000
- running: true
- repeat: false
- onTriggered: burster.pulse(0.1);
- }
- Timer{
- interval: 2000
- running: true
- repeat: false
- onTriggered: {inGrid = true;}// sys.running = false;}
- }
- }
- ImageParticle{
- system: sys
- source: "../trails/content/particle.png"
- color: "black"
- colorVariation: 0.0
- }
- GridView{ id: grid; cellWidth: 40; cellHeight: 40
- model: theModel.parts.grid
- width: 120
- height: 120
- }
- ModelParticle{
- system: sys
- model: theModel.parts.particles
- fade: false
- }
- Friction{
- system: sys
- factor: 5
- }
- VisualDataModel{
- id: theModel
- delegate: Delegate2{}
- model: ListModel{
- ListElement{
- w: 40
- h: 20
- col: "forestgreen"
- }
- ListElement{
- w: 20
- h: 40
- col: "salmon"
- }
- ListElement{
- w: 20
- h: 20
- col: "lightsteelblue"
- }
- ListElement{
- w: 40
- h: 40
- col: "goldenrod"
- }
- ListElement{
- w: 40
- h: 20
- col: "forestgreen"
- }
- ListElement{
- w: 20
- h: 40
- col: "salmon"
- }
- ListElement{
- w: 20
- h: 20
- col: "lightsteelblue"
- }
- ListElement{
- w: 40
- h: 40
- col: "goldenrod"
- }
- ListElement{
- w: 0
- h: 0
- col: "white"//Hack because add isn't working well with old stuff
- }
- }
- }
-}
diff --git a/examples/declarative/particles/modelparticles/package.qml b/examples/declarative/particles/modelparticles/package.qml
deleted file mode 100644
index d374a93446..0000000000
--- a/examples/declarative/particles/modelparticles/package.qml
+++ /dev/null
@@ -1,91 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtQuick.Particles 2.0
-import "content"
-
-Rectangle {
- color: "white"
- width: 400
- height: 200
-
- ListModel {
- id: myModel
- ListElement { display: "One" }
- ListElement { display: "Two" }
- ListElement { display: "Three" }
- ListElement { display: "Four" }
- ListElement { display: "Five" }
- ListElement { display: "Six" }
- ListElement { display: "Seven" }
- ListElement { display: "Eight" }
- }
- //![0]
- VisualDataModel {
- id: visualModel
- delegate: Delegate {}
- model: myModel
- }
-
- ListView {
- width: 200; height:200
- model: visualModel.parts.list
- }
- ModelParticle{
- x: 200; width: 200; height:200
- model: visualModel.parts.grid
- system: sys
- clip: true;
- }
- //![0]
- ParticleSystem{
- id: sys
- anchors.fill: parent
- }
- Emitter{
- system: sys
- width: 100
- x: 250
- speed: PointDirection{ y: 40 }
- lifeSpan: 5000
- emitRate: 1.6
- }
-}
diff --git a/examples/declarative/particles/modelparticles/stream.qml b/examples/declarative/particles/modelparticles/stream.qml
deleted file mode 100644
index 0938f17cd4..0000000000
--- a/examples/declarative/particles/modelparticles/stream.qml
+++ /dev/null
@@ -1,276 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtQuick.Particles 2.0
-import "content/script.js" as Script
-import "content"
-
-Item{
- id: root
- width: 640
- height: 480
- Rectangle{
- anchors.fill: parent
- color: "black"
- z: -1
- }
- Item{
- id: loading
- Behavior on opacity{NumberAnimation{}}
- anchors.fill: parent
- Text{
- anchors.centerIn: parent
- text: "Loading"
- color: "white"
- }
- }
- ParticleSystem{
- id: sys;
- running: true
- startTime: 12000//Doesn't actually work with the loading time though...
- }
- Emitter{
- id: emitter
- system: sys
- height: parent.height - 132/2
- x: -132/2
- y: 132/2
- speed: PointDirection{ x: 32; xVariation: 8 }
- emitRate: 0.5
- lifeSpan: 120000 //TODO: A -1 or something which does 'infinite'? (but need disable fade first)
- particle: "photos"
- }
- Kill{
- system: sys
- x: parent.width + 132/2
- height: parent.height
- width: 1000
- }
- ImageParticle{
- system: sys
- particles: ["fireworks"]
- source: "../trails/content/star.png"
- color: "lightsteelblue"
- alpha: 0
- colorVariation: 0
- z: 1000
- }
- ItemParticle{
- id: mp
- z: 0
- system: sys
- fade: false
- particles: ["photos"]
- }
- Component{
- id: alertDelegate
- Rectangle{
- width: 132
- height: 132
- NumberAnimation on scale{
- running: true
- loops: 1
- from: 0.2
- to: 1
- }
- Image{
- source: "../asteroid/content/rocket.png"
- anchors.centerIn: parent
- }
- Text{
- anchors.bottom: parent.bottom
- anchors.horizontalCenter: parent.horizontalCenter
- text: "A new ship has arrived!"
- }
- }
- }
- property Item alertItem;
- function alert(){
- //resetter.active = false
- force.active = true;
- alertItem = alertDelegate.createObject(root);
- alertItem.x = root.width/2 - alertItem.width/2
- alertItem.y = root.height/2 - alertItem.height/2
- spawnFireworks.pulse(0.2);
- stopAlert.start();
- }
- focus: true
- Keys.onSpacePressed: alert();
- Timer{
- id: stopAlert
- running: false
- repeat: false
- interval: 800
- onTriggered: {
- force.active = false
- //resetter.active = true;
- mp.take(alertItem, true);
- centerEmitter.burst(1);
- }
- }
- PointAttractor{
- id: force
- system: sys
- pointX: root.width/2
- pointY: root.height/2
- strength: -10000
- active: false
- anchors.centerIn: parent
- width: parent.width/2
- height: parent.height/2
- particles:["photos"]
- physics: PointAttractor.Position
- }
- Emitter{
- id: centerEmitter
- speed: PointDirection{ x: 32; xVariation: 8;}
- emitRate: 0.5
- lifeSpan: 12000 //TODO: A -1 or something which does 'infinite'? (but need disable fade first)
- emitCap: 20
- particle: "photos"
- system: sys
- anchors.centerIn: parent
- emitting: false
-
- //TODO: Zoom in effect
- }
- Emitter{
- id: spawnFireworks
- particle: "fireworks"
- system: sys
- emitCap: 400
- emitRate: 400
- lifeSpan: 2800
- x: parent.width/2
- y: parent.height/2 - 64
- width: 8
- height: 8
- emitting: false
- size: 32
- endSize: 8
- speed: AngledDirection{ magnitude: 160; magnitudeVariation: 120; angleVariation: 90; angle: 270 }
- acceleration: PointDirection{ y: 160 }
- }
- Item{ x: -1000; y: -1000 //offscreen
- Repeater{//Load them here, add to system on completed
- model: theModel
- delegate: theDelegate
- }
- }
- RssModel{id: theModel; tags:"particle,particles"}
- Component {
- id: theDelegate
- Rectangle {
- id: container
- border.width: 2
- property real myRand: Math.random();//'depth'
- z: Math.floor(myRand * 100)
- scale: (myRand + 1.0)/2;
- //TODO: Darken based on 'depth'
- width: 132
- height: 132
- //ItemParticle.onAttached: console.log("I'm in" + x + "," + y + ":" + opacity);
- ItemParticle.onDetached: mp.take(container);//respawns
- function manage()
- {
- if(state == "selected"){
- // console.log("Taking " + index);
- mp.freeze(container);
- }else{
- // console.log("Returning " +index);
- mp.unfreeze(container);
- }
- }
- Image{
- id: img
- anchors.centerIn: parent
- smooth: true; source: "http://" + Script.getImagePath(content); cache: true
- fillMode: Image.PreserveAspectFit;
- width: parent.width-4; height: parent.height-4
- onStatusChanged: if(img.status == Image.Ready){
- container.opacity = 0;
- loading.opacity = 0;
- mp.take(container);
- }
- }
- Text{
- anchors.bottom: parent.bottom
- width: parent.width
- horizontalAlignment: Text.AlignHCenter
- elide: Text.ElideRight
- text: title
- color: "black"
- }
- MouseArea{
- anchors.fill: parent
- onClicked: container.state == "selected" ? container.state = "" : container.state = "selected"
- }
- states: State{
- name: "selected"
- ParentChange{
- target: container
- parent: root
- x: 0
- y: 0
- }
- PropertyChanges{
- target: container
- width: root.width
- height: root.height
- z: 101
- opacity: 1
- rotation: 0
- }
- }
- transitions: Transition{
- to: "selected"
- reversible: true
- SequentialAnimation{
- ScriptAction{script: container.manage();}
- ParallelAnimation{
- ParentAnimation{NumberAnimation{ properties: "x,y" }}//Doesn't work, particles takes control of x,y instantly
- NumberAnimation{ properties: "width, height, z, rotation" }
- }
- }
- }
- }
- }
-}
diff --git a/examples/declarative/particles/snow/snow.qml b/examples/declarative/particles/snow/snow.qml
index b988c53f4a..39e322fe84 100644
--- a/examples/declarative/particles/snow/snow.qml
+++ b/examples/declarative/particles/snow/snow.qml
@@ -61,14 +61,13 @@ Rectangle{
id: wanderer
system: particles
anchors.fill: parent
- xVariance: 360/(wanderer.physics+1);
- pace: 100*(wanderer.physics+1);
+ xVariance: 360/(wanderer.affectedParameter+1);
+ pace: 100*(wanderer.affectedParameter+1);
}
Emitter {
system: particles
emitRate: 20
lifeSpan: 7000
- emitting: true
speed: PointDirection{ y:80; yVariation: 40; }
acceleration: PointDirection{ y: 4 }
size: 20
@@ -81,15 +80,15 @@ Rectangle{
anchors.horizontalCenter: parent.horizontalCenter
UI.Button{
text:"dx/dt"
- onClicked: wanderer.physics = Wander.Position;
+ onClicked: wanderer.affectedParameter = Wander.Position;
}
UI.Button{
text:"dv/dt"
- onClicked: wanderer.physics = Wander.Velocity;
+ onClicked: wanderer.affectedParameter = Wander.Velocity;
}
UI.Button{
text:"da/dt"
- onClicked: wanderer.physics = Wander.Acceleration;
+ onClicked: wanderer.affectedParameter = Wander.Acceleration;
}
}
}
diff --git a/examples/declarative/particles/spaceexplorer/content/helpers.js b/examples/declarative/particles/spaceexplorer/content/helpers.js
deleted file mode 100644
index c38c4c0eed..0000000000
--- a/examples/declarative/particles/spaceexplorer/content/helpers.js
+++ /dev/null
@@ -1,8 +0,0 @@
-function intersects(item, x, y, e){
- return x+e >= item.x && x-e <= item.x + item.width && y+e >= item.y && y-e <= item.y + item.height;
-}
-
-function direction(x1, y1, x2, y2){
- return Math.atan2(y2-y1, x2-x1) * (180/Math.PI);
-}
-
diff --git a/examples/declarative/particles/spaceexplorer/content/particle4.png b/examples/declarative/particles/spaceexplorer/content/particle4.png
deleted file mode 100644
index bc95b703c1..0000000000
--- a/examples/declarative/particles/spaceexplorer/content/particle4.png
+++ /dev/null
Binary files differ
diff --git a/examples/declarative/particles/spaceexplorer/content/powerupScore.png b/examples/declarative/particles/spaceexplorer/content/powerupScore.png
deleted file mode 100644
index e8c368aea7..0000000000
--- a/examples/declarative/particles/spaceexplorer/content/powerupScore.png
+++ /dev/null
Binary files differ
diff --git a/examples/declarative/particles/spaceexplorer/content/powerupScore_gone.png b/examples/declarative/particles/spaceexplorer/content/powerupScore_gone.png
deleted file mode 100644
index 4076327a1a..0000000000
--- a/examples/declarative/particles/spaceexplorer/content/powerupScore_gone.png
+++ /dev/null
Binary files differ
diff --git a/examples/declarative/particles/spaceexplorer/content/powerupScore_got.png b/examples/declarative/particles/spaceexplorer/content/powerupScore_got.png
deleted file mode 100644
index 4297245d49..0000000000
--- a/examples/declarative/particles/spaceexplorer/content/powerupScore_got.png
+++ /dev/null
Binary files differ
diff --git a/examples/declarative/particles/spaceexplorer/content/rocket.png b/examples/declarative/particles/spaceexplorer/content/rocket.png
deleted file mode 100644
index a171610b03..0000000000
--- a/examples/declarative/particles/spaceexplorer/content/rocket.png
+++ /dev/null
Binary files differ
diff --git a/examples/declarative/particles/spaceexplorer/content/rocket2.png b/examples/declarative/particles/spaceexplorer/content/rocket2.png
deleted file mode 100644
index 7110f8fdc6..0000000000
--- a/examples/declarative/particles/spaceexplorer/content/rocket2.png
+++ /dev/null
Binary files differ
diff --git a/examples/declarative/particles/spaceexplorer/content/rocketEye.png b/examples/declarative/particles/spaceexplorer/content/rocketEye.png
deleted file mode 100644
index 20005937d2..0000000000
--- a/examples/declarative/particles/spaceexplorer/content/rocketEye.png
+++ /dev/null
Binary files differ
diff --git a/examples/declarative/particles/spaceexplorer/content/star.png b/examples/declarative/particles/spaceexplorer/content/star.png
deleted file mode 100644
index 0d592cfa87..0000000000
--- a/examples/declarative/particles/spaceexplorer/content/star.png
+++ /dev/null
Binary files differ
diff --git a/examples/declarative/particles/spaceexplorer/spaceexplorer.qml b/examples/declarative/particles/spaceexplorer/spaceexplorer.qml
deleted file mode 100644
index cb8acb815e..0000000000
--- a/examples/declarative/particles/spaceexplorer/spaceexplorer.qml
+++ /dev/null
@@ -1,417 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtQuick.Particles 2.0
-import "content/helpers.js" as Helpers
-
-Rectangle{
- id: root
- width: 360
- height: 540
- color: "black"
- Image{
- anchors.centerIn: parent
- source: "../asteroid/content/finalfrontier.png"
- }
- property bool spacePressed: false
- property int holeSize: 4
- focus: true
- Keys.onPressed: {
- if (event.key == Qt.Key_Space) {
- spacePressed = true;
- event.accepted = true;
- }
- }
- Keys.onReleased: {
- if (event.key == Qt.Key_Space) {
- spacePressed = false;
- event.accepted = true;
- }
- }
-
- function fakeMove(){
- fakeMoving = rocket.x < 80 || rocket.x+rocket.width-root.width > -80 || rocket.y < 80 || rocket.y+rocket.height-root.height > -80;
- if(fakeMoving)
- fakeMovementDir = Helpers.direction(root.width/2, root.height/2, rocket.x, rocket.y) + 180;
- }
- property bool fakeMoving: false
- property real fakeMovementDir: 0
-
- Emitter{
- particle: "stars2"
- system: background
- emitRate: 60
- lifeSpan: 4000
- emitting: true
- size: 10
- sizeVariation: 10
- anchors.fill: parent
- }
- ParticleSystem{ id: background }
- ImageParticle{
- particles: ["stars2"]
- system: background
- anchors.fill: parent
- source: "content/star.png"
- color: "white"
- colorVariation: 0.1
- }
- Gravity{
- system: background
- anchors.fill: parent
- acceleration: fakeMoving?10:0
- angle: fakeMovementDir
- }
- Text{
- color: "white"
- anchors.bottom: parent.bottom
- anchors.right: parent.right
- text:"Drag the ship, but don't hit a black hole!"
- font.pixelSize: 10
- }
- Text{
- color: "white"
- font.pixelSize: 36
- anchors.centerIn: parent
- text: "GAME OVER"
- opacity: gameOver ? 1 : 0
- Behavior on opacity{NumberAnimation{}}
- }
- Text{
- color: "white"
- font.pixelSize: 18
- anchors.left: parent.left
- anchors.bottom: parent.bottom
- anchors.margins: 8
- text: "Score: " + score
- }
- Image{
- source: "content/star.png"
- width: 40
- height: 40
- anchors.right: parent.right
- anchors.top: parent.top
- MouseArea{
- anchors.fill: parent
- anchors.margins: -20
- onClicked: shoot = !shoot
- }
- }
- property int score: 0
- property bool gameOver: false
- property bool shoot: true
- property int maxLives: 3
- property int lives: maxLives
- property bool alive: !Helpers.intersects(rocket, gs1.x, gs1.y, holeSize) && !Helpers.intersects(rocket, gs2.x, gs2.y, holeSize) && !Helpers.intersects(rocket, gs3.x, gs3.y, holeSize) && !Helpers.intersects(rocket, gs4.x, gs4.y, holeSize);
- onAliveChanged: if(!alive){
- lives -= 1;
- if(lives == -1){
- console.log("game over");
- gameOver = true;
- }
- }
- Row{
- Repeater{
- model: maxLives
- delegate: Image{
- opacity: index < lives ? 1 : 0
- Behavior on opacity{NumberAnimation{}}
- source: "content/rocket.png"
- }
- }
- }
-
- property real courseDur: 10000
- property real vorteX: width/4
- property real vorteY: height/4
- Behavior on vorteX{NumberAnimation{duration: courseDur}}
- Behavior on vorteY{NumberAnimation{duration: courseDur}}
- property real vorteX2: width/4
- property real vorteY2: 3*height/4
- Behavior on vorteX2{NumberAnimation{duration: courseDur}}
- Behavior on vorteY2{NumberAnimation{duration: courseDur}}
- property real vorteX3: 3*width/4
- property real vorteY3: height/4
- Behavior on vorteX3{NumberAnimation{duration: courseDur}}
- Behavior on vorteY3{NumberAnimation{duration: courseDur}}
- property real vorteX4: 3*width/4
- property real vorteY4: 3*height/4
- Behavior on vorteX4{NumberAnimation{duration: courseDur}}
- Behavior on vorteY4{NumberAnimation{duration: courseDur}}
- Timer{
- id: vorTimer
- interval: courseDur
- running: true
- repeat: true
- triggeredOnStart: true
- onTriggered: {
- vorteX = Math.random() * width * 2 - width * 0.5;
- vorteY = Math.random() * height * 2 - height * 0.5;
- vorteX2 = Math.random() * width * 2 - width * 0.5;
- vorteY2 = Math.random() * height * 2 - height * 0.5;
- vorteX3 = Math.random() * width * 2 - width * 0.5;
- vorteY3 = Math.random() * height * 2 - height * 0.5;
- vorteX4 = Math.random() * width * 2 - width * 0.5;
- vorteY4 = Math.random() * height * 2 - height * 0.5;
- }
- }
-
-
-
- ParticleSystem{ id: foreground }
- ImageParticle{
- particles: ["stars"]
- anchors.fill: parent
- system: foreground
- source: "content/star.png"
- color: "white"
- colorVariation: 0.1
- }
- ImageParticle{
- particles: ["shot"]
- anchors.fill: parent
- system: foreground
- source: "content/star.png"
-
- color: "orange"
- colorVariation: 0.3
- }
- ImageParticle{
- id: engine
- particles: ["engine"]
- anchors.fill: parent
- system: foreground
- source: "content/particle4.png"
-
- color: "orange"
- SequentialAnimation on color {
- loops: Animation.Infinite
- ColorAnimation {
- from: "red"
- to: "cyan"
- duration: 1000
- }
- ColorAnimation {
- from: "cyan"
- to: "red"
- duration: 1000
- }
- }
-
- colorVariation: 0.2
- }
- ImageParticle{
- particles: ["powerups"]
- anchors.fill: parent
- system: foreground
- sprites:[Sprite{
- name: "norm"
- source: "content/powerupScore.png"
- frames: 35
- duration: 40
- to: {"norm":1, "got":0}
- },
- Sprite{
- name: "got"
- source: "content/powerupScore_got.png"
- frames: 22
- duration: 40
- to: {"null":1}
- },
- Sprite{
- name: "null"
- source: "content/powerupScore_gone.png"
- frames: 1
- duration: 1000
- }
- ]
- }
- SpriteGoal{
- x: rocket.x - 30
- y: rocket.y - 30
- width: 60
- height: 60
- goalState: "got"
- jump: true
- onAffected: if(!gameOver) score += 1000
- system: foreground
- }
- PointAttractor{
- proportionalToDistance: PointAttractor.InverseQuadratic;
- id: gs1; pointX: vorteX; pointY: vorteY; strength: 800000;
- system: foreground
- }
- Kill{
- x: gs1.pointX - holeSize;
- y: gs1.pointY - holeSize;
- width: holeSize * 2
- height: holeSize * 2
- system: foreground
- }
-
- PointAttractor{
- proportionalToDistance: PointAttractor.InverseQuadratic;
- id: gs2; pointX: vorteX2; pointY: vorteY2; strength: 800000;
- system: foreground
- }
- Kill{
- x: gs2.pointX - holeSize;
- y: gs2.pointY - holeSize;
- width: holeSize * 2
- height: holeSize * 2
- system: foreground
- }
-
- PointAttractor{
- proportionalToDistance: PointAttractor.InverseQuadratic;
- id: gs3; pointX: vorteX3; pointY: vorteY3; strength: 800000;
- system: foreground
- }
- Kill{
- x: gs3.pointX - holeSize;
- y: gs3.pointY - holeSize;
- width: holeSize * 2
- height: holeSize * 2
- system: foreground
- }
- PointAttractor{
- id: gs4; pointX: vorteX4; pointY: vorteY4; strength: 800000;
- proportionalToDistance: PointAttractor.InverseQuadratic;
- system: foreground
- }
- Kill{
- x: gs4.pointX - holeSize;
- y: gs4.pointY - holeSize;
- width: holeSize * 2
- height: holeSize * 2
- system: foreground
- }
- Emitter{
- particle: "powerups"
- system: foreground
- emitRate: 1
- lifeSpan: 6000
- emitting: !gameOver
- size: 60
- sizeVariation: 10
- anchors.fill: parent
- }
- Emitter{
- particle: "stars"
- system: foreground
- emitRate: 40
- lifeSpan: 4000
- emitting: !gameOver
- size: 30
- sizeVariation: 10
- anchors.fill: parent
- }
- SpriteImage{
- id: rocket
- //Sprites or children for default?
- Sprite{
- name: "normal"
- source: "content/rocket2.png"
- frames: 1
- duration: 1000
- to: {"normal": 0.9, "winking" : 0.1}
- }
- Sprite{
- name: "winking"
- source: "content/rocketEye.png"
- frames: 10
- duration: 40
- to: {"normal" : 1}
- }
- x: root.width/2
- y: root.height/2
- property int lx: 0
- property int ly: 0
- property int lastX: 0
- property int lastY: 0
- width: 45
- height: 22
- onXChanged:{ lastX = lx; lx = x; fakeMove()}
- onYChanged:{ lastY = ly; ly = y; fakeMove()}
- rotation: Helpers.direction(lastX, lastY, x, y)
- data:[
- MouseArea{
- id: ma
- anchors.fill: parent;
- drag.axis: Drag.XandYAxis
- drag.target: rocket
- },
- Emitter{
- system: foreground
- particle: "engine"
- emitRate: 100
- lifeSpan: 1000
- emitting: !gameOver
- size: 10
- endSize: 4
- sizeVariation: 4
- speed: PointDirection{
- x: -128 * Math.cos(rocket.rotation * (Math.PI / 180))
- y: -128 * Math.sin(rocket.rotation * (Math.PI / 180))
- }
- anchors.verticalCenter: parent.verticalCenter
- height: 4
- width: 4
-
- },
- Emitter{
- system: foreground
- particle: "shot"
- emitRate: 16
- lifeSpan: 1600
- emitting: !gameOver && shoot
- size: 40
- speed: PointDirection{
- x: 256 * Math.cos(rocket.rotation * (Math.PI / 180))
- y: 256 * Math.sin(rocket.rotation * (Math.PI / 180))
- }
- x: parent.width - 4
- y: parent.height/2
- }
- ]
- }
-}
-
diff --git a/examples/declarative/particles/trails/combustion.qml b/examples/declarative/particles/trails/combustion.qml
index f244300524..e4a21e9beb 100644
--- a/examples/declarative/particles/trails/combustion.qml
+++ b/examples/declarative/particles/trails/combustion.qml
@@ -70,7 +70,7 @@ Rectangle {
color: "#2060160f"
}
SpriteGoal{
- collisionParticles: ["lit"]
+ whenCollidingWith: ["lit"]
goalState: "lighting"
jump: true
systemStates: true
@@ -85,7 +85,7 @@ Rectangle {
name: "lit"
duration: 10000
onEntered: score++;
- FollowEmitter{
+ TrailEmitter{
id: fireballFlame
particle: "flame"
@@ -99,7 +99,7 @@ Rectangle {
endSize: 4
}
- FollowEmitter{
+ TrailEmitter{
id: fireballSmoke
particle: "smoke"
@@ -185,7 +185,7 @@ Rectangle {
goalState: "lighting"
jump: true
systemStates: true
- active: ma.pressed
+ enabled: ma.pressed
width: 18
height: 18
x: ma.mouseX - width/2
diff --git a/examples/declarative/particles/trails/dynamicemitters.qml b/examples/declarative/particles/trails/dynamicemitters.qml
index dbf3f8fa82..dac5d93035 100644
--- a/examples/declarative/particles/trails/dynamicemitters.qml
+++ b/examples/declarative/particles/trails/dynamicemitters.qml
@@ -63,12 +63,11 @@ Rectangle{
Emitter{
id: emitMore
system: sys
- emitting: true
emitRate: 128
lifeSpan: 600
size: 16
endSize: 8
- speed: AngledDirection{angleVariation:360; magnitude: 60}
+ speed: AngleDirection{angleVariation:360; magnitude: 60}
}
property int life: 2600
@@ -77,10 +76,9 @@ Rectangle{
function go(){
xAnim.start();
yAnim.start();
- container.emitting = true
+ container.enabled = true
}
system: sys
- emitting: true
emitRate: 32
lifeSpan: 600
size: 24
diff --git a/examples/declarative/particles/trails/fireballs.qml b/examples/declarative/particles/trails/fireballs.qml
index 4cc2eacc25..97a0c0ac5f 100644
--- a/examples/declarative/particles/trails/fireballs.qml
+++ b/examples/declarative/particles/trails/fireballs.qml
@@ -98,7 +98,7 @@ Rectangle {
sizeVariation: 8
endSize: 4
}
- FollowEmitter{
+ TrailEmitter{
id: fireSmoke
particle: "B"
system: particles
@@ -116,7 +116,7 @@ Rectangle {
sizeVariation: 8
endSize: 16
}
- FollowEmitter{
+ TrailEmitter{
id: fireballFlame
anchors.fill: parent
system: particles
@@ -133,7 +133,7 @@ Rectangle {
endSize: 4
}
- FollowEmitter{
+ TrailEmitter{
id: fireballSmoke
anchors.fill: parent
system: particles
diff --git a/examples/declarative/particles/trails/fireworks.qml b/examples/declarative/particles/trails/fireworks.qml
index a84f5d8b3c..437d9ee3d6 100644
--- a/examples/declarative/particles/trails/fireworks.qml
+++ b/examples/declarative/particles/trails/fireworks.qml
@@ -59,13 +59,13 @@ Rectangle{
name: "splode"
duration: 400
to: {"dead":1}
- FollowEmitter{
+ TrailEmitter{
particle: "works"
emitRatePerParticle: 100
lifeSpan: 1000
- emitCap: 1200
+ maximumEmitted: 1200
size: 8
- speed: AngledDirection{angle: 270; angleVariation: 45; magnitude: 20; magnitudeVariation: 20;}
+ speed: AngleDirection{angle: 270; angleVariation: 45; magnitude: 20; magnitudeVariation: 20;}
acceleration: PointDirection{y:100; yVariation: 20}
}
},
@@ -73,8 +73,7 @@ Rectangle{
name: "dead"
duration: 1000
Affector{
- onceOff: true
- signal: true
+ once: true
onAffected: worksEmitter.burst(400,x,y)
}
}
@@ -91,7 +90,7 @@ Rectangle{
particle: "fire"
width: parent.width
y: parent.height
- emitting: false
+ enabled: false
emitRate: 80
lifeSpan: 6000
speed: PointDirection{y:-100;}
@@ -100,14 +99,14 @@ Rectangle{
Emitter{
id: worksEmitter
particle: "works"
- emitting: false
+ enabled: false
emitRate: 100
lifeSpan: 1600
- emitCap: 6400
+ maximumEmitted: 6400
size: 8
speed: CumulativeDirection{
PointDirection{y:-100}
- AngledDirection{angleVariation: 360; magnitudeVariation: 80;}
+ AngleDirection{angleVariation: 360; magnitudeVariation: 80;}
}
acceleration: PointDirection{y:100; yVariation: 20}
}
diff --git a/examples/declarative/particles/trails/layered.qml b/examples/declarative/particles/trails/layered.qml
index d4a823b556..9af5f0bd64 100644
--- a/examples/declarative/particles/trails/layered.qml
+++ b/examples/declarative/particles/trails/layered.qml
@@ -53,7 +53,6 @@ Rectangle{
}
ParticleSystem{
id: sys
- startTime: 4000
}
Emitter{
system: sys
@@ -61,6 +60,7 @@ Rectangle{
width: root.width
emitRate: 200
lifeSpan: 4000
+ startTime: 4000
speed: PointDirection{ y: -120; }
}
ImageParticle{
diff --git a/examples/declarative/particles/trails/list.qml b/examples/declarative/particles/trails/list.qml
index 7e8fb44003..b64e49456b 100644
--- a/examples/declarative/particles/trails/list.qml
+++ b/examples/declarative/particles/trails/list.qml
@@ -57,6 +57,7 @@ Rectangle {
source: "content/star.png"
color: "white"
colorVariation: 0.0
+ rotationSpeed: 360
}
// Define a delegate component. A component will be
@@ -95,11 +96,12 @@ Rectangle {
Emitter{
anchors.fill: parent
system: particles;
- emitting: anim.running
+ enabled: anim.running
emitRate: 600
lifeSpan: 600
size: 16
endSize: 8
+ sizeVariation: 8
}
}
}
diff --git a/examples/declarative/particles/trails/overburst.qml b/examples/declarative/particles/trails/overburst.qml
index 620ae46088..baf1bf3046 100644
--- a/examples/declarative/particles/trails/overburst.qml
+++ b/examples/declarative/particles/trails/overburst.qml
@@ -47,7 +47,7 @@ Rectangle{
height: 540
ParticleSystem{
id: sys
- onClearChanged: if (clear) sys.pause();
+ onEmptyChanged: if (empty) sys.pause();
}
ImageParticle{
system: sys
@@ -60,12 +60,12 @@ Rectangle{
//burst on click
id: bursty
system: sys
- emitting: ma.pressed
+ enabled: ma.pressed
x: ma.mouseX
y: ma.mouseY
emitRate: 16000
- emitCap: 4000
- acceleration: AngledDirection{angleVariation: 360; magnitude: 360; }
+ maximumEmitted: 4000
+ acceleration: AngleDirection{angleVariation: 360; magnitude: 360; }
size: 8
endSize: 16
sizeVariation: 4
@@ -78,7 +78,7 @@ Rectangle{
MouseArea{
width: 100
height: 100
- onClicked: bursty.noCap = true;
+ onClicked: bursty.maximumEmitted = -1;
id: ma2
Rectangle{
anchors.fill: parent
diff --git a/examples/declarative/particles/trails/portal.qml b/examples/declarative/particles/trails/portal.qml
index 8cf323b0f5..85efd9a594 100644
--- a/examples/declarative/particles/trails/portal.qml
+++ b/examples/declarative/particles/trails/portal.qml
@@ -52,7 +52,6 @@ Rectangle{
}
ParticleSystem{
id: particles
- startTime: 2000
}
ImageParticle{
particles: ["center","edge"]
@@ -68,12 +67,11 @@ Rectangle{
system: particles
emitRate: 200
lifeSpan: 2000
- emitting: true
size: 20
sizeVariation: 2
endSize: 0
shape: EllipseShape{fill: false}
- speed: TargetedDirection{
+ speed: TargetDirection{
targetX: root.width/2
targetY: root.height/2
proportionalMagnitude: true
@@ -83,22 +81,22 @@ Rectangle{
Emitter{
anchors.fill: parent
particle: "edge"
+ startTime: 2000
system: particles
emitRate: 4000
lifeSpan: 2000
- emitting: true
size: 20
sizeVariation: 2
endSize: 0
shape: EllipseShape{fill: false}
- speed: TargetedDirection{
+ speed: TargetDirection{
targetX: root.width/2
targetY: root.height/2
proportionalMagnitude: true
magnitude: 0.1
magnitudeVariation: 0.1
}
- acceleration: TargetedDirection{
+ acceleration: TargetDirection{
targetX: root.width/2
targetY: root.height/2
targetVariation: 200
diff --git a/examples/declarative/particles/trails/shimmer.qml b/examples/declarative/particles/trails/shimmer.qml
index d195a4477b..90b47bc6b7 100644
--- a/examples/declarative/particles/trails/shimmer.qml
+++ b/examples/declarative/particles/trails/shimmer.qml
@@ -72,7 +72,6 @@ Rectangle{
system: particles
emitRate: 2000
lifeSpan: 2000
- emitting: true
size: 30
sizeVariation: 10
}
diff --git a/examples/declarative/particles/trails/trails.qml b/examples/declarative/particles/trails/trails.qml
index 689de4eb41..1b6f9e00c7 100644
--- a/examples/declarative/particles/trails/trails.qml
+++ b/examples/declarative/particles/trails/trails.qml
@@ -57,10 +57,10 @@ Rectangle{
//burst on click
id: bursty
system: sys
- emitting: false
+ enabled: false
emitRate: 2000
lifeSpan: 500
- acceleration: AngledDirection{ angle: 90; angleVariation: 360; magnitude: 640; }
+ acceleration: AngleDirection{ angle: 90; angleVariation: 360; magnitude: 640; }
size: 8
endSize: 16
sizeVariation: 4
@@ -68,12 +68,12 @@ Rectangle{
Emitter{
system: sys
speedFromMovement: 4.0
- emitting: ma.pressed
+ enabled: ma.pressed
x: ma.mouseX
y: ma.mouseY
emitRate: 400
lifeSpan: 2000
- acceleration: AngledDirection{ angle: 90; angleVariation: 22; magnitude: 32; }
+ acceleration: AngleDirection{ angle: 90; angleVariation: 22; magnitude: 32; }
size: 8
endSize: 16
sizeVariation: 8
diff --git a/examples/declarative/particles/trails/turbulence.qml b/examples/declarative/particles/trails/turbulence.qml
index 3f822c7889..62216c3460 100644
--- a/examples/declarative/particles/trails/turbulence.qml
+++ b/examples/declarative/particles/trails/turbulence.qml
@@ -91,9 +91,9 @@ Rectangle{
endSize: 10
sizeVariation: 10
acceleration: PointDirection{ y: -40 }
- speed: AngledDirection{ angle: 270; magnitude: 20; angleVariation: 22; magnitudeVariation: 5 }
+ speed: AngleDirection{ angle: 270; magnitude: 20; angleVariation: 22; magnitudeVariation: 5 }
}
- FollowEmitter{
+ TrailEmitter{
id: smoke1
width: root.width
height: 258
@@ -108,9 +108,9 @@ Rectangle{
endSize: 8
sizeVariation: 8
acceleration: PointDirection{ y: -40 }
- speed: AngledDirection{ angle: 270; magnitude: 40; angleVariation: 22; magnitudeVariation: 5 }
+ speed: AngleDirection{ angle: 270; magnitude: 40; angleVariation: 22; magnitudeVariation: 5 }
}
- FollowEmitter{
+ TrailEmitter{
id: smoke2
width: root.width
height: 232
@@ -124,6 +124,6 @@ Rectangle{
endSize: 24
sizeVariation: 8
acceleration: PointDirection{ y: -40 }
- speed: AngledDirection{ angle: 270; magnitude: 40; angleVariation: 22; magnitudeVariation: 5 }
+ speed: AngleDirection{ angle: 270; magnitude: 40; angleVariation: 22; magnitudeVariation: 5 }
}
}
diff --git a/examples/declarative/plasmapatrol/content/BlasterHardpoint.qml b/examples/declarative/plasmapatrol/content/BlasterHardpoint.qml
index 87c1822c05..384275fc94 100644
--- a/examples/declarative/plasmapatrol/content/BlasterHardpoint.qml
+++ b/examples/declarative/plasmapatrol/content/BlasterHardpoint.qml
@@ -57,10 +57,10 @@ Item {
id: visualization
particle: "blaster"
system: container.system
- emitting: show
+ enabled: show
anchors.fill: parent
shape: EllipseShape{}
- speed: TargetedDirection{ targetX: width/2; targetY: width/2; magnitude: -1; proportionalMagnitude: true}
+ speed: TargetDirection{ targetX: width/2; targetY: width/2; magnitude: -1; proportionalMagnitude: true}
lifeSpan: 1000
emitRate: 64
@@ -115,17 +115,17 @@ Item {
Emitter{
id: emitter
particle: "blaster"
- emitting: false
+ enabled: false
system: container.system
anchors.centerIn: parent
lifeSpan: 1000
emitRate: 16
- emitCap: blasts
+ maximumEmitted: blasts
size: 24
endSize:16
sizeVariation: 8
- speed: TargetedDirection{
+ speed: TargetDirection{
id: blastVector
targetX: target.x; targetY: target.y; magnitude: 1.1; proportionalMagnitude: true
}
diff --git a/examples/declarative/plasmapatrol/content/CannonHardpoint.qml b/examples/declarative/plasmapatrol/content/CannonHardpoint.qml
index e0c23c1d63..b2c7aca1fd 100644
--- a/examples/declarative/plasmapatrol/content/CannonHardpoint.qml
+++ b/examples/declarative/plasmapatrol/content/CannonHardpoint.qml
@@ -52,7 +52,7 @@ Item {
Emitter{
id: visualization
particle: "cannon"
- emitting: container.show
+ enabled: container.show
system: container.system
anchors.centerIn: parent
lifeSpan: 2000
@@ -81,7 +81,7 @@ Item {
Emitter{
id: emitter
particle: "cannon"
- emitting: false
+ enabled: false
system: container.system
anchors.centerIn: parent
@@ -89,7 +89,7 @@ Item {
emitRate: 1
size: 8
endSize: 4
- speed: TargetedDirection{
+ speed: TargetDirection{
id: blastVector
targetX: target.x; targetY: target.y; magnitude: 1.1; proportionalMagnitude: true
}
diff --git a/examples/declarative/plasmapatrol/content/Cruiser.qml b/examples/declarative/plasmapatrol/content/Cruiser.qml
index 4f600b961f..b0d20023db 100644
--- a/examples/declarative/plasmapatrol/content/Cruiser.qml
+++ b/examples/declarative/plasmapatrol/content/Cruiser.qml
@@ -66,20 +66,20 @@ Item {
emitRate: hp > 0 ? hp * 1 + 20 : 0
lifeSpan: 2400
- emitCap: (maxHP * 1 + 20)*2.4
+ maximumEmitted: (maxHP * 1 + 20)*2.4
size: 48
sizeVariation: 16
endSize: 16
- speed: AngledDirection{angleVariation:360; magnitudeVariation: 32}
+ speed: AngleDirection{angleVariation:360; magnitudeVariation: 32}
}
Emitter{
system: container.system
particle: "cruiserArmor"
anchors.fill: parent
shape: EllipseShape{ fill: false }
- emitting: hp>0
+ enabled: hp>0
emitRate: 16
lifeSpan: 2000
@@ -90,12 +90,12 @@ Item {
SpriteGoal{
id: destructor
system: container.system
- active: container.hp <=0
+ enabled: container.hp <=0
anchors.fill: parent
particles: ["cruiserArmor"]
goalState: "death"
// jump: true
- onceOff: true
+ once: true
}
}
diff --git a/examples/declarative/plasmapatrol/content/Frigate.qml b/examples/declarative/plasmapatrol/content/Frigate.qml
index 5c61177f66..8d493b81d5 100644
--- a/examples/declarative/plasmapatrol/content/Frigate.qml
+++ b/examples/declarative/plasmapatrol/content/Frigate.qml
@@ -61,7 +61,7 @@ Item {
size: 92
emitRate: 1
lifeSpan: 4800
- emitting: hp > 0
+ enabled: hp > 0
}
Emitter{
system: container.system
@@ -76,7 +76,7 @@ Item {
endSize: 8
emitRate: hp > 0 ? hp * 1 + 20 : 0
lifeSpan: 1200
- emitCap: (maxHP * 1 + 20)*2
+ maximumEmitted: (maxHP * 1 + 20)*2
}
Timer{
id: fireControl
diff --git a/examples/declarative/plasmapatrol/content/LaserHardpoint.qml b/examples/declarative/plasmapatrol/content/LaserHardpoint.qml
index ffc4be7acb..45712bf68a 100644
--- a/examples/declarative/plasmapatrol/content/LaserHardpoint.qml
+++ b/examples/declarative/plasmapatrol/content/LaserHardpoint.qml
@@ -54,9 +54,9 @@ Item {
particle: "laser"
system: container.system
anchors.fill: parent
- emitting: container.show
+ enabled: container.show
shape: EllipseShape{}
- speed: TargetedDirection{ targetX: width/2; targetY: width/2; magnitude: -1; proportionalMagnitude: true }
+ speed: TargetDirection{ targetX: width/2; targetY: width/2; magnitude: -1; proportionalMagnitude: true }
lifeSpan: 1000
emitRate: 64
@@ -87,7 +87,7 @@ Item {
Emitter{
id: emitter
particle: "laser"
- emitting: false
+ enabled: false
system: container.system
x: Math.min(container.width/2, target.x);
width: Math.max(container.width/2, target.x) - x;
@@ -99,7 +99,7 @@ Item {
lifeSpan: 1000
emitRate: 8000
- emitCap: 800
+ maximumEmitted: 800
size: 16
endSize: 0
diff --git a/examples/declarative/plasmapatrol/content/PlasmaPatrolParticles.qml b/examples/declarative/plasmapatrol/content/PlasmaPatrolParticles.qml
index 1ce1d065a5..792ba7ab72 100644
--- a/examples/declarative/plasmapatrol/content/PlasmaPatrolParticles.qml
+++ b/examples/declarative/plasmapatrol/content/PlasmaPatrolParticles.qml
@@ -144,21 +144,21 @@ Item{
}
]
}
- FollowEmitter{
+ TrailEmitter{
system: sys
particle: "cannonWake"
follow: "cannon"
emitRatePerParticle: 64
lifeSpan: 600
- speed: AngledDirection{ angleVariation: 360; magnitude: 48}
+ speed: AngleDirection{ angleVariation: 360; magnitude: 48}
size: 16
endSize: 8
sizeVariation: 2
- emitting: true
+ enabled: true
width: 1000//XXX: Terrible hack
height: 1000
}
- FollowEmitter{
+ TrailEmitter{
system: sys
particle: "cannonCore"
follow: "cannon"
@@ -166,7 +166,7 @@ Item{
lifeSpan: 128
size: 24
endSize: 8
- emitting: true
+ enabled: true
width: 1000//XXX: Terrible hack
height: 1000
}
diff --git a/examples/declarative/plasmapatrol/content/Sloop.qml b/examples/declarative/plasmapatrol/content/Sloop.qml
index cfb5798ec6..82e57f5161 100644
--- a/examples/declarative/plasmapatrol/content/Sloop.qml
+++ b/examples/declarative/plasmapatrol/content/Sloop.qml
@@ -65,9 +65,9 @@ Item {
emitRate: hp > 0 ? hp + 20 : 0
lifeSpan: blinkInterval
- emitCap: (maxHP + 20)
+ maximumEmitted: (maxHP + 20)
- acceleration: AngledDirection{angleVariation: 360; magnitude: 8}
+ acceleration: AngleDirection{angleVariation: 360; magnitude: 8}
size: 24
endSize: 4
diff --git a/examples/declarative/plasmapatrol/plasmapatrol.qml b/examples/declarative/plasmapatrol/plasmapatrol.qml
index be6d15ec13..4ea464b9f8 100644
--- a/examples/declarative/plasmapatrol/plasmapatrol.qml
+++ b/examples/declarative/plasmapatrol/plasmapatrol.qml
@@ -96,7 +96,7 @@ Rectangle {
Emitter{
anchors.fill: parent
system: particles
- emitting: true
+ enabled: true
particle: "default"
emitRate: 1200
lifeSpan: 1200
@@ -104,7 +104,7 @@ Rectangle {
size: 16
endSize: 0
sizeVariation: 8
- speed: AngledDirection{angleVariation:360; magnitudeVariation: 6}
+ speed: AngleDirection{angleVariation:360; magnitudeVariation: 6}
}
}
Button{
diff --git a/examples/declarative/samegame/SamegameCore/BoomBlock.qml b/examples/declarative/samegame/SamegameCore/BoomBlock.qml
index 4f8ef70851..1c84fa8614 100644
--- a/examples/declarative/samegame/SamegameCore/BoomBlock.qml
+++ b/examples/declarative/samegame/SamegameCore/BoomBlock.qml
@@ -86,12 +86,12 @@ Item {
}
anchors.fill: parent
- speed: TargetedDirection{targetX: block.width/2; targetY: block.height/2; magnitude: -60; magnitudeVariation: 60}
+ speed: TargetDirection{targetX: block.width/2; targetY: block.height/2; magnitude: -60; magnitudeVariation: 60}
shape: EllipseShape{fill:true}
- emitting: false;
+ enabled: false;
lifeSpan: 700; lifeSpanVariation: 100
emitRate: 1000
- emitCap: 100 //only fires 0.1s bursts (still 2x old number, ImageParticle wants less than 16000 max though)
+ maximumEmitted: 100 //only fires 0.1s bursts (still 2x old number)
size: 28
endSize: 14
}
diff --git a/src/declarative/particles/particles.pri b/src/declarative/particles/particles.pri
index 9f63cd81b9..527bd9ae61 100644
--- a/src/declarative/particles/particles.pri
+++ b/src/declarative/particles/particles.pri
@@ -1,18 +1,18 @@
INCLUDEPATH += $$PWD
HEADERS += \
- $$PWD/qsgangleddirection_p.h \
+ $$PWD/qsgangledirection_p.h \
$$PWD/qsgcustomparticle_p.h \
+ $$PWD/qsgcustomaffector_p.h \
$$PWD/qsgellipseextruder_p.h \
- $$PWD/qsgfollowemitter_p.h \
+ $$PWD/qsgtrailemitter_p.h \
$$PWD/qsgfriction_p.h \
$$PWD/qsggravity_p.h \
$$PWD/qsgimageparticle_p.h \
$$PWD/qsgitemparticle_p.h \
- $$PWD/qsgkill_p.h \
+ $$PWD/qsgage_p.h \
$$PWD/qsglineextruder_p.h \
$$PWD/qsgmaskextruder_p.h \
- $$PWD/qsgmodelparticle_p.h \
$$PWD/qsgparticleaffector_p.h \
$$PWD/qsgparticleemitter_p.h \
$$PWD/qsgparticleextruder_p.h \
@@ -22,27 +22,28 @@ HEADERS += \
$$PWD/qsgpointattractor_p.h \
$$PWD/qsgpointdirection_p.h \
$$PWD/qsgspritegoal_p.h \
- $$PWD/qsgstochasticdirection_p.h \
- $$PWD/qsgtargeteddirection_p.h \
+ $$PWD/qsgdirection_p.h \
+ $$PWD/qsgtargetdirection_p.h \
$$PWD/qsgturbulence_p.h \
$$PWD/qsgwander_p.h \
$$PWD/qsgtargetaffector_p.h \
$$PWD/qsgcumulativedirection_p.h \
- $$PWD/qsgv8particledata_p.h
+ $$PWD/qsgv8particledata_p.h \
+ $$PWD/qsgrectangleextruder_p.h
SOURCES += \
- $$PWD/qsgangleddirection.cpp \
+ $$PWD/qsgangledirection.cpp \
$$PWD/qsgcustomparticle.cpp \
+ $$PWD/qsgcustomaffector.cpp \
$$PWD/qsgellipseextruder.cpp \
- $$PWD/qsgfollowemitter.cpp \
+ $$PWD/qsgtrailemitter.cpp \
$$PWD/qsgfriction.cpp \
$$PWD/qsggravity.cpp \
$$PWD/qsgimageparticle.cpp \
$$PWD/qsgitemparticle.cpp \
- $$PWD/qsgkill.cpp \
+ $$PWD/qsgage.cpp \
$$PWD/qsglineextruder.cpp \
$$PWD/qsgmaskextruder.cpp \
- $$PWD/qsgmodelparticle.cpp \
$$PWD/qsgparticleaffector.cpp \
$$PWD/qsgparticleemitter.cpp \
$$PWD/qsgparticleextruder.cpp \
@@ -52,13 +53,14 @@ SOURCES += \
$$PWD/qsgpointattractor.cpp \
$$PWD/qsgpointdirection.cpp \
$$PWD/qsgspritegoal.cpp \
- $$PWD/qsgstochasticdirection.cpp \
- $$PWD/qsgtargeteddirection.cpp \
+ $$PWD/qsgdirection.cpp \
+ $$PWD/qsgtargetdirection.cpp \
$$PWD/qsgturbulence.cpp \
$$PWD/qsgwander.cpp \
$$PWD/qsgtargetaffector.cpp \
$$PWD/qsgcumulativedirection.cpp \
- $$PWD/qsgv8particledata.cpp
+ $$PWD/qsgv8particledata.cpp \
+ $$PWD/qsgrectangleextruder.cpp
RESOURCES += \
$$PWD/particles.qrc
diff --git a/src/declarative/particles/qsgage.cpp b/src/declarative/particles/qsgage.cpp
new file mode 100644
index 0000000000..2c0678fd0e
--- /dev/null
+++ b/src/declarative/particles/qsgage.cpp
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Declarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsgage_p.h"
+#include "qsgparticleemitter_p.h"
+QT_BEGIN_NAMESPACE
+/*!
+ \qmlclass Age QSGAgeAffector
+ \inqmlmodule QtQuick.Particles 2
+ \inherits Affector
+ \brief The Age affector allows you to prematurely age particles
+
+ The Age affector allows you to alter where the particle is in its lifecycle. Common uses
+ are to expire particles prematurely, possibly giving them time to animate out.
+
+ The Age affector only applies to particles which are still alive.
+*/
+/*!
+ \qmlproperty int QtQuick.Particles2::Age::lifeLeft
+
+ The amount of life to set the particle to have. Affected particles
+ will jump to a point in their life where they will have this many
+ milliseconds left to live.
+*/
+
+QSGAgeAffector::QSGAgeAffector(QSGItem *parent) :
+ QSGParticleAffector(parent), m_lifeLeft(0)
+{
+}
+
+
+bool QSGAgeAffector::affectParticle(QSGParticleData *d, qreal dt)
+{
+ Q_UNUSED(dt);
+ if (d->stillAlive()){
+ qreal curT = (qreal)m_system->m_timeInt/1000.0;
+ qreal ttl = (qreal)m_lifeLeft/1000.0;
+ d->t = curT - (d->lifeSpan - ttl) + 1;
+ return true;
+ }
+ return false;
+}
+QT_END_NAMESPACE
diff --git a/src/declarative/particles/qsgkill.cpp b/src/declarative/particles/qsgage_p.h
index dfd26e3f39..c4c9929ad8 100644
--- a/src/declarative/particles/qsgkill.cpp
+++ b/src/declarative/particles/qsgage_p.h
@@ -39,30 +39,49 @@
**
****************************************************************************/
-#include "qsgkill_p.h"
-#include "qsgparticleemitter_p.h"
+#ifndef KILLAFFECTOR_H
+#define KILLAFFECTOR_H
+#include "qsgparticleaffector_p.h"
+
+QT_BEGIN_HEADER
+
QT_BEGIN_NAMESPACE
-/*!
- \qmlclass Kill QSGKillAffector
- \inqmlmodule QtQuick.Particles 2
- \inherits Affector
- \brief The Kill affector allows you to expire affected particles
-*/
+QT_MODULE(Declarative)
+
-QSGKillAffector::QSGKillAffector(QSGItem *parent) :
- QSGParticleAffector(parent)
+class QSGAgeAffector : public QSGParticleAffector
{
-}
+ Q_OBJECT
+ Q_PROPERTY(int lifeLeft READ lifeLeft WRITE setLifeLeft NOTIFY lifeLeftChanged)
+public:
+ explicit QSGAgeAffector(QSGItem *parent = 0);
-bool QSGKillAffector::affectParticle(QSGParticleData *d, qreal dt)
-{
- Q_UNUSED(dt);
- if (d->stillAlive()){
- d->t -= d->lifeSpan + 1;
- return true;
+ int lifeLeft() const
+ {
+ return m_lifeLeft;
+ }
+
+protected:
+ virtual bool affectParticle(QSGParticleData *d, qreal dt);
+signals:
+ void lifeLeftChanged(int arg);
+
+public slots:
+ void setLifeLeft(int arg)
+ {
+ if (m_lifeLeft != arg) {
+ m_lifeLeft = arg;
+ emit lifeLeftChanged(arg);
+ }
}
- return false;
-}
+
+private:
+
+int m_lifeLeft;
+};
+
QT_END_NAMESPACE
+QT_END_HEADER
+#endif // KILLAFFECTOR_H
diff --git a/src/declarative/particles/qsgangleddirection.cpp b/src/declarative/particles/qsgangledirection.cpp
index ab39b8a575..10a31bf07e 100644
--- a/src/declarative/particles/qsgangleddirection.cpp
+++ b/src/declarative/particles/qsgangledirection.cpp
@@ -39,21 +39,21 @@
**
****************************************************************************/
-#include "qsgangleddirection_p.h"
+#include "qsgangledirection_p.h"
#include <cmath>
QT_BEGIN_NAMESPACE
const qreal CONV = 0.017453292519943295;
/*!
- \qmlclass AngledDirection QSGAngledDirection
+ \qmlclass AngleDirection QSGAngleDirection
\inqmlmodule QtQuick.Particles 2
- \inherits StochasticDirection
- \brief The AngledDirection element allows you to specify a direction that varies in angle
+ \inherits Direction
+ \brief The AngleDirection element allows you to specify a direction that varies in angle
The AngledDirection element allows both the specification of a direction by angle and magnitude,
as well as varying the parameters by angle or magnitude.
*/
/*!
- \qmlproperty real QtQuick.Particles2::AngledDirection::angle
+ \qmlproperty real QtQuick.Particles2::AngleDirection::angle
This property specifies the base angle for the direction.
The angle of this direction will vary by no more than angleVariation
from this angle.
@@ -63,7 +63,7 @@ const qreal CONV = 0.017453292519943295;
The default value is zero.
*/
/*!
- \qmlproperty real QtQuick.Particles2::AngledDirection::magnitude
+ \qmlproperty real QtQuick.Particles2::AngleDirection::magnitude
This property specifies the base magnitude for the direction.
The magnitude of this direction will vary by no more than magnitudeVariation
from this magnitude.
@@ -73,7 +73,7 @@ const qreal CONV = 0.017453292519943295;
The default value is zero.
*/
/*!
- \qmlproperty real QtQuick.Particles2::AngledDirection::angleVariation
+ \qmlproperty real QtQuick.Particles2::AngleDirection::angleVariation
This property specifies the maximum angle variation for the direction.
The angle of the direction will vary by up to angleVariation clockwise
and anticlockwise from the value specified in angle.
@@ -83,7 +83,7 @@ const qreal CONV = 0.017453292519943295;
The default value is zero.
*/
/*!
- \qmlproperty real QtQuick.Particles2::AngledDirection::magnitudeVariation
+ \qmlproperty real QtQuick.Particles2::AngleDirection::magnitudeVariation
This property specifies the base magnitude for the direction.
The magnitude of this direction will vary by no more than magnitudeVariation
from the base magnitude.
@@ -92,8 +92,8 @@ const qreal CONV = 0.017453292519943295;
The default value is zero.
*/
-QSGAngledDirection::QSGAngledDirection(QObject *parent) :
- QSGStochasticDirection(parent)
+QSGAngleDirection::QSGAngleDirection(QObject *parent) :
+ QSGDirection(parent)
, m_angle(0)
, m_magnitude(0)
, m_angleVariation(0)
@@ -102,7 +102,7 @@ QSGAngledDirection::QSGAngledDirection(QObject *parent) :
}
-const QPointF &QSGAngledDirection::sample(const QPointF &from)
+const QPointF &QSGAngleDirection::sample(const QPointF &from)
{
//TODO: Faster
qreal theta = m_angle*CONV - m_angleVariation*CONV + rand()/float(RAND_MAX) * m_angleVariation*CONV * 2;
diff --git a/src/declarative/particles/qsgangleddirection_p.h b/src/declarative/particles/qsgangledirection_p.h
index 4d5522d13c..870a7eb0d9 100644
--- a/src/declarative/particles/qsgangleddirection_p.h
+++ b/src/declarative/particles/qsgangledirection_p.h
@@ -41,14 +41,14 @@
#ifndef QSGANGLEDDIRECTION_H
#define QSGANGLEDDIRECTION_H
-#include "qsgstochasticdirection_p.h"
+#include "qsgdirection_p.h"
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
-class QSGAngledDirection : public QSGStochasticDirection
+class QSGAngleDirection : public QSGDirection
{
Q_OBJECT
Q_PROPERTY(qreal angle READ angle WRITE setAngle NOTIFY angleChanged)
@@ -56,7 +56,7 @@ class QSGAngledDirection : public QSGStochasticDirection
Q_PROPERTY(qreal angleVariation READ angleVariation WRITE setAngleVariation NOTIFY angleVariationChanged)
Q_PROPERTY(qreal magnitudeVariation READ magnitudeVariation WRITE setMagnitudeVariation NOTIFY magnitudeVariationChanged)
public:
- explicit QSGAngledDirection(QObject *parent = 0);
+ explicit QSGAngleDirection(QObject *parent = 0);
const QPointF &sample(const QPointF &from);
qreal angle() const
{
diff --git a/src/declarative/particles/qsgcumulativedirection.cpp b/src/declarative/particles/qsgcumulativedirection.cpp
index 1d7523972b..8e4e6b681d 100644
--- a/src/declarative/particles/qsgcumulativedirection.cpp
+++ b/src/declarative/particles/qsgcumulativedirection.cpp
@@ -45,24 +45,24 @@ QT_BEGIN_NAMESPACE
/*!
\qmlclass CumulativeDirection QSGCumulativeDirection
\inqmlmodule QtQuick.Particles 2
- \inherits StochasticDirection
+ \inherits Direction
\brief The CumulativeDirection element allows you to specify a direction made of other directions
The CumulativeDirection element will act as a direction that sums the directions within it.
*/
-QSGCumulativeDirection::QSGCumulativeDirection(QObject *parent):QSGStochasticDirection(parent)
+QSGCumulativeDirection::QSGCumulativeDirection(QObject *parent):QSGDirection(parent)
{
}
-QDeclarativeListProperty<QSGStochasticDirection> QSGCumulativeDirection::directions()
+QDeclarativeListProperty<QSGDirection> QSGCumulativeDirection::directions()
{
- return QDeclarativeListProperty<QSGStochasticDirection>(this, m_directions);//TODO: Proper list property
+ return QDeclarativeListProperty<QSGDirection>(this, m_directions);//TODO: Proper list property
}
const QPointF &QSGCumulativeDirection::sample(const QPointF &from)
{
QPointF ret;
- foreach (QSGStochasticDirection* dir, m_directions)
+ foreach (QSGDirection* dir, m_directions)
ret += dir->sample(from);
return ret;
}
diff --git a/src/declarative/particles/qsgcumulativedirection_p.h b/src/declarative/particles/qsgcumulativedirection_p.h
index c54a795931..4f93fed1bd 100644
--- a/src/declarative/particles/qsgcumulativedirection_p.h
+++ b/src/declarative/particles/qsgcumulativedirection_p.h
@@ -41,7 +41,7 @@
#ifndef QSGCUMULATIVEDIRECTION_P_H
#define QSGCUMULATIVEDIRECTION_P_H
-#include "qsgstochasticdirection_p.h"
+#include "qsgdirection_p.h"
#include <QDeclarativeListProperty>
QT_BEGIN_HEADER
@@ -49,16 +49,16 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
-class QSGCumulativeDirection : public QSGStochasticDirection
+class QSGCumulativeDirection : public QSGDirection
{
Q_OBJECT
- Q_PROPERTY(QDeclarativeListProperty<QSGStochasticDirection> directions READ directions)
+ Q_PROPERTY(QDeclarativeListProperty<QSGDirection> directions READ directions)
Q_CLASSINFO("DefaultProperty", "directions")
public:
explicit QSGCumulativeDirection(QObject *parent = 0);
- QDeclarativeListProperty<QSGStochasticDirection> directions();
+ QDeclarativeListProperty<QSGDirection> directions();
const QPointF &sample(const QPointF &from);
private:
- QList<QSGStochasticDirection*> m_directions;
+ QList<QSGDirection*> m_directions;
};
#endif // QSGCUMULATIVEDIRECTION_P_H
diff --git a/src/declarative/particles/qsgcustomaffector.cpp b/src/declarative/particles/qsgcustomaffector.cpp
new file mode 100644
index 0000000000..70e1dbe035
--- /dev/null
+++ b/src/declarative/particles/qsgcustomaffector.cpp
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Declarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsgcustomaffector_p.h"
+#include <QDebug>
+QT_BEGIN_NAMESPACE
+
+//TODO: Move docs (and inherit) to real base when docs can propagate
+//TODO: Document particle 'type'
+/*!
+ \qmlsignal QtQuick.Particles2::Affector::affectParticle(particle, dt)
+
+ This handler is called when particles are selected to be affected.
+
+ dt is the time since the last time it was affected. Use dt to normalize
+ trajectory manipulations to real time.
+
+ Note that JS is slower to execute, so it is not recommended to use this in
+ high-volume particle systems.
+*/
+QSGCustomAffector::QSGCustomAffector(QSGItem *parent) :
+ QSGParticleAffector(parent)
+{
+}
+
+bool QSGCustomAffector::isAffectConnected()
+{
+ static int idx = QObjectPrivate::get(this)->signalIndex("affectParticle(QDeclarativeV8Handle,qreal)");
+ return QObjectPrivate::get(this)->isSignalConnected(idx);
+}
+
+bool QSGCustomAffector::affectParticle(QSGParticleData *d, qreal dt)
+{
+ if (isAffectConnected()){
+ d->update = 0.0;
+ emit affectParticle(d->v8Value(), dt);
+ return d->update == 1.0;
+ }
+ return true;
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/particles/qsgkill_p.h b/src/declarative/particles/qsgcustomaffector_p.h
index d1e2292f13..7f39200298 100644
--- a/src/declarative/particles/qsgkill_p.h
+++ b/src/declarative/particles/qsgcustomaffector_p.h
@@ -39,8 +39,12 @@
**
****************************************************************************/
-#ifndef KILLAFFECTOR_H
-#define KILLAFFECTOR_H
+#ifndef CUSTOMAFFECTOR_H
+#define CUSTOMAFFECTOR_H
+
+#include <QObject>
+#include "qsgparticlesystem_p.h"
+#include "qsgparticleextruder_p.h"
#include "qsgparticleaffector_p.h"
QT_BEGIN_HEADER
@@ -49,20 +53,22 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
-
-class QSGKillAffector : public QSGParticleAffector
+class QSGCustomAffector : public QSGParticleAffector
{
Q_OBJECT
+
public:
- explicit QSGKillAffector(QSGItem *parent = 0);
-protected:
- virtual bool affectParticle(QSGParticleData *d, qreal dt);
-signals:
+ explicit QSGCustomAffector(QSGItem *parent = 0);
+signals:
+ void affectParticle(QDeclarativeV8Handle particle, qreal dt);
public slots:
-
+protected:
+ bool isAffectConnected();
+ virtual bool affectParticle(QSGParticleData *d, qreal dt);
+private:
};
QT_END_NAMESPACE
QT_END_HEADER
-#endif // KILLAFFECTOR_H
+#endif // CUSTOMAFFECTOR_H
diff --git a/src/declarative/particles/qsgcustomparticle.cpp b/src/declarative/particles/qsgcustomparticle.cpp
index 00e3ec185b..6c95fe66c0 100644
--- a/src/declarative/particles/qsgcustomparticle.cpp
+++ b/src/declarative/particles/qsgcustomparticle.cpp
@@ -47,36 +47,36 @@ QT_BEGIN_NAMESPACE
//Includes comments because the code isn't self explanatory
static const char qt_particles_template_vertex_code[] =
- "attribute highp vec2 vPos; \n"
- "attribute highp vec2 vTex; \n"
- "attribute highp vec4 vData; // x = time, y = lifeSpan, z = size, w = endSize \n"
- "attribute highp vec4 vVec; // x,y = constant speed, z,w = acceleration \n"
- "attribute highp float r; \n"
- "uniform highp mat4 qt_Matrix; \n"
- "uniform highp float timestamp; \n"
- "varying highp vec2 fTex; \n"
- "void defaultMain() { \n"
- " fTex = vTex; \n"
- " highp float size = vData.z; \n"
- " highp float endSize = vData.w; \n"
- " highp float t = (timestamp - vData.x) / vData.y; \n"
- " highp float currentSize = mix(size, endSize, t * t); \n"
- " if (t < 0. || t > 1.) \n"
- " currentSize = 0.; \n"
- " highp vec2 pos = vPos \n"
- " - currentSize / 2. + currentSize * vTex // adjust size \n"
- " + vVec.xy * t * vData.y // apply speed vector.. \n"
- " + 0.5 * vVec.zw * pow(t * vData.y, 2.); \n"
- " gl_Position = qt_Matrix * vec4(pos.x, pos.y, 0, 1); \n"
- "}\n";
+ "attribute highp vec2 qt_ParticlePos;\n"
+ "attribute highp vec2 qt_ParticleTex;\n"
+ "attribute highp vec4 qt_ParticleData; // x = time, y = lifeSpan, z = size, w = endSize\n"
+ "attribute highp vec4 qt_ParticleVec; // x,y = constant speed, z,w = acceleration\n"
+ "attribute highp float qt_ParticleR;\n"
+ "uniform highp mat4 qt_Matrix;\n"
+ "uniform highp float qt_Timestamp;\n"
+ "varying highp vec2 qt_TexCoord0;\n"
+ "void defaultMain() {\n"
+ " qt_TexCoord0 = qt_ParticleTex;\n"
+ " highp float size = qt_ParticleData.z;\n"
+ " highp float endSize = qt_ParticleData.w;\n"
+ " highp float t = (qt_Timestamp - qt_ParticleData.x) / qt_ParticleData.y;\n"
+ " highp float currentSize = mix(size, endSize, t * t);\n"
+ " if (t < 0. || t > 1.)\n"
+ " currentSize = 0.;\n"
+ " highp vec2 pos = qt_ParticlePos\n"
+ " - currentSize / 2. + currentSize * qt_ParticleTex // adjust size\n"
+ " + qt_ParticleVec.xy * t * qt_ParticleData.y // apply speed vector..\n"
+ " + 0.5 * qt_ParticleVec.zw * pow(t * qt_ParticleData.y, 2.);\n"
+ " gl_Position = qt_Matrix * vec4(pos.x, pos.y, 0, 1);\n"
+ "}";
static const char qt_particles_default_vertex_code[] =
"void main() { \n"
" defaultMain(); \n"
"}";
-static const char qt_particles_default_fragment_code[] =//TODO: Default frag requires source?
+static const char qt_particles_default_fragment_code[] =
"uniform sampler2D source; \n"
- "varying highp vec2 fTex; \n"
+ "varying highp vec2 qt_TexCoord0; \n"
"uniform lowp float qt_Opacity; \n"
"void main() { \n"
" gl_FragColor = texture2D(source, fTex) * qt_Opacity; \n"
@@ -150,7 +150,7 @@ void QSGCustomParticle::componentComplete()
This property holds the fragment shader's GLSL source code.
The default shader expects the texture coordinate to be passed from the
- vertex shader as "varying highp vec2 fTex", and it samples from a
+ vertex shader as "varying highp vec2 qt_TexCoord0", and it samples from a
sampler2D named "source".
*/
@@ -171,31 +171,31 @@ void QSGCustomParticle::setFragmentShader(const QByteArray &code)
This property holds the vertex shader's GLSL source code.
The default shader passes the texture coordinate along to the fragment
- shader as "varying highp vec2 fTex".
+ shader as "varying highp vec2 qt_TexCoord0".
To aid writing a particle vertex shader, the following GLSL code is prepended
to your vertex shader:
\code
- attribute highp vec2 vPos;
- attribute highp vec2 vTex;
- attribute highp vec4 vData; // x = time, y = lifeSpan, z = size, w = endSize
- attribute highp vec4 vVec; // x,y = constant speed, z,w = acceleration
- attribute highp float r;
+ attribute highp vec2 qt_ParticlePos;
+ attribute highp vec2 qt_ParticleTex;
+ attribute highp vec4 qt_ParticleData; // x = time, y = lifeSpan, z = size, w = endSize
+ attribute highp vec4 qt_ParticleVec; // x,y = constant speed, z,w = acceleration
+ attribute highp float qt_ParticleR;
uniform highp mat4 qt_Matrix;
- uniform highp float timestamp;
- varying highp vec2 fTex;
+ uniform highp float qt_Timestamp;
+ varying highp vec2 qt_TexCoord0;
void defaultMain() {
- fTex = vTex;
- highp float size = vData.z;
- highp float endSize = vData.w;
- highp float t = (timestamp - vData.x) / vData.y;
+ qt_TexCoord0 = qt_ParticleTex;
+ highp float size = qt_ParticleData.z;
+ highp float endSize = qt_ParticleData.w;
+ highp float t = (qt_Timestamp - qt_ParticleData.x) / qt_ParticleData.y;
highp float currentSize = mix(size, endSize, t * t);
if (t < 0. || t > 1.)
currentSize = 0.;
- highp vec2 pos = vPos
- - currentSize / 2. + currentSize * vTex // adjust size
- + vVec.xy * t * vData.y // apply speed vector..
- + 0.5 * vVec.zw * pow(t * vData.y, 2.);
+ highp vec2 pos = qt_ParticlePos
+ - currentSize / 2. + currentSize * qt_ParticleTex // adjust size
+ + qt_ParticleVec.xy * t * qt_ParticleData.y // apply speed vector..
+ + 0.5 * qt_ParticleVec.zw * pow(t * qt_ParticleData.y, 2.);
gl_Position = qt_Matrix * vec4(pos.x, pos.y, 0, 1);
}
\endcode
@@ -340,7 +340,11 @@ void QSGCustomParticle::updateProperties()
vertexCode = qt_particles_template_vertex_code + vertexCode;
m_source.attributeNames.clear();
- m_source.attributeNames << "vPos" << "vTex" << "vData" << "vVec" << "r";
+ m_source.attributeNames << "qt_ParticlePos"
+ << "qt_ParticleTex"
+ << "qt_ParticleData"
+ << "qt_ParticleVec"
+ << "qt_ParticleR";
lookThroughShaderCode(vertexCode);
lookThroughShaderCode(fragmentCode);
@@ -384,8 +388,8 @@ void QSGCustomParticle::lookThroughShaderCode(const QByteArray &code)
m_source.respectsMatrix = true;
} else if (name == "qt_Opacity") {
m_source.respectsOpacity = true;
- } else if (name == "timestamp") {
- //TODO: Copy the whole thing just because I have one more uniform?
+ } else if (name == "qt_Timestamp") {
+ //Not strictly necessary
} else {
m_source.uniformNames.insert(name);
if (type == "sampler2D") {
@@ -513,12 +517,12 @@ QSGShaderEffectNode* QSGCustomParticle::buildCustomNodes()
return *(m_nodes.begin());
}
-static const QByteArray timestampName("timestamp");
void QSGCustomParticle::buildData()
{
if (!m_rootNode)
return;
+ const QByteArray timestampName("qt_Timestamp");
QVector<QPair<QByteArray, QVariant> > values;
QVector<QPair<QByteArray, QPointer<QSGItem> > > textures;
const QVector<QPair<QByteArray, QPointer<QSGItem> > > &oldTextures = m_material.textureProviders();
diff --git a/src/declarative/particles/qsgstochasticdirection.cpp b/src/declarative/particles/qsgdirection.cpp
index cdbc9f15ad..f233a56f61 100644
--- a/src/declarative/particles/qsgstochasticdirection.cpp
+++ b/src/declarative/particles/qsgdirection.cpp
@@ -39,23 +39,23 @@
**
****************************************************************************/
-#include "qsgstochasticdirection_p.h"
+#include "qsgdirection_p.h"
QT_BEGIN_NAMESPACE
/*!
- \qmlclass StochasticDirection QSGStochasticDirection
+ \qmlclass Direction QSGDirection
\inqmlmodule QtQuick.Particles 2
- \brief The StochasticDirection elements allow you to specify a vector space.
+ \brief The Direction elements allow you to specify a vector space.
*/
-QSGStochasticDirection::QSGStochasticDirection(QObject *parent) :
+QSGDirection::QSGDirection(QObject *parent) :
QObject(parent)
{
}
-const QPointF &QSGStochasticDirection::sample(const QPointF &from)
+const QPointF &QSGDirection::sample(const QPointF &from)
{
return m_ret;
}
diff --git a/src/declarative/particles/qsgstochasticdirection_p.h b/src/declarative/particles/qsgdirection_p.h
index 764937fc00..f64d5644e7 100644
--- a/src/declarative/particles/qsgstochasticdirection_p.h
+++ b/src/declarative/particles/qsgdirection_p.h
@@ -52,11 +52,11 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
-class QSGStochasticDirection : public QObject
+class QSGDirection : public QObject
{
Q_OBJECT
public:
- explicit QSGStochasticDirection(QObject *parent = 0);
+ explicit QSGDirection(QObject *parent = 0);
virtual const QPointF &sample(const QPointF &from);
signals:
diff --git a/src/declarative/particles/qsgimageparticle.cpp b/src/declarative/particles/qsgimageparticle.cpp
index b31d763f82..007cfb98db 100644
--- a/src/declarative/particles/qsgimageparticle.cpp
+++ b/src/declarative/particles/qsgimageparticle.cpp
@@ -608,7 +608,7 @@ void fillUniformArrayFromImage(float* array, const QImage& img, int size)
Acceptable values are
\list
\o None: Particles just appear and disappear.
- \o Fade: Particles fade in from 0. opacity at the start of their life, and fade out to 0. at the end.
+ \o Fade: Particles fade in from 0 opacity at the start of their life, and fade out to 0 at the end.
\o Scale: Particles scale in from 0 size at the start of their life, and scale back to 0 at the end.
\endlist
@@ -812,7 +812,7 @@ void QSGImageParticle::setAutoRotation(bool arg)
reset();
}
-void QSGImageParticle::setXVector(QSGStochasticDirection* arg)
+void QSGImageParticle::setXVector(QSGDirection* arg)
{
if (m_xVector != arg) {
m_xVector = arg;
@@ -822,7 +822,7 @@ void QSGImageParticle::setXVector(QSGStochasticDirection* arg)
reset();
}
-void QSGImageParticle::setYVector(QSGStochasticDirection* arg)
+void QSGImageParticle::setYVector(QSGDirection* arg)
{
if (m_yVector != arg) {
m_yVector = arg;
diff --git a/src/declarative/particles/qsgimageparticle_p.h b/src/declarative/particles/qsgimageparticle_p.h
index eb890e285c..01eacbad99 100644
--- a/src/declarative/particles/qsgimageparticle_p.h
+++ b/src/declarative/particles/qsgimageparticle_p.h
@@ -42,7 +42,7 @@
#ifndef ULTRAPARTICLE_H
#define ULTRAPARTICLE_H
#include "qsgparticlepainter_p.h"
-#include "qsgstochasticdirection_p.h"
+#include "qsgdirection_p.h"
#include <QDeclarativeListProperty>
#include <qsgsimplematerial.h>
@@ -172,9 +172,9 @@ class QSGImageParticle : public QSGParticlePainter
//###Call i/j? Makes more sense to those with vector calculus experience, and I could even add the cirumflex in QML?
//xVector is the vector from the top-left point to the top-right point, and is multiplied by current size
- Q_PROPERTY(QSGStochasticDirection* xVector READ xVector WRITE setXVector NOTIFY xVectorChanged)
+ Q_PROPERTY(QSGDirection* xVector READ xVector WRITE setXVector NOTIFY xVectorChanged)
//yVector is the same, but top-left to bottom-left. The particle is always a parallelogram.
- Q_PROPERTY(QSGStochasticDirection* yVector READ yVector WRITE setYVector NOTIFY yVectorChanged)
+ Q_PROPERTY(QSGDirection* yVector READ yVector WRITE setYVector NOTIFY yVectorChanged)
Q_PROPERTY(QDeclarativeListProperty<QSGSprite> sprites READ sprites)
Q_PROPERTY(EntryEffect entryEffect READ entryEffect WRITE setEntryEffect NOTIFY entryEffectChanged)
@@ -243,9 +243,9 @@ public:
bool autoRotation() const { return m_autoRotation; }
- QSGStochasticDirection* xVector() const { return m_xVector; }
+ QSGDirection* xVector() const { return m_xVector; }
- QSGStochasticDirection* yVector() const { return m_yVector; }
+ QSGDirection* yVector() const { return m_yVector; }
bool bloat() const { return m_bloat; }
@@ -282,9 +282,9 @@ signals:
void autoRotationChanged(bool arg);
- void xVectorChanged(QSGStochasticDirection* arg);
+ void xVectorChanged(QSGDirection* arg);
- void yVectorChanged(QSGStochasticDirection* arg);
+ void yVectorChanged(QSGDirection* arg);
void bloatChanged(bool arg);
@@ -312,9 +312,9 @@ public slots:
void setAutoRotation(bool arg);
- void setXVector(QSGStochasticDirection* arg);
+ void setXVector(QSGDirection* arg);
- void setYVector(QSGStochasticDirection* arg);
+ void setYVector(QSGDirection* arg);
void setBloat(bool arg);
@@ -364,8 +364,8 @@ private:
qreal m_rotationSpeed;
qreal m_rotationSpeedVariation;
bool m_autoRotation;
- QSGStochasticDirection* m_xVector;
- QSGStochasticDirection* m_yVector;
+ QSGDirection* m_xVector;
+ QSGDirection* m_yVector;
QList<QSGSprite*> m_sprites;
QSGSpriteEngine* m_spriteEngine;
diff --git a/src/declarative/particles/qsgmodelparticle.cpp b/src/declarative/particles/qsgmodelparticle.cpp
deleted file mode 100644
index c013d726a3..0000000000
--- a/src/declarative/particles/qsgmodelparticle.cpp
+++ /dev/null
@@ -1,335 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Declarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qsgmodelparticle_p.h"
-#include <QtDeclarative/private/qsgvisualitemmodel_p.h>
-#include <qsgnode.h>
-#include <QTimer>
-#include <QDebug>
-
-QT_BEGIN_NAMESPACE
-/*!
- \qmlclass ModelParticle QSGModelParticle
- \inqmlmodule QtQuick.Particles 2
- \inherits ParticlePainter
- \brief The ModelParticle element allows you to specify a model and delegate pair to paint particles.
-
-*/
-
-
-/*!
- \qmlmethod void QtQuick.Particles2::ModelParticle::freeze(Item item)
-
- Suspends the flow of time for the logical particle which item represents, allowing you to control its movement.
-*/
-
-/*!
- \qmlmethod void QtQuick.Particles2::ModelParticle::unfreeze(Item item)
-
- Restarts the flow of time for the logical particle which item represents, allowing it to be moved by the particle system again.
-*/
-
-/*!
- \qmlproperty bool QtQuick.Particles2::ModelParticle::fade
-
- If true, the item will automatically be faded in and out
- at the ends of its lifetime. If false, you will have to
- implement any entry effect yourself.
-
- Default is true.
-*/
-
-/*!
- \qmlproperty model QtQuick.Particles2::ModelParticle::model
-
- The model to use as a data source. Every time a particle is
- emitted, the next model entry will be used with a delegate
- to visualize it.
-*/
-
-/*!
- \qmlproperty Component QtQuick.Particles2::ModelParticle::delegate
-
- An instance of the delegate will be created for every model
- entry, and moved along with it.
-*/
-
-QSGModelParticle::QSGModelParticle(QSGItem *parent) :
- QSGParticlePainter(parent), m_ownModel(false), m_comp(0), m_model(0), m_fade(true), m_modelCount(0)
-{
- setFlag(QSGItem::ItemHasContents);
- QTimer* manageDelegates = new QTimer(this);//TODO: don't leak
- connect(manageDelegates, SIGNAL(timeout()),
- this, SLOT(processPending()));
- manageDelegates->setInterval(16);
- manageDelegates->setSingleShot(false);
- manageDelegates->start();
-}
-
-QSGModelParticle::~QSGModelParticle()
-{
- if (m_ownModel)
- delete m_model;
-}
-
-QVariant QSGModelParticle::model() const
-{
- return m_dataSource;
-}
-
-void QSGModelParticle::setModel(const QVariant &arg)
-{
- if (arg == m_dataSource)
- return;
- m_dataSource = arg;
- if (qobject_cast<QSGVisualDataModel*>(arg.value<QObject*>())) {
- if (m_ownModel && m_model)
- delete m_model;
- m_model = qobject_cast<QSGVisualDataModel*>(arg.value<QObject*>());
- m_ownModel = false;
- }else{
- if (!m_model || !m_ownModel)
- m_model = new QSGVisualDataModel(qmlContext(this));
- m_model->setModel(m_dataSource);
- m_ownModel = true;
- }
- if (m_comp)
- m_model->setDelegate(m_comp);
- emit modelChanged();
- emit modelCountChanged();
- connect(m_model, SIGNAL(countChanged()),
- this, SIGNAL(modelCountChanged()));
- connect(m_model, SIGNAL(countChanged()),
- this, SLOT(updateCount()));
- updateCount();
-}
-
-void QSGModelParticle::updateCount()
-{
- int newCount = 0;
- if (m_model)
- newCount = m_model->count();
- if (newCount < 0)
- return;//WTF?
- if (m_modelCount == 0 || newCount == 0){
- m_available.clear();
- for (int i=0; i<newCount; i++)
- m_available << i;
- }else if (newCount < m_modelCount){
- for (int i=newCount; i<m_modelCount; i++) //existing ones must leave normally, but aren't readded
- m_available.removeAll(i);
- }else if (newCount > m_modelCount){
- for (int i=m_modelCount; i<newCount; i++)
- m_available << i;
- }
- m_modelCount = newCount;
-}
-
-QDeclarativeComponent *QSGModelParticle::delegate() const
-{
- if (m_model)
- return m_model->delegate();
- return 0;
-}
-
-void QSGModelParticle::setDelegate(QDeclarativeComponent *comp)
-{
- if (QSGVisualDataModel *dataModel = qobject_cast<QSGVisualDataModel*>(m_model))
- if (comp == dataModel->delegate())
- return;
- m_comp = comp;
- if (m_model)
- m_model->setDelegate(comp);
- emit delegateChanged();
-}
-
-int QSGModelParticle::modelCount() const
-{
- if (m_model)
- const_cast<QSGModelParticle*>(this)->updateCount();//TODO: Investigate why this doesn't get called properly
- return m_modelCount;
-}
-
-
-void QSGModelParticle::freeze(QSGItem* item)
-{
- m_stasis << item;
-}
-
-
-void QSGModelParticle::unfreeze(QSGItem* item)
-{
- m_stasis.remove(item);
-}
-
-void QSGModelParticle::initialize(int gIdx, int pIdx)
-{
- if (!m_model || !m_model->count())
- return;
- if (m_available.isEmpty())
- return;
- m_requests << m_system->m_groupData[gIdx]->data[pIdx];
-}
-
-void QSGModelParticle::processPending()
-{//can't create/delete arbitrary items in the render thread
- foreach (QSGItem* item, m_deletables){
- item->setVisible(false);
- if (m_fade)
- item->setOpacity(0.);
- m_model->release(item);
- m_activeCount--;
- }
- m_deletables.clear();
-
- foreach (QSGParticleData* datum, m_requests){
- if (datum->delegate){
- if (m_stasis.contains(datum->delegate))
- qWarning() << "Current model particles prefers overwrite:false";
- //remove old item from the particle that is dying to make room for this one
- m_deletables << datum->delegate;
- m_available << datum->modelIndex;
- datum->modelIndex = -1;
- datum->delegate = 0;
- }
-
- if (!m_available.isEmpty()){
- datum->delegate = m_model->item(m_available.first());
- datum->modelIndex = m_available.first();
- m_available.pop_front();
- QSGModelParticleAttached* mpa = qobject_cast<QSGModelParticleAttached*>(qmlAttachedPropertiesObject<QSGModelParticle>(datum->delegate));
- if (mpa){
- mpa->m_mp = this;
- mpa->attach();
- }
- datum->delegate->setParentItem(this);
- if (m_fade)
- datum->delegate->setOpacity(0.0);
- datum->delegate->setVisible(false);//Will be set to true when we prepare the next frame
- m_activeCount++;
- }
- }
- m_requests.clear();
-}
-
-void QSGModelParticle::commit(int gIdx, int pIdx)
-{
- //No-op unless we start copying the data.
-}
-
-void QSGModelParticle::reset()
-{
- QSGParticlePainter::reset();
- //TODO: Cleanup items?
- //m_available.clear();//Should this be reset too?
- //m_pendingItems.clear();//TODO: Should this be done? If so, Emit signal?
-}
-
-
-QSGNode* QSGModelParticle::updatePaintNode(QSGNode* n, UpdatePaintNodeData* d)
-{
- //Dummy update just to get painting tick
- if (m_pleaseReset){
- m_pleaseReset = false;
- reset();
- }
- prepareNextFrame();
-
- update();//Get called again
- if (n)
- n->markDirty(QSGNode::DirtyMaterial);
- return QSGItem::updatePaintNode(n,d);
-}
-
-void QSGModelParticle::prepareNextFrame()
-{
- if (!m_system)
- return;
- qint64 timeStamp = m_system->systemSync(this);
- qreal curT = timeStamp/1000.0;
- qreal dt = curT - m_lastT;
- m_lastT = curT;
- if (!m_activeCount)
- return;
-
- //TODO: Size, better fade?
- foreach (const QString &str, m_particles){
- int gIdx = m_system->m_groupIds[str];
- int count = m_system->m_groupData[gIdx]->size();
-
- for (int i=0; i<count; i++){
- QSGParticleData* data = m_system->m_groupData[gIdx]->data[i];
- if (!data || !data->delegate)
- continue;
- qreal t = ((timeStamp/1000.0) - data->t) / data->lifeSpan;
- if (m_stasis.contains(data->delegate)) {
- data->t += dt;//Stasis effect
- continue;
- }
- if (t >= 1.0){//Usually happens from load
- m_available << data->modelIndex;
- m_deletables << data->delegate;
- data->modelIndex = -1;
- data->delegate = 0;
- continue;
- }else{//Fade
- data->delegate->setVisible(true);
- if (m_fade){
- qreal o = 1.;
- if (t<0.2)
- o = t*5;
- if (t>0.8)
- o = (1-t)*5;
- data->delegate->setOpacity(o);
- }
- }
- data->delegate->setX(data->curX() - data->delegate->width()/2 - m_systemOffset.x());
- data->delegate->setY(data->curY() - data->delegate->height()/2 - m_systemOffset.y());
- }
- }
-}
-
-QSGModelParticleAttached *QSGModelParticle::qmlAttachedProperties(QObject *object)
-{
- return new QSGModelParticleAttached(object);
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/particles/qsgmodelparticle_p.h b/src/declarative/particles/qsgmodelparticle_p.h
deleted file mode 100644
index c6dd40d51e..0000000000
--- a/src/declarative/particles/qsgmodelparticle_p.h
+++ /dev/null
@@ -1,140 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Declarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef DATAPARTICLE_H
-#define DATAPARTICLE_H
-#include "qsgparticlepainter_p.h"
-#include <QPointer>
-#include <QSet>
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-class QSGVisualDataModel;
-class QSGModelParticleAttached;
-
-class QSGModelParticle : public QSGParticlePainter
-{
- Q_OBJECT
-
- Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged)
- Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
- Q_PROPERTY(int modelCount READ modelCount NOTIFY modelCountChanged)
- Q_PROPERTY(bool fade READ fade WRITE setFade NOTIFY fadeChanged)
- Q_CLASSINFO("DefaultProperty", "delegate")
-public:
- explicit QSGModelParticle(QSGItem *parent = 0);
- virtual ~QSGModelParticle();
- QVariant model() const;
- void setModel(const QVariant &);
-
- QDeclarativeComponent *delegate() const;
- void setDelegate(QDeclarativeComponent *);
-
- int modelCount() const;
-
- bool fade() const { return m_fade; }
-
- virtual QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *);
-
- static QSGModelParticleAttached *qmlAttachedProperties(QObject *object);
-signals:
- void modelChanged();
- void delegateChanged();
- void modelCountChanged();
- void fadeChanged();
-
-public slots:
- void freeze(QSGItem* item);
- void unfreeze(QSGItem* item);
-
- void setFade(bool arg){if (arg == m_fade) return; m_fade = arg; emit fadeChanged();}
-protected:
- virtual void reset();
- virtual void commit(int gIdx, int pIdx);
- virtual void initialize(int gIdx, int pIdx);
- void prepareNextFrame();
-private slots:
- void updateCount();
- void processPending();
-private:
- bool m_ownModel;
- QDeclarativeComponent* m_comp;
- QSGVisualDataModel *m_model;
- QVariant m_dataSource;
- QList<QSGItem*> m_deletables;
- QList< QSGParticleData* > m_requests;
- bool m_fade;
-
- QList<QSGItem*> m_pendingItems;
- QList<int> m_available;
- QSet<QSGItem*> m_stasis;
- qreal m_lastT;
- int m_activeCount;
- int m_modelCount;
-};
-
-class QSGModelParticleAttached : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QSGModelParticle* particle READ particle CONSTANT)
-public:
- QSGModelParticleAttached(QObject* parent)
- : QObject(parent), m_mp(0)
- {;}
- QSGModelParticle* particle() {return m_mp;}
- void detach(){emit detached();}
- void attach(){emit attached();}
-private:
- QSGModelParticle* m_mp;
- friend class QSGModelParticle;
-Q_SIGNALS:
- void detached();
- void attached();
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPEINFO(QSGModelParticle, QML_HAS_ATTACHED_PROPERTIES)
-
-QT_END_HEADER
-#endif // DATAPARTICLE_H
diff --git a/src/declarative/particles/qsgparticleaffector.cpp b/src/declarative/particles/qsgparticleaffector.cpp
index 4a3bba6e6d..3554121a2b 100644
--- a/src/declarative/particles/qsgparticleaffector.cpp
+++ b/src/declarative/particles/qsgparticleaffector.cpp
@@ -73,16 +73,16 @@ QT_BEGIN_NAMESPACE
By default, no groups are specified.
*/
/*!
- \qmlproperty bool QtQuick.Particles2::Affector::active
- If active is set to false, this affector will not affect any particles.
+ \qmlproperty bool QtQuick.Particles2::Affector::enabled
+ If enabled is set to false, this affector will not affect any particles.
Usually this is used to conditionally turn an affector on or off.
Default value is true.
*/
/*!
- \qmlproperty bool QtQuick.Particles2::Affector::onceOff
- If onceOff is set to true, this affector will only affect each particle
+ \qmlproperty bool QtQuick.Particles2::Affector::once
+ If once is set to true, this affector will only affect each particle
once in their lifetimes.
Default value is false.
@@ -93,27 +93,24 @@ QT_BEGIN_NAMESPACE
non-rectangular area.
*/
/*!
- \qmlproperty bool QtQuick.Particles2::Affector::signal
- If this is set to true, then an affected(x,y) signal will be emitted each
- time this affector would affect a particle.
+ \qmlsignal QtQuick.Particles2::Affector::onAffected(x, y)
- For Affector only, this will happen irrespective of whether any changes
- are made to the particle, for other Affectors the signal will only fire
- if the particle is actually affected.
+ This signal is emitted each time the affector actually affects a particle.
- Default value is false.
-*/
+ x,y are the coordinates of the affected particle, relative to the ParticleSystem.
+*/
//TODO: Document particle 'type'
/*!
\qmlsignal QtQuick.Particles2::Affector::affectParticle(particle, dt)
- This handler is called when a particle is selected to be affected.
+ This handler is called when particles are selected to be affected.
dt is the time since the last time it was affected. Use dt to normalize
trajectory manipulations to real time.
- This handler is usually not available on inherited types.
+ Note that JS is slower to execute, so it is not recommended to use this in
+ high-volume particle systems.
*/
/*!
\qmlsignal QtQuick.Particles2::Affector::affected(x, y)
@@ -124,32 +121,32 @@ QT_BEGIN_NAMESPACE
x,y is the particles current position.
*/
QSGParticleAffector::QSGParticleAffector(QSGItem *parent) :
- QSGItem(parent), m_needsReset(false), m_system(0), m_active(true)
- , m_updateIntSet(false), m_shape(new QSGParticleExtruder(this)), m_signal(false)
+ QSGItem(parent), m_needsReset(false), m_system(0), m_enabled(true)
+ , m_updateIntSet(false), m_shape(new QSGParticleExtruder(this))
{
}
-bool QSGParticleAffector::isAffectConnected()
+bool QSGParticleAffector::isAffectedConnected()
{
- static int idx = QObjectPrivate::get(this)->signalIndex("affectParticle(QDeclarativeV8Handle,qreal)");
+ static int idx = QObjectPrivate::get(this)->signalIndex("affected(qreal,qreal)");
return QObjectPrivate::get(this)->isSignalConnected(idx);
}
+
void QSGParticleAffector::componentComplete()
{
if (!m_system && qobject_cast<QSGParticleSystem*>(parentItem()))
setSystem(qobject_cast<QSGParticleSystem*>(parentItem()));
- if (!m_system)
- qWarning() << "Affector created without a particle system specified";//TODO: useful QML warnings, like line number?
QSGItem::componentComplete();
}
void QSGParticleAffector::affectSystem(qreal dt)
{
- if (!m_active)
+ if (!m_enabled)
return;
//If not reimplemented, calls affect particle per particle
//But only on particles in targeted system/area
+ bool affectedConnected = isAffectedConnected();
if (m_updateIntSet){
m_groups.clear();
foreach (const QString &p, m_particles)
@@ -167,16 +164,16 @@ void QSGParticleAffector::affectSystem(qreal dt)
continue;
//Need to have previous location for affected anyways
QPointF curPos;
- if (m_signal || (width() && height()))
+ if (affectedConnected || (width() && height()))
curPos = QPointF(d->curX(), d->curY());
if (width() == 0 || height() == 0
|| m_shape->contains(QRectF(m_offset.x(), m_offset.y(), width(), height()),curPos)){
- if (m_collisionParticles.isEmpty() || isColliding(d)){
+ if (m_whenCollidingWith.isEmpty() || isColliding(d)){
if (affectParticle(d, dt)){
m_system->m_needsReset << d;
if (m_onceOff)
m_onceOffed << qMakePair(d->group, d->index);
- if (m_signal)//###Make signal based on if connected, and then m_signal just affects AffectParticle for base?
+ if (affectedConnected)
emit affected(curPos.x(), curPos.y());
}
}
@@ -188,12 +185,7 @@ void QSGParticleAffector::affectSystem(qreal dt)
bool QSGParticleAffector::affectParticle(QSGParticleData *d, qreal dt)
{
- if (isAffectConnected()){
- d->update = 0.0;
- emit affectParticle(d->v8Value(), dt);
- return d->update == 1.0;
- }
- return m_signal;//If signalling, then we always 'null affect' it.
+ return true;
}
void QSGParticleAffector::reset(QSGParticleData* pd)
@@ -214,7 +206,7 @@ bool QSGParticleAffector::isColliding(QSGParticleData *d)
qreal myCurX = d->curX();
qreal myCurY = d->curY();
qreal myCurSize = d->curSize()/2;
- foreach (const QString &group, m_collisionParticles){
+ foreach (const QString &group, m_whenCollidingWith){
foreach (QSGParticleData* other, m_system->m_groupData[m_system->m_groupIds[group]]->data){
if (!other->stillAlive())
continue;
diff --git a/src/declarative/particles/qsgparticleaffector_p.h b/src/declarative/particles/qsgparticleaffector_p.h
index dd279c07b9..c808ef4e76 100644
--- a/src/declarative/particles/qsgparticleaffector_p.h
+++ b/src/declarative/particles/qsgparticleaffector_p.h
@@ -57,11 +57,10 @@ class QSGParticleAffector : public QSGItem
Q_OBJECT
Q_PROPERTY(QSGParticleSystem* system READ system WRITE setSystem NOTIFY systemChanged)
Q_PROPERTY(QStringList particles READ particles WRITE setParticles NOTIFY particlesChanged)
- Q_PROPERTY(QStringList collisionParticles READ collisionParticles WRITE setCollisionParticles NOTIFY collisionParticlesChanged)
- Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged)
- Q_PROPERTY(bool onceOff READ onceOff WRITE setOnceOff NOTIFY onceOffChanged)
+ Q_PROPERTY(QStringList whenCollidingWith READ whenCollidingWith WRITE setWhenCollidingWith NOTIFY whenCollidingWithChanged)
+ Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
+ Q_PROPERTY(bool once READ onceOff WRITE setOnceOff NOTIFY onceChanged)
Q_PROPERTY(QSGParticleExtruder* shape READ shape WRITE setShape NOTIFY shapeChanged)
- Q_PROPERTY(bool signal READ signal WRITE setSignal NOTIFY signalChanged)//TODO: Determine by whether it's connected
public:
explicit QSGParticleAffector(QSGItem *parent = 0);
@@ -77,9 +76,9 @@ public:
return m_particles;
}
- bool active() const
+ bool enabled() const
{
- return m_active;
+ return m_enabled;
}
bool onceOff() const
@@ -92,33 +91,26 @@ public:
return m_shape;
}
- bool signal() const
+ QStringList whenCollidingWith() const
{
- return m_signal;
- }
-
- QStringList collisionParticles() const
- {
- return m_collisionParticles;
+ return m_whenCollidingWith;
}
signals:
- void affectParticle(QDeclarativeV8Handle particle, qreal dt);
void systemChanged(QSGParticleSystem* arg);
void particlesChanged(QStringList arg);
- void activeChanged(bool arg);
+ void enabledChanged(bool arg);
- void onceOffChanged(bool arg);
+ void onceChanged(bool arg);
void shapeChanged(QSGParticleExtruder* arg);
void affected(qreal x, qreal y);
- void signalChanged(bool arg);
- void collisionParticlesChanged(QStringList arg);
+ void whenCollidingWithChanged(QStringList arg);
public slots:
void setSystem(QSGParticleSystem* arg)
@@ -139,11 +131,11 @@ void setParticles(QStringList arg)
}
}
-void setActive(bool arg)
+void setEnabled(bool arg)
{
- if (m_active != arg) {
- m_active = arg;
- emit activeChanged(arg);
+ if (m_enabled != arg) {
+ m_enabled = arg;
+ emit enabledChanged(arg);
}
}
@@ -152,7 +144,7 @@ void setOnceOff(bool arg)
if (m_onceOff != arg) {
m_onceOff = arg;
m_needsReset = true;
- emit onceOffChanged(arg);
+ emit onceChanged(arg);
}
}
@@ -164,19 +156,11 @@ void setShape(QSGParticleExtruder* arg)
}
}
-void setSignal(bool arg)
-{
- if (m_signal != arg) {
- m_signal = arg;
- emit signalChanged(arg);
- }
-}
-
-void setCollisionParticles(QStringList arg)
+void setWhenCollidingWith(QStringList arg)
{
- if (m_collisionParticles != arg) {
- m_collisionParticles = arg;
- emit collisionParticlesChanged(arg);
+ if (m_whenCollidingWith != arg) {
+ m_whenCollidingWith = arg;
+ emit whenCollidingWithChanged(arg);
}
}
@@ -187,10 +171,10 @@ protected:
QSGParticleSystem* m_system;
QStringList m_particles;
bool activeGroup(int g) {return m_groups.isEmpty() || m_groups.contains(g);}
- bool m_active;
+ bool m_enabled;
virtual void componentComplete();
QPointF m_offset;
- bool isAffectConnected();
+ bool isAffectedConnected();
private:
QSet<int> m_groups;
QSet<QPair<int, int> > m_onceOffed;
@@ -200,9 +184,7 @@ private:
QSGParticleExtruder* m_shape;
- bool m_signal;
-
- QStringList m_collisionParticles;
+ QStringList m_whenCollidingWith;
bool isColliding(QSGParticleData* d);
private slots:
diff --git a/src/declarative/particles/qsgparticleemitter.cpp b/src/declarative/particles/qsgparticleemitter.cpp
index 6519bf5f9e..d44ad689ee 100644
--- a/src/declarative/particles/qsgparticleemitter.cpp
+++ b/src/declarative/particles/qsgparticleemitter.cpp
@@ -117,21 +117,17 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \qmlproperty int QtQuick.Particles2::Emitter::emitCap
+ \qmlproperty int QtQuick.Particles2::Emitter::maximumEmitted
The maximum number of particles at a time that this emitter will have alive.
This can be set as a performance optimization (when using burst and pulse) or
- to stagger emissions. The default value is emitRate * lifeSpan in seconds, which
- is the number of particles that would be alive at any one time given the default settings.
-*/
-/*!
- \qmlproperty bool QtQuick.Particles2::Emitter::noCap
+ to stagger emissions.
- If set to true, the emitCap will be ignored and this emitter will never skip emitting
- a particle based on how many it has alive.
+ If this is set to a number below zero, then there is no maximum limit on the number
+ of particles this emitter can have alive.
- Default value is false.
+ The default value is -1.
*/
/*!
\qmlproperty int QtQuick.Particles2::Emitter::startTime
@@ -187,19 +183,38 @@ QT_BEGIN_NAMESPACE
*/
//TODO: Document particle 'type'
/*!
- \qmlsignal QtQuick.Particles2::Emitter::emitParticle(particle)
+ \qmlsignal QtQuick.Particles2::Emitter::onEmitParticle(Particle particle)
This handler is called when a particle is emitted. You can modify particle
attributes from within the handler.
+
+ Note that JS is slower to execute, so it is not recommended to use this in
+ high-volume particle systems.
+*/
+
+/*! \qmlmethod QtQuick.Particles2::Emitter::burst(int count)
+
+ Emits count particles from this emitter immediately.
*/
+/*! \qmlmethod QtQuick.Particles2::Emitter::burst(int x, int y, int count)
+
+ Emits count particles from this emitter immediately. The particles are emitted
+ as if the Emitter was positioned at x,y but all other properties are the same.
+*/
+
+/*! \qmlmethod QtQuick.Particles2::Emitter::pulse(real duration)
+
+ If the emitter is not enabled, enables it for duration seconds and then switches
+ it back off.
+*/
QSGParticleEmitter::QSGParticleEmitter(QSGItem *parent) :
QSGItem(parent)
, m_particlesPerSecond(10)
, m_particleDuration(1000)
, m_particleDurationVariation(0)
- , m_emitting(true)
+ , m_enabled(true)
, m_system(0)
, m_extruder(0)
, m_defaultExtruder(0)
@@ -215,11 +230,11 @@ QSGParticleEmitter::QSGParticleEmitter(QSGItem *parent) :
, m_last_timestamp(-1)
, m_last_emission(0)
, m_startTime(0)
- , m_overwrite(false)
+ , m_overwrite(true)
{
//TODO: Reset speed/acc back to null vector? Or allow null pointer?
- connect(this, SIGNAL(maxParticleCountChanged(int)),
+ connect(this, SIGNAL(maximumEmittedChanged(int)),
this, SIGNAL(particleCountChanged()));
connect(this, SIGNAL(particlesPerSecondChanged(qreal)),
this, SIGNAL(particleCountChanged()));
@@ -243,16 +258,14 @@ void QSGParticleEmitter::componentComplete()
{
if (!m_system && qobject_cast<QSGParticleSystem*>(parentItem()))
setSystem(qobject_cast<QSGParticleSystem*>(parentItem()));
- if (!m_system)
- qWarning() << "Emitter created without a particle system specified";//TODO: useful QML warnings, like line number?
QSGItem::componentComplete();
}
-void QSGParticleEmitter::setEmitting(bool arg)
+void QSGParticleEmitter::setEnabled(bool arg)
{
- if (m_emitting != arg) {
- m_emitting = arg;
- emit emittingChanged(arg);
+ if (m_enabled != arg) {
+ m_enabled = arg;
+ emit enabledChanged(arg);
}
}
@@ -270,7 +283,7 @@ void QSGParticleEmitter::pulse(qreal seconds)
{
if (!particleCount())
qWarning() << "pulse called on an emitter with a particle count of zero";
- if (!m_emitting)
+ if (!m_enabled)
m_burstLeft = seconds*1000.0;//TODO: Change name to match
}
@@ -302,8 +315,9 @@ void QSGParticleEmitter::setMaxParticleCount(int arg)
disconnect(this, SIGNAL(particleDurationChanged(int)),
this, SIGNAL(particleCountChanged()));
}
+ m_overwrite = arg < 0;
m_maxParticleCount = arg;
- emit maxParticleCountChanged(arg);
+ emit maximumEmittedChanged(arg);
}
}
@@ -331,7 +345,7 @@ void QSGParticleEmitter::emitWindow(int timeStamp)
{
if (m_system == 0)
return;
- if ((!m_emitting || !m_particlesPerSecond)&& !m_burstLeft && m_burstQueue.isEmpty()){
+ if ((!m_enabled || !m_particlesPerSecond)&& !m_burstLeft && m_burstQueue.isEmpty()){
m_reset_last = true;
return;
}
@@ -339,7 +353,7 @@ void QSGParticleEmitter::emitWindow(int timeStamp)
if (m_reset_last) {
m_last_emitter = m_last_last_emitter = QPointF(x(), y());
if (m_last_timestamp == -1)
- m_last_timestamp = timeStamp/1000. - m_startTime;
+ m_last_timestamp = (timeStamp - m_startTime)/1000.;
else
m_last_timestamp = timeStamp/1000.;
m_last_emission = m_last_timestamp;
@@ -350,12 +364,11 @@ void QSGParticleEmitter::emitWindow(int timeStamp)
if (m_burstLeft){
m_burstLeft -= timeStamp - m_last_timestamp * 1000.;
if (m_burstLeft < 0){
- if (!m_emitting)
+ if (!m_enabled)
timeStamp += m_burstLeft;
m_burstLeft = 0;
}
}
-
qreal time = timeStamp / 1000.;
qreal particleRatio = 1. / m_particlesPerSecond;
qreal pt = m_last_emission;
@@ -379,7 +392,7 @@ void QSGParticleEmitter::emitWindow(int timeStamp)
qreal sizeAtEnd = m_particleEndSize >= 0 ? m_particleEndSize : m_particleSize;
qreal emitter_x_offset = m_last_emitter.x() - x();
qreal emitter_y_offset = m_last_emitter.y() - y();
- if (!m_burstQueue.isEmpty() && !m_burstLeft && !m_emitting)//'outside time' emissions only
+ if (!m_burstQueue.isEmpty() && !m_burstLeft && !m_enabled)//'outside time' emissions only
pt = time;
while ((pt < time && m_emitCap) || !m_burstQueue.isEmpty()) {
//int pos = m_last_particle % m_particle_count;
diff --git a/src/declarative/particles/qsgparticleemitter_p.h b/src/declarative/particles/qsgparticleemitter_p.h
index 9e1fc7a9d8..8ed7ee7053 100644
--- a/src/declarative/particles/qsgparticleemitter_p.h
+++ b/src/declarative/particles/qsgparticleemitter_p.h
@@ -46,7 +46,7 @@
#include <QDebug>
#include "qsgparticlesystem_p.h"
#include "qsgparticleextruder_p.h"
-#include "qsgstochasticdirection_p.h"
+#include "qsgdirection_p.h"
#include <QList>
#include <QPair>
@@ -63,21 +63,20 @@ class QSGParticleEmitter : public QSGItem
Q_PROPERTY(QSGParticleSystem* system READ system WRITE setSystem NOTIFY systemChanged)
Q_PROPERTY(QString particle READ particle WRITE setParticle NOTIFY particleChanged)
Q_PROPERTY(QSGParticleExtruder* shape READ extruder WRITE setExtruder NOTIFY extruderChanged)
- Q_PROPERTY(bool emitting READ emitting WRITE setEmitting NOTIFY emittingChanged)
+ Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
Q_PROPERTY(int startTime READ startTime WRITE setStartTime NOTIFY startTimeChanged)
- Q_PROPERTY(bool noCap READ overwrite WRITE setOverWrite NOTIFY overwriteChanged)
Q_PROPERTY(qreal emitRate READ particlesPerSecond WRITE setParticlesPerSecond NOTIFY particlesPerSecondChanged)
Q_PROPERTY(int lifeSpan READ particleDuration WRITE setParticleDuration NOTIFY particleDurationChanged)
Q_PROPERTY(int lifeSpanVariation READ particleDurationVariation WRITE setParticleDurationVariation NOTIFY particleDurationVariationChanged)
- Q_PROPERTY(int emitCap READ maxParticleCount WRITE setMaxParticleCount NOTIFY maxParticleCountChanged)
+ Q_PROPERTY(int maximumEmitted READ maxParticleCount WRITE setMaxParticleCount NOTIFY maximumEmittedChanged)
Q_PROPERTY(qreal size READ particleSize WRITE setParticleSize NOTIFY particleSizeChanged)
Q_PROPERTY(qreal endSize READ particleEndSize WRITE setParticleEndSize NOTIFY particleEndSizeChanged)
Q_PROPERTY(qreal sizeVariation READ particleSizeVariation WRITE setParticleSizeVariation NOTIFY particleSizeVariationChanged)
- Q_PROPERTY(QSGStochasticDirection *speed READ speed WRITE setSpeed NOTIFY speedChanged)
- Q_PROPERTY(QSGStochasticDirection *acceleration READ acceleration WRITE setAcceleration NOTIFY accelerationChanged)
+ Q_PROPERTY(QSGDirection *speed READ speed WRITE setSpeed NOTIFY speedChanged)
+ Q_PROPERTY(QSGDirection *acceleration READ acceleration WRITE setAcceleration NOTIFY accelerationChanged)
Q_PROPERTY(qreal speedFromMovement READ speedFromMovement WRITE setSpeedFromMovement NOTIFY speedFromMovementChanged)
Q_ENUMS(Lifetime)
@@ -90,9 +89,9 @@ public:
InfiniteLife = QSGParticleSystem::maxLife
};
- bool emitting() const
+ bool enabled() const
{
- return m_emitting;
+ return m_enabled;
}
qreal particlesPerSecond() const
@@ -127,7 +126,7 @@ signals:
void emitParticle(QDeclarativeV8Handle particle);
void particlesPerSecondChanged(qreal);
void particleDurationChanged(int);
- void emittingChanged(bool);
+ void enabledChanged(bool);
void systemChanged(QSGParticleSystem* arg);
@@ -143,25 +142,23 @@ signals:
void particleSizeVariationChanged(qreal arg);
- void speedChanged(QSGStochasticDirection * arg);
+ void speedChanged(QSGDirection * arg);
- void accelerationChanged(QSGStochasticDirection * arg);
+ void accelerationChanged(QSGDirection * arg);
- void maxParticleCountChanged(int arg);
+ void maximumEmittedChanged(int arg);
void particleCountChanged();
void speedFromMovementChanged();
void startTimeChanged(int arg);
- void overwriteChanged(bool arg);
-
public slots:
void pulse(qreal seconds);
void burst(int num);
void burst(int num, qreal x, qreal y);
- void setEmitting(bool arg);
+ void setEnabled(bool arg);
void setParticlesPerSecond(qreal arg)
{
@@ -179,95 +176,87 @@ public slots:
}
}
- void setSystem(QSGParticleSystem* arg)
+ void setSystem(QSGParticleSystem* arg)
{
if (m_system != arg) {
m_system = arg;
m_system->registerParticleEmitter(this);
emit systemChanged(arg);
}
- }
-
- void setParticle(QString arg)
- {
- if (m_particle != arg) {
- m_particle = arg;
- emit particleChanged(arg);
- }
- }
+ }
- void setParticleDurationVariation(int arg)
- {
- if (m_particleDurationVariation != arg) {
- m_particleDurationVariation = arg;
- emit particleDurationVariationChanged(arg);
- }
- }
- void setExtruder(QSGParticleExtruder* arg)
- {
- if (m_extruder != arg) {
- m_extruder = arg;
- emit extruderChanged(arg);
- }
- }
+ void setParticle(QString arg)
+ {
+ if (m_particle != arg) {
+ m_particle = arg;
+ emit particleChanged(arg);
+ }
+ }
- void setParticleSize(qreal arg)
- {
- if (m_particleSize != arg) {
- m_particleSize = arg;
- emit particleSizeChanged(arg);
- }
- }
+ void setParticleDurationVariation(int arg)
+ {
+ if (m_particleDurationVariation != arg) {
+ m_particleDurationVariation = arg;
+ emit particleDurationVariationChanged(arg);
+ }
+ }
+ void setExtruder(QSGParticleExtruder* arg)
+ {
+ if (m_extruder != arg) {
+ m_extruder = arg;
+ emit extruderChanged(arg);
+ }
+ }
- void setParticleEndSize(qreal arg)
- {
- if (m_particleEndSize != arg) {
- m_particleEndSize = arg;
- emit particleEndSizeChanged(arg);
- }
- }
+ void setParticleSize(qreal arg)
+ {
+ if (m_particleSize != arg) {
+ m_particleSize = arg;
+ emit particleSizeChanged(arg);
+ }
+ }
- void setParticleSizeVariation(qreal arg)
- {
- if (m_particleSizeVariation != arg) {
- m_particleSizeVariation = arg;
- emit particleSizeVariationChanged(arg);
- }
- }
+ void setParticleEndSize(qreal arg)
+ {
+ if (m_particleEndSize != arg) {
+ m_particleEndSize = arg;
+ emit particleEndSizeChanged(arg);
+ }
+ }
- void setSpeed(QSGStochasticDirection * arg)
- {
- if (m_speed != arg) {
- m_speed = arg;
- emit speedChanged(arg);
- }
- }
+ void setParticleSizeVariation(qreal arg)
+ {
+ if (m_particleSizeVariation != arg) {
+ m_particleSizeVariation = arg;
+ emit particleSizeVariationChanged(arg);
+ }
+ }
- void setAcceleration(QSGStochasticDirection * arg)
- {
- if (m_acceleration != arg) {
- m_acceleration = arg;
- emit accelerationChanged(arg);
- }
- }
+ void setSpeed(QSGDirection * arg)
+ {
+ if (m_speed != arg) {
+ m_speed = arg;
+ emit speedChanged(arg);
+ }
+ }
- void setMaxParticleCount(int arg);
+ void setAcceleration(QSGDirection * arg)
+ {
+ if (m_acceleration != arg) {
+ m_acceleration = arg;
+ emit accelerationChanged(arg);
+ }
+ }
- void setStartTime(int arg)
- {
- if (m_startTime != arg) {
- m_startTime = arg;
- emit startTimeChanged(arg);
- }
- }
+ void setMaxParticleCount(int arg);
- void setOverWrite(bool arg)
- {
- if (m_overwrite != arg) {
- m_overwrite = arg;
- emit overwriteChanged(arg);
- }
- }
+ void setStartTime(int arg)
+ {
+ if (m_startTime != arg) {
+ m_startTime = arg;
+ emit startTimeChanged(arg);
+ }
+ }
virtual void reset();
public:
@@ -293,12 +282,12 @@ public:
return m_particleSizeVariation;
}
- QSGStochasticDirection * speed() const
+ QSGDirection * speed() const
{
return m_speed;
}
- QSGStochasticDirection * acceleration() const
+ QSGDirection * acceleration() const
{
return m_acceleration;
}
@@ -313,23 +302,18 @@ public:
return m_startTime;
}
- bool overwrite() const
- {
- return m_overwrite;
- }
-
protected:
qreal m_particlesPerSecond;
int m_particleDuration;
int m_particleDurationVariation;
- bool m_emitting;
+ bool m_enabled;
QSGParticleSystem* m_system;
QString m_particle;
QSGParticleExtruder* m_extruder;
QSGParticleExtruder* m_defaultExtruder;
QSGParticleExtruder* effectiveExtruder();
- QSGStochasticDirection * m_speed;
- QSGStochasticDirection * m_acceleration;
+ QSGDirection * m_speed;
+ QSGDirection * m_acceleration;
qreal m_particleSize;
qreal m_particleEndSize;
qreal m_particleSizeVariation;
@@ -356,7 +340,7 @@ protected:
bool isEmitConnected();
private:
- QSGStochasticDirection m_nullVector;
+ QSGDirection m_nullVector;
};
diff --git a/src/declarative/particles/qsgparticleextruder.cpp b/src/declarative/particles/qsgparticleextruder.cpp
index a390bb92ac..73c8ce0a66 100644
--- a/src/declarative/particles/qsgparticleextruder.cpp
+++ b/src/declarative/particles/qsgparticleextruder.cpp
@@ -52,30 +52,14 @@ QT_BEGIN_NAMESPACE
*/
QSGParticleExtruder::QSGParticleExtruder(QObject *parent) :
- QObject(parent), m_fill(true)
+ QObject(parent)
{
}
QPointF QSGParticleExtruder::extrude(const QRectF &rect)
{
- if (m_fill)
- return QPointF(((qreal)rand() / RAND_MAX) * rect.width() + rect.x(),
- ((qreal)rand() / RAND_MAX) * rect.height() + rect.y());
- int side = rand() % 4;
- switch (side){//TODO: Doesn't this overlap the corners?
- case 0:
- return QPointF(rect.x(),
- ((qreal)rand() / RAND_MAX) * rect.height() + rect.y());
- case 1:
- return QPointF(rect.width() + rect.x(),
- ((qreal)rand() / RAND_MAX) * rect.height() + rect.y());
- case 2:
- return QPointF(((qreal)rand() / RAND_MAX) * rect.width() + rect.x(),
- rect.y());
- default:
- return QPointF(((qreal)rand() / RAND_MAX) * rect.width() + rect.x(),
- rect.height() + rect.y());
- }
+ return QPointF(((qreal)rand() / RAND_MAX) * rect.width() + rect.x(),
+ ((qreal)rand() / RAND_MAX) * rect.height() + rect.y());
}
bool QSGParticleExtruder::contains(const QRectF &bounds, const QPointF &point)
diff --git a/src/declarative/particles/qsgparticleextruder_p.h b/src/declarative/particles/qsgparticleextruder_p.h
index bb2cc24ac2..b31b80231d 100644
--- a/src/declarative/particles/qsgparticleextruder_p.h
+++ b/src/declarative/particles/qsgparticleextruder_p.h
@@ -55,32 +55,15 @@ QT_MODULE(Declarative)
class QSGParticleExtruder : public QObject
{
Q_OBJECT
- Q_PROPERTY(bool fill READ fill WRITE setFill NOTIFY fillChanged)//###Should this be base class, or a BoxExtruder?
public:
explicit QSGParticleExtruder(QObject *parent = 0);
virtual QPointF extrude(const QRectF &);
- virtual bool contains(const QRectF &bounds, const QPointF &point);//###Needed for follow emitter, but does it belong? Only marginally conceptually valid, and that's from user's perspective
- bool fill() const
- {
- return m_fill;
- }
+ virtual bool contains(const QRectF &bounds, const QPointF &point);
signals:
-
- void fillChanged(bool arg);
-
public slots:
-
- void setFill(bool arg)
- {
- if (m_fill != arg) {
- m_fill = arg;
- emit fillChanged(arg);
- }
- }
protected:
- bool m_fill;
};
QT_END_NAMESPACE
diff --git a/src/declarative/particles/qsgparticlepainter.cpp b/src/declarative/particles/qsgparticlepainter.cpp
index 97333ff20b..f4639c20a2 100644
--- a/src/declarative/particles/qsgparticlepainter.cpp
+++ b/src/declarative/particles/qsgparticlepainter.cpp
@@ -103,12 +103,16 @@ void QSGParticlePainter::setSystem(QSGParticleSystem *arg)
void QSGParticlePainter::load(QSGParticleData* d)
{
+ if (m_pleaseReset)
+ return;
initialize(d->group, d->index);
m_pendingCommits << qMakePair<int, int>(d->group, d->index);
}
void QSGParticlePainter::reload(QSGParticleData* d)
{
+ if (m_pleaseReset)
+ return;
m_pendingCommits << qMakePair<int, int>(d->group, d->index);
}
diff --git a/src/declarative/particles/qsgparticlesmodule.cpp b/src/declarative/particles/qsgparticlesmodule.cpp
index e6076b925f..9fa0ebad97 100644
--- a/src/declarative/particles/qsgparticlesmodule.cpp
+++ b/src/declarative/particles/qsgparticlesmodule.cpp
@@ -39,18 +39,17 @@
**
****************************************************************************/
-#include "qsgangleddirection_p.h"
+#include "qsgangledirection_p.h"
#include "qsgcustomparticle_p.h"
#include "qsgellipseextruder_p.h"
-#include "qsgfollowemitter_p.h"
+#include "qsgtrailemitter_p.h"
#include "qsgfriction_p.h"
#include "qsggravity_p.h"
#include "qsgimageparticle_p.h"
#include "qsgitemparticle_p.h"
-#include "qsgkill_p.h"
+#include "qsgage_p.h"
#include "qsglineextruder_p.h"
#include "qsgmaskextruder_p.h"
-#include "qsgmodelparticle_p.h"
#include "qsgparticleaffector_p.h"
#include "qsgparticleemitter_p.h"
#include "qsgparticleextruder_p.h"
@@ -60,12 +59,14 @@
#include "qsgpointattractor_p.h"
#include "qsgpointdirection_p.h"
#include "qsgspritegoal_p.h"
-#include "qsgstochasticdirection_p.h"
-#include "qsgtargeteddirection_p.h"
+#include "qsgdirection_p.h"
+#include "qsgtargetdirection_p.h"
#include "qsgturbulence_p.h"
#include "qsgwander_p.h"
#include "qsgtargetaffector_p.h"
#include "qsgcumulativedirection_p.h"
+#include "qsgcustomaffector_p.h"
+#include "qsgrectangleextruder_p.h"
QT_BEGIN_NAMESPACE
@@ -78,34 +79,35 @@ void QSGParticlesModule::defineModule()
qmlRegisterType<QSGImageParticle>(uri, 2, 0, "ImageParticle");
qmlRegisterType<QSGCustomParticle>(uri, 2, 0, "CustomParticle");
qmlRegisterType<QSGItemParticle>(uri, 2, 0, "ItemParticle");
- qmlRegisterType<QSGModelParticle>(uri, 2, 0, "ModelParticle");
qmlRegisterType<QSGParticleEmitter>(uri, 2, 0, "Emitter");
- qmlRegisterType<QSGFollowEmitter>(uri, 2, 0, "FollowEmitter");
+ qmlRegisterType<QSGTrailEmitter>(uri, 2, 0, "TrailEmitter");
qmlRegisterType<QSGEllipseExtruder>(uri, 2, 0, "EllipseShape");
+ qmlRegisterType<QSGRectangleExtruder>(uri, 2, 0, "RectangleShape");
qmlRegisterType<QSGLineExtruder>(uri, 2, 0, "LineShape");
qmlRegisterType<QSGMaskExtruder>(uri, 2, 0, "MaskShape");
qmlRegisterType<QSGPointDirection>(uri, 2, 0, "PointDirection");
- qmlRegisterType<QSGAngledDirection>(uri, 2, 0, "AngledDirection");
- qmlRegisterType<QSGTargetedDirection>(uri, 2, 0, "TargetedDirection");
+ qmlRegisterType<QSGAngleDirection>(uri, 2, 0, "AngleDirection");
+ qmlRegisterType<QSGTargetDirection>(uri, 2, 0, "TargetDirection");
qmlRegisterType<QSGCumulativeDirection>(uri, 2, 0, "CumulativeDirection");
- qmlRegisterType<QSGParticleAffector>(uri, 2, 0, "Affector");//useful for the triggered signal
+ qmlRegisterType<QSGCustomAffector>(uri, 2, 0, "Affector");
qmlRegisterType<QSGWanderAffector>(uri, 2, 0, "Wander");
qmlRegisterType<QSGFrictionAffector>(uri, 2, 0, "Friction");
- qmlRegisterType<QSGPointAttractorAffector>(uri, 2, 0, "PointAttractor");
+ qmlRegisterType<QSGAttractorAffector>(uri, 2, 0, "Attractor");
qmlRegisterType<QSGGravityAffector>(uri, 2, 0, "Gravity");
- qmlRegisterType<QSGKillAffector>(uri, 2, 0, "Kill");
+ qmlRegisterType<QSGAgeAffector>(uri, 2, 0, "Age");
qmlRegisterType<QSGSpriteGoalAffector>(uri, 2, 0, "SpriteGoal");
qmlRegisterType<QSGTurbulenceAffector>(uri, 2, 0 , "Turbulence");
qmlRegisterType<QSGTargetAffector>(uri, 2, 0 , "Target");
//Exposed just for completeness
- qmlRegisterType<QSGParticlePainter>(uri, 2, 0, "ParticlePainter");
- qmlRegisterType<QSGParticleExtruder>(uri, 2, 0, "ParticleExtruder");
- qmlRegisterType<QSGStochasticDirection>(uri, 2, 0, "NullVector");
+ qmlRegisterUncreatableType<QSGParticleAffector>(uri, 2, 0, "ParticleAffector", "Abstract type. Use one of the inheriting types instead.");
+ qmlRegisterUncreatableType<QSGParticlePainter>(uri, 2, 0, "ParticlePainter", "Abstract type. Use one of the inheriting types instead.");
+ qmlRegisterUncreatableType<QSGParticleExtruder>(uri, 2, 0, "ParticleExtruder", "Abstract type. Use one of the inheriting types instead.");
+ qmlRegisterUncreatableType<QSGDirection>(uri, 2, 0, "NullVector", "Abstract type. Use one of the inheriting types instead.");
}
QT_END_NAMESPACE
diff --git a/src/declarative/particles/qsgparticlesystem.cpp b/src/declarative/particles/qsgparticlesystem.cpp
index 534b1ca8a1..425df349e5 100644
--- a/src/declarative/particles/qsgparticlesystem.cpp
+++ b/src/declarative/particles/qsgparticlesystem.cpp
@@ -48,7 +48,7 @@
#include "qsgsprite_p.h"
#include "qsgv8particledata_p.h"
-#include "qsgfollowemitter_p.h"//###For auto-follow on states, perhaps should be in emitter?
+#include "qsgtrailemitter_p.h"//###For auto-follow on states, perhaps should be in emitter?
#include <private/qdeclarativeengine_p.h>
#include <cmath>
#include <QDebug>
@@ -99,13 +99,6 @@ DEFINE_BOOL_CONFIG_OPTION(qmlParticlesDebug, QML_PARTICLES_DEBUG)
*/
/*!
- \qmlproperty int QtQuick.Particles2::ParticleSystem::startTime
-
- If start time is specified, then the system will simulate up to this time
- before the system starts playing. This allows you to appear to start with a
- fully populated particle system, instead of starting with no particles visible.
-*/
-/*!
\qmlproperty list<Sprite> QtQuick.Particles2::ParticleSystem::particleStates
You can define a sub-set of particle groups in this property in order to provide them
@@ -113,10 +106,55 @@ DEFINE_BOOL_CONFIG_OPTION(qmlParticlesDebug, QML_PARTICLES_DEBUG)
Each QtQuick2::Sprite in this list is interpreted as corresponding to the particle group
with ths same name. Any transitions defined in these sprites will take effect on the particle
- groups as well. Additionally FollowEmitters, Affectors and ParticlePainters definined
+ groups as well. Additionally TrailEmitters, Affectors and ParticlePainters definined
inside one of these sprites are automatically associated with the corresponding particle group.
*/
+/*!
+ \qmlmethod void QtQuick.Particles2::ParticleSystem::pause
+
+ Pauses the simulation if it is running.
+
+ \sa resume, paused
+*/
+
+/*!
+ \qmlmethod void QtQuick.Particles2::ParticleSystem::resume
+
+ Resumes the simulation if it is paused.
+
+ \sa pause, paused
+*/
+
+/*!
+ \qmlmethod void QtQuick.Particles2::ParticleSystem::start
+
+ Starts the simulation if it has not already running.
+
+ \sa stop, restart, running
+*/
+
+/*!
+ \qmlmethod void QtQuick.Particles2::ParticleSystem::stop
+
+ Stops the simulation if it is running.
+
+ \sa start, restart, running
+*/
+
+/*!
+ \qmlmethod void QtQuick.Particles2::ParticleSystem::restart
+
+ Stops the simulation if it is running, and then starts it.
+
+ \sa stop, restart, running
+*/
+/*!
+ \qmlmethod void QtQuick.Particles2::ParticleSystem::reset
+
+ Discards all currently existing particles.
+
+*/
const qreal EPSILON = 0.001;
//Utility functions for when within 1ms is close enough
bool timeEqualOrGreater(qreal a, qreal b){
@@ -562,8 +600,8 @@ void QSGParticleData::extendLife(float time)
}
QSGParticleSystem::QSGParticleSystem(QSGItem *parent) :
- QSGItem(parent), m_particle_count(0), m_running(true)
- , m_startTime(0), m_nextIndex(0), m_componentComplete(false), m_spriteEngine(0)
+ QSGItem(parent), m_particle_count(0), m_running(true), m_paused(false)
+ , m_nextIndex(0), m_componentComplete(false), m_spriteEngine(0)
{
connect(&m_painterMapper, SIGNAL(mapped(QObject*)),
this, SLOT(loadPainter(QObject*)));
@@ -663,7 +701,7 @@ void QSGParticleSystem::stateRedirect(QDeclarativeListProperty<QObject> *prop, Q
a->setSystem(sys);
return;
}
- QSGFollowEmitter* fe = qobject_cast<QSGFollowEmitter*>(value);
+ QSGTrailEmitter* fe = qobject_cast<QSGTrailEmitter*>(value);
if (fe){
fe->setParentItem(sys);
fe->setFollow(sprite->name());
@@ -726,8 +764,9 @@ void QSGParticleSystem::reset()
//### Do affectors need reset too?
- if (m_animation){//reset restarts animation (if running)
- m_animation->stop();
+ if (m_running) {//reset restarts animation (if running)
+ if ((m_animation->state() == QAbstractAnimation::Running))
+ m_animation->stop();
m_animation->start();
if (m_paused)
m_animation->pause();
@@ -927,7 +966,7 @@ QSGParticleData* QSGParticleSystem::newDatum(int groupId, bool respectLimits, in
if (m_spriteEngine)
m_spriteEngine->startSprite(ret->systemIndex, ret->group);
- m_clear = false;
+ m_empty = false;
return ret;
}
@@ -962,15 +1001,15 @@ void QSGParticleSystem::updateCurrentTime( int currentTime )
//### Elapsed time never shrinks - may cause problems if left emitting for weeks at a time.
qreal dt = m_timeInt / 1000.;
- m_timeInt = currentTime + m_startTime;
+ m_timeInt = currentTime;
qreal time = m_timeInt / 1000.;
dt = time - dt;
m_needsReset.clear();
- bool oldClear = m_clear;
- m_clear = true;
+ bool oldClear = m_empty;
+ m_empty = true;
foreach (QSGParticleGroupData* gd, m_groupData)//Recycle all groups and see if they're out of live particles
- m_clear = m_clear && gd->recycle();
+ m_empty = m_empty && gd->recycle();
if (m_spriteEngine)
m_spriteEngine->updateSprites(m_timeInt);
@@ -986,8 +1025,8 @@ void QSGParticleSystem::updateCurrentTime( int currentTime )
if (p && d)
p->reload(d);
- if (oldClear != m_clear)
- clearChanged(m_clear);
+ if (oldClear != m_empty)
+ emptyChanged(m_empty);
}
int QSGParticleSystem::systemSync(QSGParticlePainter* p)
diff --git a/src/declarative/particles/qsgparticlesystem_p.h b/src/declarative/particles/qsgparticlesystem_p.h
index 17b67d9cce..25a0c87f53 100644
--- a/src/declarative/particles/qsgparticlesystem_p.h
+++ b/src/declarative/particles/qsgparticlesystem_p.h
@@ -222,8 +222,7 @@ class QSGParticleSystem : public QSGItem
Q_OBJECT
Q_PROPERTY(bool running READ isRunning WRITE setRunning NOTIFY runningChanged)
Q_PROPERTY(bool paused READ isPaused WRITE setPaused NOTIFY pausedChanged)
- Q_PROPERTY(bool clear READ isClear NOTIFY clearChanged)
- Q_PROPERTY(int startTime READ startTime WRITE setStartTime NOTIFY startTimeChanged)
+ Q_PROPERTY(bool empty READ isEmpty NOTIFY emptyChanged)
Q_PROPERTY(QDeclarativeListProperty<QSGSprite> particleStates READ particleStates)
public:
@@ -237,11 +236,6 @@ public:
return m_running;
}
- int startTime() const
- {
- return m_startTime;
- }
-
int count(){ return m_particle_count; }
static const int maxLife = 600000;
@@ -250,13 +244,8 @@ signals:
void systemInitialized();
void runningChanged(bool arg);
-
- void startTimeChanged(int arg);
-
-
void pausedChanged(bool arg);
-
- void clearChanged(bool arg);
+ void emptyChanged(bool arg);
public slots:
void start(){setRunning(true);}
@@ -269,16 +258,6 @@ public slots:
void setRunning(bool arg);
void setPaused(bool arg);
- void setStartTime(int arg)
- {
- m_startTime = arg;
- }
-
- void fastForward(int ms)
- {
- m_startTime += ms;
- }
-
virtual int duration() const { return -1; }
@@ -323,9 +302,9 @@ public://###but only really for related class usage. Perhaps we should all be fr
return m_paused;
}
- bool isClear() const
+ bool isEmpty() const
{
- return m_clear;
+ return m_empty;
}
private:
@@ -336,7 +315,6 @@ private:
QList<QPointer<QSGParticleAffector> > m_affectors;
QList<QPointer<QSGParticlePainter> > m_painters;
QList<QPointer<QSGParticlePainter> > m_syncList;
- qint64 m_startTime;
int m_nextGroupId;
int m_nextIndex;
QSet<int> m_reusableIndexes;
@@ -351,7 +329,7 @@ private:
bool m_paused;
bool m_debugMode;
bool m_allDead;
- bool m_clear;
+ bool m_empty;
};
// Internally, this animation drives all the timing. Painters sync up in their updatePaintNode
diff --git a/src/declarative/particles/qsgpointattractor.cpp b/src/declarative/particles/qsgpointattractor.cpp
index c916e4da94..8c2632f2c8 100644
--- a/src/declarative/particles/qsgpointattractor.cpp
+++ b/src/declarative/particles/qsgpointattractor.cpp
@@ -44,16 +44,16 @@
#include <QDebug>
QT_BEGIN_NAMESPACE
/*!
- \qmlclass PointAttractor QSGPointAttractorAffector
+ \qmlclass Attractor QSGAttractorAffector
\inqmlmodule QtQuick.Particles 2
\inherits Affector
- \brief The PointAttractor allows you to attract particles towards a specific point.
+ \brief The Attractor allows you to attract particles towards a specific point.
Note that the size and position of this element affects which particles it affects.
The size of the point attracted to is always 0x0, and the location of that point
is specified by the pointX and pointY properties.
- Note that PointAttractor has the standard Item x,y,width and height properties.
+ Note that Attractor has the standard Item x,y,width and height properties.
Like other affectors, these represent the affected area. They
do not represent the 0x0 point which is the target of the attraction.
@@ -62,45 +62,57 @@ QT_BEGIN_NAMESPACE
/*!
\qmlproperty real QtQuick.Particles2::PointAttractor::pointX
+
+ The x coordinate of the attracting point. This is relative
+ to the x coordinate of the Attractor.
*/
/*!
\qmlproperty real QtQuick.Particles2::PointAttractor::pointY
+
+ The x coordinate of the attracting point. This is relative
+ to the x coordinate of the Attractor.
*/
/*!
\qmlproperty real QtQuick.Particles2::PointAttractor::strength
+
+ The pull, in units per second, to be exerted on an item one pixel away.
+
+ Depending on how the attraction is proportionalToDistance this may have to
+ be very high or very low to have a reasonable effect on particles at a
+ distance.
*/
/*!
- \qmlproperty PhysicsAffects QtQuick.Particles2::PointAttractor::physics
+ \qmlproperty AffectableParameter QtQuick.Particles2::Attractor::affectedParameter
What attribute of particles is directly affected.
\list
- \o PointAttractor.Position
- \o PointAttractor.Velocity
- \o PointAttractor.Acceleration
+ \o Attractor.Position
+ \o Attractor.Velocity
+ \o Attractor.Acceleration
\endlist
*/
/*!
- \qmlproperty Proportion QtQuick.Particles2::PointAttractor::proportionalToDistance
+ \qmlproperty Proportion QtQuick.Particles2::Attractor::proportionalToDistance
How the distance from the particle to the point affects the strength of the attraction.
\list
- \o PointAttractor.Constant
- \o PointAttractor.Linear
- \o PointAttractor.InverseLinear
- \o PointAttractor.Quadratic
- \o PointAttractor.InverseQuadratic
+ \o Attractor.Constant
+ \o Attractor.Linear
+ \o Attractor.InverseLinear
+ \o Attractor.Quadratic
+ \o Attractor.InverseQuadratic
\endlist
*/
-QSGPointAttractorAffector::QSGPointAttractorAffector(QSGItem *parent) :
+QSGAttractorAffector::QSGAttractorAffector(QSGItem *parent) :
QSGParticleAffector(parent), m_strength(0.0), m_x(0), m_y(0)
, m_physics(Velocity), m_proportionalToDistance(Linear)
{
}
-bool QSGPointAttractorAffector::affectParticle(QSGParticleData *d, qreal dt)
+bool QSGAttractorAffector::affectParticle(QSGParticleData *d, qreal dt)
{
if (m_strength == 0.0)
return false;
diff --git a/src/declarative/particles/qsgpointattractor_p.h b/src/declarative/particles/qsgpointattractor_p.h
index e2cdd0fdca..75dd47e331 100644
--- a/src/declarative/particles/qsgpointattractor_p.h
+++ b/src/declarative/particles/qsgpointattractor_p.h
@@ -49,15 +49,15 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
-class QSGPointAttractorAffector : public QSGParticleAffector
+class QSGAttractorAffector : public QSGParticleAffector
{
Q_OBJECT
Q_PROPERTY(qreal strength READ strength WRITE setStrength NOTIFY strengthChanged)
Q_PROPERTY(qreal pointX READ pointX WRITE setPointX NOTIFY pointXChanged)
Q_PROPERTY(qreal pointY READ pointY WRITE setPointY NOTIFY pointYChanged)
- Q_PROPERTY(PhysicsAffects physics READ physics WRITE setPhysics NOTIFY physicsChanged)
+ Q_PROPERTY(AffectableParameters affectedParameter READ affectedParameter WRITE setAffectedParameter NOTIFY affectedParameterChanged)
Q_PROPERTY(Proportion proportionalToDistance READ proportionalToDistance WRITE setProportionalToDistance NOTIFY proportionalToDistanceChanged)
- Q_ENUMS(PhysicsAffects)
+ Q_ENUMS(AffectableParameters)
Q_ENUMS(Proportion)
public:
@@ -69,13 +69,13 @@ public:
InverseQuadratic
};
- enum PhysicsAffects {
+ enum AffectableParameters {
Position,
Velocity,
Acceleration
};
- explicit QSGPointAttractorAffector(QSGItem *parent = 0);
+ explicit QSGAttractorAffector(QSGItem *parent = 0);
qreal strength() const
{
@@ -92,7 +92,7 @@ public:
return m_y;
}
- PhysicsAffects physics() const
+ AffectableParameters affectedParameter() const
{
return m_physics;
}
@@ -110,7 +110,7 @@ signals:
void pointYChanged(qreal arg);
- void physicsChanged(PhysicsAffects arg);
+ void affectedParameterChanged(AffectableParameters arg);
void proportionalToDistanceChanged(Proportion arg);
@@ -138,11 +138,11 @@ void setPointY(qreal arg)
emit pointYChanged(arg);
}
}
-void setPhysics(PhysicsAffects arg)
+void setAffectedParameter(AffectableParameters arg)
{
if (m_physics != arg) {
m_physics = arg;
- emit physicsChanged(arg);
+ emit affectedParameterChanged(arg);
}
}
@@ -160,7 +160,7 @@ private:
qreal m_strength;
qreal m_x;
qreal m_y;
-PhysicsAffects m_physics;
+AffectableParameters m_physics;
Proportion m_proportionalToDistance;
};
diff --git a/src/declarative/particles/qsgpointdirection.cpp b/src/declarative/particles/qsgpointdirection.cpp
index 7cc0823eec..dc104c1a81 100644
--- a/src/declarative/particles/qsgpointdirection.cpp
+++ b/src/declarative/particles/qsgpointdirection.cpp
@@ -46,7 +46,7 @@ QT_BEGIN_NAMESPACE
/*!
\qmlclass PointDirection QSGPointDirection
\inqmlmodule QtQuick.Particles 2
- \inherits StochasticDirection
+ \inherits Direction
\brief The PointDirection element allows you to specify a direction that varies in x and y components
The PointDirection element allows both the specification of a direction by x and y components,
@@ -66,7 +66,7 @@ QT_BEGIN_NAMESPACE
*/
QSGPointDirection::QSGPointDirection(QObject *parent) :
- QSGStochasticDirection(parent)
+ QSGDirection(parent)
, m_x(0)
, m_y(0)
, m_xVariation(0)
diff --git a/src/declarative/particles/qsgpointdirection_p.h b/src/declarative/particles/qsgpointdirection_p.h
index 6a6beb6623..ca00824a3e 100644
--- a/src/declarative/particles/qsgpointdirection_p.h
+++ b/src/declarative/particles/qsgpointdirection_p.h
@@ -41,7 +41,7 @@
#ifndef POINTVECTOR_H
#define POINTVECTOR_H
-#include "qsgstochasticdirection_p.h"
+#include "qsgdirection_p.h"
QT_BEGIN_HEADER
@@ -49,7 +49,7 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
-class QSGPointDirection : public QSGStochasticDirection
+class QSGPointDirection : public QSGDirection
{
Q_OBJECT
Q_PROPERTY(qreal x READ x WRITE setX NOTIFY xChanged)
diff --git a/src/declarative/particles/qsgrectangleextruder.cpp b/src/declarative/particles/qsgrectangleextruder.cpp
new file mode 100644
index 0000000000..accc88fcdb
--- /dev/null
+++ b/src/declarative/particles/qsgrectangleextruder.cpp
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Declarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsgrectangleextruder_p.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmlclass RectangleShape QSGRectangleExtruder
+ \inqmlmodule QtQuick.Particles 2
+ \brief The RectangleShape element allows you to specify an area for affectors and emitter.
+
+ Just a rectangle.
+*/
+
+QSGRectangleExtruder::QSGRectangleExtruder(QObject *parent) :
+ QObject(parent), m_fill(true)
+{
+}
+
+QPointF QSGRectangleExtruder::extrude(const QRectF &rect)
+{
+ if (m_fill)
+ return QPointF(((qreal)rand() / RAND_MAX) * rect.width() + rect.x(),
+ ((qreal)rand() / RAND_MAX) * rect.height() + rect.y());
+ int side = rand() % 4;
+ switch (side){//TODO: Doesn't this overlap the corners?
+ case 0:
+ return QPointF(rect.x(),
+ ((qreal)rand() / RAND_MAX) * rect.height() + rect.y());
+ case 1:
+ return QPointF(rect.width() + rect.x(),
+ ((qreal)rand() / RAND_MAX) * rect.height() + rect.y());
+ case 2:
+ return QPointF(((qreal)rand() / RAND_MAX) * rect.width() + rect.x(),
+ rect.y());
+ default:
+ return QPointF(((qreal)rand() / RAND_MAX) * rect.width() + rect.x(),
+ rect.height() + rect.y());
+ }
+}
+
+bool QSGRectangleExtruder::contains(const QRectF &bounds, const QPointF &point)
+{
+ return bounds.contains(point);
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/particles/qsgrectangleextruder_p.h b/src/declarative/particles/qsgrectangleextruder_p.h
new file mode 100644
index 0000000000..5795375c84
--- /dev/null
+++ b/src/declarative/particles/qsgrectangleextruder_p.h
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Declarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef RECTANGLEEXTRUDER_H
+#define RECTANGLEEXTRUDER_H
+
+#include "qsgparticleextruder_p.h"
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QSGRectangleExtruder : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(bool fill READ fill WRITE setFill NOTIFY fillChanged)
+
+public:
+ explicit QSGRectangleExtruder(QObject *parent = 0);
+ virtual QPointF extrude(const QRectF &);
+ virtual bool contains(const QRectF &bounds, const QPointF &point);
+ bool fill() const
+ {
+ return m_fill;
+ }
+
+signals:
+
+ void fillChanged(bool arg);
+
+public slots:
+
+ void setFill(bool arg)
+ {
+ if (m_fill != arg) {
+ m_fill = arg;
+ emit fillChanged(arg);
+ }
+ }
+protected:
+ bool m_fill;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // RectangleEXTRUDER_H
diff --git a/src/declarative/particles/qsgtargeteddirection.cpp b/src/declarative/particles/qsgtargetdirection.cpp
index 696cdfa915..d9a3ce5a74 100644
--- a/src/declarative/particles/qsgtargeteddirection.cpp
+++ b/src/declarative/particles/qsgtargetdirection.cpp
@@ -39,41 +39,41 @@
**
****************************************************************************/
-#include "qsgtargeteddirection_p.h"
+#include "qsgtargetdirection_p.h"
#include "qsgparticleemitter_p.h"
#include <cmath>
#include <QDebug>
QT_BEGIN_NAMESPACE
/*!
- \qmlclass TargetedDirection QSGTargetedDirection
+ \qmlclass TargetDirection QSGTargetDirection
\inqmlmodule QtQuick.Particles 2
- \inherits StochasticDirection
- \brief The TargetedDirection element allows you to specify a direction towards the target point
+ \inherits Direction
+ \brief The TargetDirection element allows you to specify a direction towards the target point
*/
/*!
- \qmlproperty real QtQuick.Particles2::TargetedDirection::targetX
+ \qmlproperty real QtQuick.Particles2::TargetDirection::targetX
*/
/*!
- \qmlproperty real QtQuick.Particles2::TargetedDirection::targetY
+ \qmlproperty real QtQuick.Particles2::TargetDirection::targetY
*/
/*!
- \qmlproperty Item QtQuick.Particles2::TargetedDirection::targetItem
+ \qmlproperty Item QtQuick.Particles2::TargetDirection::targetItem
If specified, this will take precedence over targetX and targetY.
The targeted point will be the center of the specified Item
*/
/*!
- \qmlproperty real QtQuick.Particles2::TargetedDirection::targetVariation
+ \qmlproperty real QtQuick.Particles2::TargetDirection::targetVariation
*/
/*!
- \qmlproperty real QtQuick.Particles2::TargetedDirection::magnitude
+ \qmlproperty real QtQuick.Particles2::TargetDirection::magnitude
*/
/*!
- \qmlproperty real QtQuick.Particles2::TargetedDirection::magnitudeVariation
+ \qmlproperty real QtQuick.Particles2::TargetDirection::magnitudeVariation
*/
/*!
- \qmlproperty bool QtQuick.Particles2::TargetedDirection::proportionalMagnitude
+ \qmlproperty bool QtQuick.Particles2::TargetDirection::proportionalMagnitude
If true, then the value of magnitude and magnitudeVariation shall be interpreted as multiples
of the distance between the source point and the target point, per second.
@@ -82,8 +82,8 @@ QT_BEGIN_NAMESPACE
pixels per second.
*/
-QSGTargetedDirection::QSGTargetedDirection(QObject *parent) :
- QSGStochasticDirection(parent)
+QSGTargetDirection::QSGTargetDirection(QObject *parent) :
+ QSGDirection(parent)
, m_targetX(0)
, m_targetY(0)
, m_targetVariation(0)
@@ -94,7 +94,7 @@ QSGTargetedDirection::QSGTargetedDirection(QObject *parent) :
{
}
-const QPointF &QSGTargetedDirection::sample(const QPointF &from)
+const QPointF &QSGTargetDirection::sample(const QPointF &from)
{
//###This approach loses interpolating the last position of the target (like we could with the emitter) is it worthwhile?
qreal targetX;
diff --git a/src/declarative/particles/qsgtargeteddirection_p.h b/src/declarative/particles/qsgtargetdirection_p.h
index 6fdd3f937d..8f4901a57b 100644
--- a/src/declarative/particles/qsgtargeteddirection_p.h
+++ b/src/declarative/particles/qsgtargetdirection_p.h
@@ -41,7 +41,7 @@
#ifndef DIRECTEDVECTOR_H
#define DIRECTEDVECTOR_H
-#include "qsgstochasticdirection_p.h"
+#include "qsgdirection_p.h"
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
@@ -49,7 +49,7 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
class QSGItem;
-class QSGTargetedDirection : public QSGStochasticDirection
+class QSGTargetDirection : public QSGDirection
{
Q_OBJECT
Q_PROPERTY(qreal targetX READ targetX WRITE setTargetX NOTIFY targetXChanged)
@@ -65,7 +65,7 @@ class QSGTargetedDirection : public QSGStochasticDirection
Q_PROPERTY(qreal magnitudeVariation READ magnitudeVariation WRITE setMagnitudeVariation NOTIFY magnitudeVariationChanged)
public:
- explicit QSGTargetedDirection(QObject *parent = 0);
+ explicit QSGTargetDirection(QObject *parent = 0);
virtual const QPointF &sample(const QPointF &from);
qreal targetX() const
diff --git a/src/declarative/particles/qsgfollowemitter.cpp b/src/declarative/particles/qsgtrailemitter.cpp
index 68f0f6bf75..6bccf3ba8c 100644
--- a/src/declarative/particles/qsgfollowemitter.cpp
+++ b/src/declarative/particles/qsgtrailemitter.cpp
@@ -39,21 +39,20 @@
**
****************************************************************************/
-#include "qsgfollowemitter_p.h"
-#include "qsgparticlepainter_p.h"//TODO: What was this for again?
+#include "qsgtrailemitter_p.h"
#include <cmath>
QT_BEGIN_NAMESPACE
/*!
- \qmlclass FollowEmitter QSGFollowEmitter
+ \qmlclass TrailEmitter QSGTrailEmitter
\inqmlmodule QtQuick.Particles 2
\inherits QSGParticleEmitter
- \brief The FollowEmitter element allows you to emit logical particles from other logical particles.
+ \brief The TrailEmitter element allows you to emit logical particles from other logical particles.
This element emits logical particles into the ParticleSystem, with the
starting positions based on those of other logical particles.
*/
-QSGFollowEmitter::QSGFollowEmitter(QSGItem *parent) :
+QSGTrailEmitter::QSGTrailEmitter(QSGItem *parent) :
QSGParticleEmitter(parent)
, m_particlesPerParticlePerSecond(0)
, m_lastTimeStamp(0)
@@ -73,28 +72,37 @@ QSGFollowEmitter::QSGFollowEmitter(QSGItem *parent) :
}
/*!
- \qmlproperty string QtQuick.Particles2::FollowEmitter::follow
+ \qmlproperty string QtQuick.Particles2::TrailEmitter::follow
The type of logical particle which this is emitting from.
*/
+/*!
+ \qmlproperty qreal QtQuick.Particles2::TrailEmitter::speedFromMovement
+
+ If this value is non-zero, then any movement of the emitter will provide additional
+ starting velocity to the particles based on the movement. The additional vector will be the
+ same angle as the emitter's movement, with a magnitude that is the magnitude of the emitters
+ movement multiplied by speedFromMovement.
+ Default value is 0.
+*/
/*!
- \qmlproperty Shape QtQuick.Particles2::FollowEmitter::emitShape
+ \qmlproperty Shape QtQuick.Particles2::TrailEmitter::emitShape
- As the area of a FollowEmitter is the area it follows, a separate shape can be provided
+ As the area of a TrailEmitter is the area it follows, a separate shape can be provided
to be the shape it emits out of.
*/
/*!
- \qmlproperty real QtQuick.Particles2::FollowEmitter::emitWidth
+ \qmlproperty real QtQuick.Particles2::TrailEmitter::emitWidth
*/
/*!
- \qmlproperty real QtQuick.Particles2::FollowEmitter::emitHeight
+ \qmlproperty real QtQuick.Particles2::TrailEmitter::emitHeight
*/
/*!
- \qmlproperty real QtQuick.Particles2::FollowEmitter::emitRatePerParticle
+ \qmlproperty real QtQuick.Particles2::TrailEmitter::emitRatePerParticle
*/
/*!
- \qmlsignal QtQuick.Particles2::FollowEmitter::emitFollowParticle(particle, followed)
+ \qmlsignal QtQuick.Particles2::TrailEmitter::emitFollowParticle(particle, followed)
This handler is called when a particle is emitted. You can modify particle
attributes from within the handler. followed is the particle that this is being
@@ -103,13 +111,13 @@ QSGFollowEmitter::QSGFollowEmitter(QSGItem *parent) :
If you use this signal handler, emitParticle will not be emitted.
*/
-bool QSGFollowEmitter::isEmitFollowConnected()
+bool QSGTrailEmitter::isEmitFollowConnected()
{
static int idx = QObjectPrivate::get(this)->signalIndex("emitFollowParticle(QDeclarativeV8Handle,QDeclarativeV8Handle)");
return QObjectPrivate::get(this)->isSignalConnected(idx);
}
-void QSGFollowEmitter::recalcParticlesPerSecond(){
+void QSGTrailEmitter::recalcParticlesPerSecond(){
if (!m_system)
return;
m_followCount = m_system->m_groupData[m_system->m_groupIds[m_follow]]->size();
@@ -122,16 +130,16 @@ void QSGFollowEmitter::recalcParticlesPerSecond(){
}
}
-void QSGFollowEmitter::reset()
+void QSGTrailEmitter::reset()
{
m_followCount = 0;
}
-void QSGFollowEmitter::emitWindow(int timeStamp)
+void QSGTrailEmitter::emitWindow(int timeStamp)
{
if (m_system == 0)
return;
- if (!m_emitting && !m_burstLeft && m_burstQueue.isEmpty())
+ if (!m_enabled && !m_burstLeft && m_burstQueue.isEmpty())
return;
if (m_followCount != m_system->m_groupData[m_system->m_groupIds[m_follow]]->size()){
qreal oldPPS = m_particlesPerSecond;
@@ -224,8 +232,8 @@ void QSGFollowEmitter::emitWindow(int timeStamp)
float size = qMax((qreal)0.0, m_particleSize + sizeVariation);
float endSize = qMax((qreal)0.0, sizeAtEnd + sizeVariation);
- datum->size = size * float(m_emitting);
- datum->endSize = endSize * float(m_emitting);
+ datum->size = size * float(m_enabled);
+ datum->endSize = endSize * float(m_enabled);
if (isEmitFollowConnected())
emitFollowParticle(datum->v8Value(), d->v8Value());//A chance for many arbitrary JS changes
diff --git a/src/declarative/particles/qsgfollowemitter_p.h b/src/declarative/particles/qsgtrailemitter_p.h
index d26435df6a..5ab6f24270 100644
--- a/src/declarative/particles/qsgfollowemitter_p.h
+++ b/src/declarative/particles/qsgtrailemitter_p.h
@@ -51,21 +51,20 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
-class QSGFollowEmitter : public QSGParticleEmitter
+class QSGTrailEmitter : public QSGParticleEmitter
{
Q_OBJECT
Q_PROPERTY(QString follow READ follow WRITE setFollow NOTIFY followChanged)
- //### Remove, and just document that particles per second is per particle? But has count issues
Q_PROPERTY(int emitRatePerParticle READ particlesPerParticlePerSecond WRITE setParticlesPerParticlePerSecond NOTIFY particlesPerParticlePerSecondChanged)
- //TODO: Document that FollowEmitter's box is where it follows. It emits in a rect centered on the followed particle
+ //TODO: Document that TrailEmitter's box is where it follows. It emits in a rect centered on the followed particle
//TODO: A set of properties that can involve the particle size of the followed
Q_PROPERTY(QSGParticleExtruder* emitShape READ emissonShape WRITE setEmissionShape NOTIFY emissionShapeChanged)
Q_PROPERTY(qreal emitHeight READ emitterYVariation WRITE setEmitterYVariation NOTIFY emitterYVariationChanged)
Q_PROPERTY(qreal emitWidth READ emitterXVariation WRITE setEmitterXVariation NOTIFY emitterXVariationChanged)
public:
- explicit QSGFollowEmitter(QSGItem *parent = 0);
+ explicit QSGTrailEmitter(QSGItem *parent = 0);
virtual void emitWindow(int timeStamp);
virtual void reset();
diff --git a/src/declarative/particles/qsgturbulence.cpp b/src/declarative/particles/qsgturbulence.cpp
index 003f3c12b6..2caebc7c1f 100644
--- a/src/declarative/particles/qsgturbulence.cpp
+++ b/src/declarative/particles/qsgturbulence.cpp
@@ -138,7 +138,7 @@ void QSGTurbulenceAffector::mapUpdate()
void QSGTurbulenceAffector::affectSystem(qreal dt)
{
- if (!m_system || !m_active)
+ if (!m_system || !m_enabled)
return;
ensureInit();
qreal period = 1.0/m_frequency;
diff --git a/src/declarative/particles/qsgv8particledata.cpp b/src/declarative/particles/qsgv8particledata.cpp
index 72c0b7c2de..d45093c57e 100644
--- a/src/declarative/particles/qsgv8particledata.cpp
+++ b/src/declarative/particles/qsgv8particledata.cpp
@@ -128,7 +128,7 @@ static void particleData_set_ ## VARIABLE (v8::Local<v8::String>, v8::Local<v8::
r->datum-> SETTER ( value->NumberValue() );\
}
-#define FLOAT_REGISTER_ACCESSOR(FT, ENGINE, VARIABLE) FT ->PrototypeTemplate()->SetAccessor( v8::String::New( #VARIABLE ), particleData_get_ ## VARIABLE , particleData_set_ ## VARIABLE , v8::External::Wrap(ENGINE))
+#define FLOAT_REGISTER_ACCESSOR(FT, ENGINE, VARIABLE, NAME) FT ->PrototypeTemplate()->SetAccessor( v8::String::New( #NAME ), particleData_get_ ## VARIABLE , particleData_set_ ## VARIABLE , v8::External::Wrap(ENGINE))
FLOAT_GETTER_AND_SETTER(x)
FLOAT_GETTER_AND_SETTER(y)
@@ -169,34 +169,34 @@ QV8ParticleDataDeletable::QV8ParticleDataDeletable(QV8Engine *engine)
ft->InstanceTemplate()->SetHasExternalResource(true);
ft->PrototypeTemplate()->Set(v8::String::New("discard"), V8FUNCTION(particleData_discard, engine));
ft->PrototypeTemplate()->Set(v8::String::New("lifeLeft"), V8FUNCTION(particleData_lifeLeft, engine));
- ft->PrototypeTemplate()->Set(v8::String::New("curSize"), V8FUNCTION(particleData_curSize, engine));
- FLOAT_REGISTER_ACCESSOR(ft, engine, x);
- FLOAT_REGISTER_ACCESSOR(ft, engine, y);
- FLOAT_REGISTER_ACCESSOR(ft, engine, t);
- FLOAT_REGISTER_ACCESSOR(ft, engine, lifeSpan);
- FLOAT_REGISTER_ACCESSOR(ft, engine, size);
- FLOAT_REGISTER_ACCESSOR(ft, engine, endSize);
- FLOAT_REGISTER_ACCESSOR(ft, engine, vx);
- FLOAT_REGISTER_ACCESSOR(ft, engine, vy);
- FLOAT_REGISTER_ACCESSOR(ft, engine, ax);
- FLOAT_REGISTER_ACCESSOR(ft, engine, ay);
- FLOAT_REGISTER_ACCESSOR(ft, engine, xx);
- FLOAT_REGISTER_ACCESSOR(ft, engine, xy);
- FLOAT_REGISTER_ACCESSOR(ft, engine, rotation);
- FLOAT_REGISTER_ACCESSOR(ft, engine, rotationSpeed);
- FLOAT_REGISTER_ACCESSOR(ft, engine, autoRotate);
- FLOAT_REGISTER_ACCESSOR(ft, engine, animIdx);
- FLOAT_REGISTER_ACCESSOR(ft, engine, frameDuration);
- FLOAT_REGISTER_ACCESSOR(ft, engine, frameCount);
- FLOAT_REGISTER_ACCESSOR(ft, engine, animT);
- FLOAT_REGISTER_ACCESSOR(ft, engine, r);
- FLOAT_REGISTER_ACCESSOR(ft, engine, update);
- FLOAT_REGISTER_ACCESSOR(ft, engine, curX);
- FLOAT_REGISTER_ACCESSOR(ft, engine, curVX);
- FLOAT_REGISTER_ACCESSOR(ft, engine, curAX);
- FLOAT_REGISTER_ACCESSOR(ft, engine, curY);
- FLOAT_REGISTER_ACCESSOR(ft, engine, curVY);
- FLOAT_REGISTER_ACCESSOR(ft, engine, curAY);
+ ft->PrototypeTemplate()->Set(v8::String::New("currentSize"), V8FUNCTION(particleData_curSize, engine));
+ FLOAT_REGISTER_ACCESSOR(ft, engine, x, initialX);
+ FLOAT_REGISTER_ACCESSOR(ft, engine, y, initialY);
+ FLOAT_REGISTER_ACCESSOR(ft, engine, t, t);
+ FLOAT_REGISTER_ACCESSOR(ft, engine, lifeSpan, lifeSpan);
+ FLOAT_REGISTER_ACCESSOR(ft, engine, size, startSize);
+ FLOAT_REGISTER_ACCESSOR(ft, engine, endSize, endSize);
+ FLOAT_REGISTER_ACCESSOR(ft, engine, vx, initialVX);
+ FLOAT_REGISTER_ACCESSOR(ft, engine, vy, initialVY);
+ FLOAT_REGISTER_ACCESSOR(ft, engine, ax, initialAX);
+ FLOAT_REGISTER_ACCESSOR(ft, engine, ay, initialAY);
+ FLOAT_REGISTER_ACCESSOR(ft, engine, xx, xDeformationVector);
+ FLOAT_REGISTER_ACCESSOR(ft, engine, xy, yDeformationVector);
+ FLOAT_REGISTER_ACCESSOR(ft, engine, rotation, rotation);
+ FLOAT_REGISTER_ACCESSOR(ft, engine, rotationSpeed, rotationSpeed);
+ FLOAT_REGISTER_ACCESSOR(ft, engine, autoRotate, autoRotate);
+ FLOAT_REGISTER_ACCESSOR(ft, engine, animIdx, animationIndex);
+ FLOAT_REGISTER_ACCESSOR(ft, engine, frameDuration, frameDuration);
+ FLOAT_REGISTER_ACCESSOR(ft, engine, frameCount, frameCount);
+ FLOAT_REGISTER_ACCESSOR(ft, engine, animT, animationT);
+ FLOAT_REGISTER_ACCESSOR(ft, engine, r, r);
+ FLOAT_REGISTER_ACCESSOR(ft, engine, update, update);
+ FLOAT_REGISTER_ACCESSOR(ft, engine, curX, x);
+ FLOAT_REGISTER_ACCESSOR(ft, engine, curVX, vx);
+ FLOAT_REGISTER_ACCESSOR(ft, engine, curAX, ax);
+ FLOAT_REGISTER_ACCESSOR(ft, engine, curY, y);
+ FLOAT_REGISTER_ACCESSOR(ft, engine, curVY, vy);
+ FLOAT_REGISTER_ACCESSOR(ft, engine, curAY, ay);
constructor = qPersistentNew(ft->GetFunction());
}
diff --git a/src/declarative/particles/qsgwander.cpp b/src/declarative/particles/qsgwander.cpp
index a4a4d2c9c5..d3e87fb241 100644
--- a/src/declarative/particles/qsgwander.cpp
+++ b/src/declarative/particles/qsgwander.cpp
@@ -49,10 +49,39 @@ QT_BEGIN_NAMESPACE
\brief The Wander affector allows particles to randomly vary their trajectory.
*/
+/*!
+ \qmlproperty real QtQuick.Particles2::Wander::pace
+
+ Maximum attribute change per second.
+*/
+/*!
+ \qmlproperty real QtQuick.Particles2::Wander::xVariance
+
+ Maximum attribute x value (as a result of Wander).
+
+ If unset, Wander will not affect x values.
+*/
+/*!
+ \qmlproperty real QtQuick.Particles2::Wander::yVariance
+
+ Maximum attribute y value (as a result of Wander).
+
+ If unset, Wander will not affect y values.
+*/
+/*!
+ \qmlproperty AffectableParameter QtQuick.Particles2::Wander::affectedParameter
+
+ What attribute of particles is directly affected.
+ \list
+ \o PointAttractor.Position
+ \o PointAttractor.Velocity
+ \o PointAttractor.Acceleration
+ \endlist
+*/
QSGWanderAffector::QSGWanderAffector(QSGItem *parent) :
QSGParticleAffector(parent), m_xVariance(0), m_yVariance(0), m_pace(0)
- , m_physics(Velocity)
+ , m_affectedParameter(Velocity)
{
m_needsReset = true;
}
@@ -119,7 +148,7 @@ bool QSGWanderAffector::affectParticle(QSGParticleData* data, qreal dt)
qreal dx = dt * m_pace * (2 * qreal(qrand())/RAND_MAX - 1);
qreal dy = dt * m_pace * (2 * qreal(qrand())/RAND_MAX - 1);
qreal newX, newY;
- switch (m_physics){
+ switch (m_affectedParameter){
case Position:
newX = data->curX() + dx;
if (m_xVariance > qAbs(newX) )
diff --git a/src/declarative/particles/qsgwander_p.h b/src/declarative/particles/qsgwander_p.h
index ae98cf3681..46ad6ea3a2 100644
--- a/src/declarative/particles/qsgwander_p.h
+++ b/src/declarative/particles/qsgwander_p.h
@@ -66,11 +66,11 @@ class QSGWanderAffector : public QSGParticleAffector
Q_PROPERTY(qreal pace READ pace WRITE setPace NOTIFY paceChanged)
Q_PROPERTY(qreal xVariance READ xVariance WRITE setXVariance NOTIFY xVarianceChanged)
Q_PROPERTY(qreal yVariance READ yVariance WRITE setYVariance NOTIFY yVarianceChanged)
- Q_PROPERTY(PhysicsAffects physics READ physics WRITE setPhysics NOTIFY physicsChanged)
- Q_ENUMS(PhysicsAffects)
+ Q_PROPERTY(AffectableParameters affectedParameter READ affectedParameter WRITE setAffectedParameter NOTIFY affectedParameterChanged)
+ Q_ENUMS(AffectableParameters)
public:
- enum PhysicsAffects {
+ enum AffectableParameters {
Position,
Velocity,
Acceleration
@@ -95,9 +95,9 @@ public:
return m_pace;
}
- PhysicsAffects physics() const
+ AffectableParameters affectedParameter() const
{
- return m_physics;
+ return m_affectedParameter;
}
protected:
@@ -111,7 +111,7 @@ signals:
void paceChanged(qreal arg);
- void physicsChanged(PhysicsAffects arg);
+ void affectedParameterChanged(AffectableParameters arg);
public slots:
void setXVariance(qreal arg)
@@ -139,11 +139,11 @@ void setPace(qreal arg)
}
-void setPhysics(PhysicsAffects arg)
+void setAffectedParameter(AffectableParameters arg)
{
- if (m_physics != arg) {
- m_physics = arg;
- emit physicsChanged(arg);
+ if (m_affectedParameter != arg) {
+ m_affectedParameter = arg;
+ emit affectedParameterChanged(arg);
}
}
@@ -153,7 +153,7 @@ private:
qreal m_xVariance;
qreal m_yVariance;
qreal m_pace;
- PhysicsAffects m_physics;
+ AffectableParameters m_affectedParameter;
};
QT_END_NAMESPACE