From 108f7cec20c105c07a34cded24fc1632b86e15c2 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Thu, 12 May 2011 15:43:29 +1000 Subject: [PATCH] Upgrade Flickr demo to QtQuick 2. And throw in particle effects. Includes a variety of fixes to modelparticle and picture affector which were arrived at during this demo. --- .../flickr/{mobile => content}/Button.qml | 2 +- .../{mobile => content}/GridDelegate.qml | 2 +- .../{mobile => content}/ImageDetails.qml | 101 ++++++++++- .../{mobile => content}/ListDelegate.qml | 2 +- .../flickr/{common => content}/Progress.qml | 35 ++-- .../flickr/{common => content}/RssModel.qml | 2 +- .../flickr/{common => content}/ScrollBar.qml | 2 +- .../flickr/{common => content}/Slider.qml | 2 +- .../declarative/flickr/content/StreamView.qml | 108 ++++++++++++ .../flickr/{mobile => content}/TitleBar.qml | 2 +- .../flickr/{mobile => content}/ToolBar.qml | 2 +- .../flickr/content/UnifiedDelegate.qml | 162 ++++++++++++++++++ .../{mobile => content}/images/gloss.png | Bin .../{mobile => content}/images/lineedit.png | Bin .../{mobile => content}/images/lineedit.sci | 0 .../flickr/content/images/particle.png | Bin 0 -> 5148 bytes .../{mobile => content}/images/quit.png | Bin .../flickr/content/images/squareParticle.png | Bin 0 -> 933 bytes .../{mobile => content}/images/stripes.png | Bin .../{mobile => content}/images/titlebar.png | Bin .../{mobile => content}/images/titlebar.sci | 0 .../{mobile => content}/images/toolbutton.png | Bin .../{mobile => content}/images/toolbutton.sci | 0 .../flickr/{common => content}/qmldir | 0 demos/declarative/flickr/flickr-90.qml | 2 +- demos/declarative/flickr/flickr.qml | 75 ++++++-- .../scenegraph/util/qsgtexture_p.h | 1 + src/imports/particles/modelparticle.cpp | 17 +- src/imports/particles/particles.pro | 2 +- src/imports/particles/particlesystem.cpp | 2 + src/imports/particles/particlesystem.h | 5 + src/imports/particles/pictureaffector.cpp | 27 ++- src/imports/particles/pictureaffector.h | 10 +- 33 files changed, 507 insertions(+), 56 deletions(-) rename demos/declarative/flickr/{mobile => content}/Button.qml (99%) rename demos/declarative/flickr/{mobile => content}/GridDelegate.qml (99%) rename demos/declarative/flickr/{mobile => content}/ImageDetails.qml (65%) rename demos/declarative/flickr/{mobile => content}/ListDelegate.qml (99%) rename demos/declarative/flickr/{common => content}/Progress.qml (74%) rename demos/declarative/flickr/{common => content}/RssModel.qml (99%) rename demos/declarative/flickr/{common => content}/ScrollBar.qml (99%) rename demos/declarative/flickr/{common => content}/Slider.qml (99%) create mode 100644 demos/declarative/flickr/content/StreamView.qml rename demos/declarative/flickr/{mobile => content}/TitleBar.qml (99%) rename demos/declarative/flickr/{mobile => content}/ToolBar.qml (99%) create mode 100644 demos/declarative/flickr/content/UnifiedDelegate.qml rename demos/declarative/flickr/{mobile => content}/images/gloss.png (100%) rename demos/declarative/flickr/{mobile => content}/images/lineedit.png (100%) rename demos/declarative/flickr/{mobile => content}/images/lineedit.sci (100%) create mode 100644 demos/declarative/flickr/content/images/particle.png rename demos/declarative/flickr/{mobile => content}/images/quit.png (100%) create mode 100644 demos/declarative/flickr/content/images/squareParticle.png rename demos/declarative/flickr/{mobile => content}/images/stripes.png (100%) rename demos/declarative/flickr/{mobile => content}/images/titlebar.png (100%) rename demos/declarative/flickr/{mobile => content}/images/titlebar.sci (100%) rename demos/declarative/flickr/{mobile => content}/images/toolbutton.png (100%) rename demos/declarative/flickr/{mobile => content}/images/toolbutton.sci (100%) rename demos/declarative/flickr/{common => content}/qmldir (100%) diff --git a/demos/declarative/flickr/mobile/Button.qml b/demos/declarative/flickr/content/Button.qml similarity index 99% rename from demos/declarative/flickr/mobile/Button.qml rename to demos/declarative/flickr/content/Button.qml index 539011552a..7285753a0a 100644 --- a/demos/declarative/flickr/mobile/Button.qml +++ b/demos/declarative/flickr/content/Button.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 Item { id: container diff --git a/demos/declarative/flickr/mobile/GridDelegate.qml b/demos/declarative/flickr/content/GridDelegate.qml similarity index 99% rename from demos/declarative/flickr/mobile/GridDelegate.qml rename to demos/declarative/flickr/content/GridDelegate.qml index 06e0b853e1..5b7af23ea0 100644 --- a/demos/declarative/flickr/mobile/GridDelegate.qml +++ b/demos/declarative/flickr/content/GridDelegate.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 Item { id: wrapper; width: GridView.view.cellWidth; height: GridView.view.cellHeight diff --git a/demos/declarative/flickr/mobile/ImageDetails.qml b/demos/declarative/flickr/content/ImageDetails.qml similarity index 65% rename from demos/declarative/flickr/mobile/ImageDetails.qml rename to demos/declarative/flickr/content/ImageDetails.qml index 1f49160603..62c3397f08 100644 --- a/demos/declarative/flickr/mobile/ImageDetails.qml +++ b/demos/declarative/flickr/content/ImageDetails.qml @@ -39,8 +39,8 @@ ** ****************************************************************************/ -import QtQuick 1.0 -import "../common" as Common +import QtQuick 2.0 +import Qt.labs.particles 2.0 Flipable { id: container @@ -95,7 +95,7 @@ Flipable { Rectangle { anchors.fill: parent; color: "black"; opacity: 0.4 } - Common.Progress { + Progress { anchors.centerIn: parent; width: 200; height: 22 progress: bigImage.progress; visible: bigImage.status != Image.Ready } @@ -126,7 +126,6 @@ Flipable { id: imageContainer width: Math.max(bigImage.width * bigImage.scale, flickable.width); height: Math.max(bigImage.height * bigImage.scale, flickable.height); - Image { id: bigImage; source: container.photoUrl; scale: slider.value anchors.centerIn: parent; smooth: !flickable.movingVertically @@ -137,7 +136,96 @@ Flipable { prevScale = Math.min(slider.minimum, 1); slider.value = prevScale; } + if (inBackState && bigImage.status == Image.Ready) + particleBox.imageInAnim(); + } + property bool inBackState: false + onInBackStateChanged:{ + if(inBackState && bigImage.status == Image.Ready) + particleBox.imageInAnim(); + else if (!inBackState && bigImage.status == Image.Ready) + particleBox.imageOutAnim(); + } + } + + Item{ + id: particleBox + width: bigImage.width * bigImage.scale + height: bigImage.height * bigImage.scale + anchors.centerIn: parent + + function imageInAnim(){ + cp.visible = true; + pixAffect.onceOff = false; + bigImage.visible = false; + endEffectTimer.start(); + pixelEmitter.pulse(1); + } + function imageOutAnim(){ + cp.visible = true; + pixAffect.onceOff = true; + bigImage.visible = false; + turbulence.active = true; + endEffectTimer.start(); + pixelEmitter.burst(2048); + } + Timer{ + id: endEffectTimer + interval: 1000 + repeat: false + running: false + onTriggered:{ + bigImage.visible = true; + turbulence.active = false; + cp.visible = false; + } + } + ParticleSystem{ + id: imageSystem + } + ColoredParticle{ + id: cp + system: imageSystem + color: "gray" + alpha: 1 + image: "images/squareParticle.png" + colorVariation: 0 + } + Picture{ + id: pixAffect + system: imageSystem + anchors.fill: parent + image: container.photoUrl; + onceOff: true } + Turbulence{ + id: turbulence + system: imageSystem + anchors.fill: parent + frequency: 100 + strength: 250 + active: false + } + TrailEmitter{ + id: pixelEmitter0 + system: imageSystem + height: parent.height + particleSize: 4 + particleDuration: 1000 + particlesPerSecond: 4096 + speed: PointVector{x: 360; xVariation: 8; yVariation: 4} + emitting: false + } + TrailEmitter{ + id: pixelEmitter + system: imageSystem + anchors.fill: parent + particleSize: 4 + particleDuration: 1000 + particlesPerSecond: 2048 + emitting: false + } + } } } @@ -148,7 +236,7 @@ Flipable { anchors.centerIn: parent; color: "white"; font.bold: true } - Common.Slider { + Slider { id: slider; visible: { bigImage.status == Image.Ready && maximum > minimum } anchors { bottom: parent.bottom; bottomMargin: 65 @@ -174,12 +262,13 @@ Flipable { PropertyChanges { target: itemRotation; angle: 180 } PropertyChanges { target: toolBar; button2Visible: false } PropertyChanges { target: toolBar; button1Label: "Back" } + PropertyChanges { target: bigImage; inBackState: true } } transitions: Transition { SequentialAnimation { PropertyAction { target: bigImage; property: "smooth"; value: false } - NumberAnimation { easing.type: Easing.InOutQuad; properties: "angle"; duration: 500 } + NumberAnimation { easing.type: Easing.InOutQuad; properties: "angle"; duration: 1000 } PropertyAction { target: bigImage; property: "smooth"; value: !flickable.movingVertically } } } diff --git a/demos/declarative/flickr/mobile/ListDelegate.qml b/demos/declarative/flickr/content/ListDelegate.qml similarity index 99% rename from demos/declarative/flickr/mobile/ListDelegate.qml rename to demos/declarative/flickr/content/ListDelegate.qml index 89dfb54db8..b65704867b 100644 --- a/demos/declarative/flickr/mobile/ListDelegate.qml +++ b/demos/declarative/flickr/content/ListDelegate.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 Component { Item { diff --git a/demos/declarative/flickr/common/Progress.qml b/demos/declarative/flickr/content/Progress.qml similarity index 74% rename from demos/declarative/flickr/common/Progress.qml rename to demos/declarative/flickr/content/Progress.qml index 2bb4f1a9c1..d403feebd1 100644 --- a/demos/declarative/flickr/common/Progress.qml +++ b/demos/declarative/flickr/content/Progress.qml @@ -39,9 +39,11 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 +import Qt.labs.particles 2.0 -Item { +Item{ + id: container property variant progress: 0 Rectangle { @@ -53,21 +55,34 @@ Item { } } - Rectangle { + ParticleSystem{ + running: container.visible + id: barSys + } + ColoredParticle{ + color: "lightsteelblue" + alpha: 0.1 + colorVariation: 0.05 + image: "images/particle.png" + system: barSys + } + TrailEmitter{ y: 2; height: parent.height-4; x: 2; width: Math.max(parent.width * progress - 4, 0); - opacity: width < 1 ? 0 : 1; smooth: true - gradient: Gradient { - GradientStop { position: 0; color: "lightsteelblue" } - GradientStop { position: 1.0; color: "steelblue" } - } - radius: height/2 - 2 + speed: AngleVector{ angleVariation: 180; magnitudeVariation: 12 } + system: barSys + particlesPerSecond: width; + particleDuration: 1000 + particleSize: 20 + particleSizeVariation: 4 + particleEndSize: 12 + maxParticles: parent.width; } Text { text: Math.round(progress * 100) + "%" anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter - color: "white"; font.bold: true; font.pixelSize: 15 + color: Qt.rgba(1.0, 1.0 - progress, 1.0 - progress,0.9); font.bold: true; font.pixelSize: 15 } } diff --git a/demos/declarative/flickr/common/RssModel.qml b/demos/declarative/flickr/content/RssModel.qml similarity index 99% rename from demos/declarative/flickr/common/RssModel.qml rename to demos/declarative/flickr/content/RssModel.qml index 172fdf337f..007f086830 100644 --- a/demos/declarative/flickr/common/RssModel.qml +++ b/demos/declarative/flickr/content/RssModel.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 XmlListModel { property string tags : "" diff --git a/demos/declarative/flickr/common/ScrollBar.qml b/demos/declarative/flickr/content/ScrollBar.qml similarity index 99% rename from demos/declarative/flickr/common/ScrollBar.qml rename to demos/declarative/flickr/content/ScrollBar.qml index 1a9f6d8361..7d2d9ff7d3 100644 --- a/demos/declarative/flickr/common/ScrollBar.qml +++ b/demos/declarative/flickr/content/ScrollBar.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 Item { id: container diff --git a/demos/declarative/flickr/common/Slider.qml b/demos/declarative/flickr/content/Slider.qml similarity index 99% rename from demos/declarative/flickr/common/Slider.qml rename to demos/declarative/flickr/content/Slider.qml index 2d35ee499d..b4a2960ac8 100644 --- a/demos/declarative/flickr/common/Slider.qml +++ b/demos/declarative/flickr/content/Slider.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 Item { id: slider; width: 400; height: 16 diff --git a/demos/declarative/flickr/content/StreamView.qml b/demos/declarative/flickr/content/StreamView.qml new file mode 100644 index 0000000000..26384d3c07 --- /dev/null +++ b/demos/declarative/flickr/content/StreamView.qml @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import Qt.labs.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 + overwrite: false + } + 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 + TrailEmitter{ + system: sys + width: emitterSpacing - 64 + x: emitterSpacing*0 + 32 + y: -128 + height: 32 + speed: PointVector{ y: (container.height + 128)/12 } + particlesPerSecond: 0.4 + particleDuration: 1000000//eventually -1 should mean a million seconds for neatness + maxParticles: 15 + } + TrailEmitter{ + system: sys + width: emitterSpacing - 64 + x: emitterSpacing*1 + 32 + y: -128 + height: 32 + speed: PointVector{ y: (container.height + 128)/12 } + particlesPerSecond: 0.4 + particleDuration: 1000000//eventually -1 should mean a million seconds for neatness + maxParticles: 15 + } + TrailEmitter{ + system: sys + width: emitterSpacing - 64 + x: emitterSpacing*2 + 32 + y: -128 + height: 32 + speed: PointVector{ y: (container.height + 128)/12 } + particlesPerSecond: 0.4 + particleDuration: 1000000//eventually -1 should mean a million seconds for neatness + maxParticles: 15 + } + Kill{ + system: sys + y: container.height + 64 + width: container.width + height: 6400 + } +} diff --git a/demos/declarative/flickr/mobile/TitleBar.qml b/demos/declarative/flickr/content/TitleBar.qml similarity index 99% rename from demos/declarative/flickr/mobile/TitleBar.qml rename to demos/declarative/flickr/content/TitleBar.qml index ec5a5c0710..381d252ed3 100644 --- a/demos/declarative/flickr/mobile/TitleBar.qml +++ b/demos/declarative/flickr/content/TitleBar.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 Item { id: titleBar diff --git a/demos/declarative/flickr/mobile/ToolBar.qml b/demos/declarative/flickr/content/ToolBar.qml similarity index 99% rename from demos/declarative/flickr/mobile/ToolBar.qml rename to demos/declarative/flickr/content/ToolBar.qml index 24126125c8..ca5341e101 100644 --- a/demos/declarative/flickr/mobile/ToolBar.qml +++ b/demos/declarative/flickr/content/ToolBar.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 Item { id: toolbar diff --git a/demos/declarative/flickr/content/UnifiedDelegate.qml b/demos/declarative/flickr/content/UnifiedDelegate.qml new file mode 100644 index 0000000000..aaf4ccbd7a --- /dev/null +++ b/demos/declarative/flickr/content/UnifiedDelegate.qml @@ -0,0 +1,162 @@ +/**************************************************************************** +** +** 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import Qt.labs.particles 2.0 + +Package { + function photoClicked() { + imageDetails.photoTitle = title; + imageDetails.photoTags = tags; + imageDetails.photoWidth = photoWidth; + imageDetails.photoHeight = photoHeight; + imageDetails.photoType = photoType; + imageDetails.photoAuthor = photoAuthor; + imageDetails.photoDate = photoDate; + imageDetails.photoUrl = url; + imageDetails.rating = 0; + scaleMe.state = "Details"; + } + + Item { + id: gridwrapper; + width: GridView.view.cellWidth; height: GridView.view.cellHeight + Package.name: "grid" + } + Item { + 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 :( + width: 80; height: 80 + scale: 0.0 + Behavior on scale { NumberAnimation { easing.type: Easing.InOutQuad} } + id: scaleMe + + Item { + id: whiteRectContainer + width: 77; height: 77; anchors.centerIn: parent + Rectangle { + id: whiteRect; width: 77; height: 77; color: "#dddddd"; smooth: true + x:0; y:0 + Image { id: thumb; source: imagePath; x: 1; y: 1; smooth: true } + Image { source: "images/gloss.png" } + MouseArea { anchors.fill: parent; onClicked: photoClicked() } + } + } + + Connections { + target: toolBar + onButton2Clicked: if (scaleMe.state == 'Details' ) scaleMe.state = 'Show' + } + + state: 'inStream' + states: [ + State { + name: "Show"; when: thumb.status == Image.Ready + PropertyChanges { target: scaleMe; scale: 1; } + }, + State { + name: "Details" + PropertyChanges { target: scaleMe; scale: 1 } + ParentChange { target: whiteRect; x: 10; y: 20; parent: imageDetails.frontContainer } + PropertyChanges { target: background; state: "DetailedView" } + } + ] + transitions: [ + Transition { + from: "Show"; to: "Details" + ScriptAction{ script: streamwrapper.pleaseFreeze(); } + ParentAnimation { + via: foreground + NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad } + } + }, + Transition { + from: "Details"; to: "Show" + SequentialAnimation{ + ParentAnimation { + via: foreground + NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad } + } + ScriptAction{ script: streamwrapper.pleaseUnfreeze(); } + } + } + ] + Item{ + id: stateContainer + states: [ + State { + name: 'inStream' + when: screen.inGridView == false + ParentChange { + target: scaleMe; parent: streamwrapper + x: 0; y: 0; + } + }, + State { + name: 'inGrid' + when: screen.inGridView == true + ParentChange { + target: scaleMe; parent: gridwrapper + x: 0; y: 0; + } + } + ] + + transitions: [ + Transition { + ParentAnimation { + NumberAnimation { target: scaleMe; properties: 'x,y,width,height'; duration: 300 } + } + } + ] + } + } +} diff --git a/demos/declarative/flickr/mobile/images/gloss.png b/demos/declarative/flickr/content/images/gloss.png similarity index 100% rename from demos/declarative/flickr/mobile/images/gloss.png rename to demos/declarative/flickr/content/images/gloss.png diff --git a/demos/declarative/flickr/mobile/images/lineedit.png b/demos/declarative/flickr/content/images/lineedit.png similarity index 100% rename from demos/declarative/flickr/mobile/images/lineedit.png rename to demos/declarative/flickr/content/images/lineedit.png diff --git a/demos/declarative/flickr/mobile/images/lineedit.sci b/demos/declarative/flickr/content/images/lineedit.sci similarity index 100% rename from demos/declarative/flickr/mobile/images/lineedit.sci rename to demos/declarative/flickr/content/images/lineedit.sci diff --git a/demos/declarative/flickr/content/images/particle.png b/demos/declarative/flickr/content/images/particle.png new file mode 100644 index 0000000000000000000000000000000000000000..dbc39cb16eec43d80546f79ade596d2b0bf5bc3e GIT binary patch literal 5148 zcmeHL`8$+t-@lB(&?x(sWg3(UGsD;hS!TwTWek;_VaAeW#u$4TYnDiEm2PE8Bq~!x zRF<+Qv{59oR2ou|eR;T_yZd>6czgeW_c@Q_y3X@^9-q(WyB^1N99J5_+LWJ9iVpw) zeseP%aeHU(JP^+9_rln@mF-QEfp=ioQN0=ABsv8!B2zsnF!Ml?4~0k}kt2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O17%n(qmlAttachedPropertiesObject(m_items[pos])); - if(mpa) - qDebug() << (mpa->m_mp = this); - else - qDebug() << "Bugger"; if(m_pendingItems.isEmpty()){ m_items[pos] = m_model->item(m_available.first()); m_idx[pos] = m_available.first(); m_available.pop_front(); + ModelParticleAttached* mpa = qobject_cast(qmlAttachedPropertiesObject(m_items[pos])); + if(mpa){ + mpa->m_mp = this; + mpa->attach(); + } }else{ m_items[pos] = m_pendingItems.front(); m_pendingItems.pop_front(); m_items[pos]->setX(d->curX() - m_items[pos]->width()/2); m_items[pos]->setY(d->curY() - m_items[pos]->height()/2); - if(mpa) - mpa->attach(); m_idx[pos] = -2; + ModelParticleAttached* mpa = qobject_cast(qmlAttachedPropertiesObject(m_items[pos])); + if(mpa){ + mpa->m_mp = this; + mpa->attach(); + } } m_items[pos]->setParentItem(this); m_data[pos] = d; diff --git a/src/imports/particles/particles.pro b/src/imports/particles/particles.pro index 6eea892f83..56474b4b37 100644 --- a/src/imports/particles/particles.pro +++ b/src/imports/particles/particles.pro @@ -48,7 +48,7 @@ HEADERS += \ deformableparticle.h \ pictureaffector.h -QT += core-private gui-private declarative-private +QT += core-private gui-private declarative-private script-private SOURCES += \ V1/qdeclarativeparticles.cpp \ diff --git a/src/imports/particles/particlesystem.cpp b/src/imports/particles/particlesystem.cpp index 854d512630..f89eda4aaf 100644 --- a/src/imports/particles/particlesystem.cpp +++ b/src/imports/particles/particlesystem.cpp @@ -206,6 +206,8 @@ void ParticleSystem::reset() initializeSystem(); foreach(ParticleType* p, m_particles) p->update(); + foreach(ParticleEmitter* e, m_emitters) + e->emitWindow(0);//Start, so that starttime factors appropriately } ParticleData* ParticleSystem::newDatum(int groupId) diff --git a/src/imports/particles/particlesystem.h b/src/imports/particles/particlesystem.h index 896f215bfc..fc5575d3a7 100644 --- a/src/imports/particles/particlesystem.h +++ b/src/imports/particles/particlesystem.h @@ -118,6 +118,11 @@ emit overwriteChanged(arg); } } +void fastForward(int ms) +{ + m_startTime += ms; +} + protected: void componentComplete(); diff --git a/src/imports/particles/pictureaffector.cpp b/src/imports/particles/pictureaffector.cpp index c05a553f39..d684b3fd80 100644 --- a/src/imports/particles/pictureaffector.cpp +++ b/src/imports/particles/pictureaffector.cpp @@ -42,11 +42,13 @@ #include "pictureaffector.h" #include "coloredparticle.h" #include +#include +#include QT_BEGIN_NAMESPACE PictureAffector::PictureAffector(QSGItem *parent) : - ParticleAffector(parent) + ParticleAffector(parent), m_pix(0) { m_needsReset = true; } @@ -56,6 +58,27 @@ void PictureAffector::reset(int systemIdx) ParticleAffector::reset(systemIdx); } +void PictureAffector::startLoadImage() +{ + if(m_pix) + m_pix->clear(); + else + m_pix = new QDeclarativePixmap(); + m_pix->load(qmlEngine(this), m_image, QDeclarativePixmap::Cache); + if(m_pix->isReady()) + loadImage(); + else + m_pix->connectFinished(this, SLOT(loadImage())); +} +void PictureAffector::loadImage() +{ + QSGPlainTexture* ptext = qobject_cast(m_pix->texture()); + if(ptext) + m_loadedImage = ptext->image(); + if(m_loadedImage.isNull()) + qWarning() << "PictureAffector could not load picture " << m_image; +} + bool PictureAffector::affectParticle(ParticleData *d, qreal dt) { Q_UNUSED(dt); @@ -74,7 +97,7 @@ bool PictureAffector::affectParticle(ParticleData *d, qreal dt) QPoint pos = QPoint(d->curX() - m_offset.x(), d->curY() - m_offset.y()); if(!QRect(0,0,width(),height()).contains(pos)){ //XXX: Just a debugging helper, as I don't think it can get here. - qWarning() << "An unexpected situation has occurred. But don't worry, everything will be fine."; + qWarning() << "PictureAffector gives up."; return false; } Color4ub c; diff --git a/src/imports/particles/pictureaffector.h b/src/imports/particles/pictureaffector.h index ca7d13f477..4e0141d00a 100644 --- a/src/imports/particles/pictureaffector.h +++ b/src/imports/particles/pictureaffector.h @@ -50,12 +50,12 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) +class QDeclarativePixmap; class PictureAffector : public ParticleAffector { Q_OBJECT //Usually want to use "particles" to target just colored stuff, and save performance //Use onceOff (inherited) to determine if this is an emitter modification or a more constant enforcer - //TODO: Onceoff isn't actually working right now... Q_PROPERTY(QUrl image READ image WRITE setImage NOTIFY imageChanged) //TODO: Bool smooth, where it interpolates public: @@ -78,15 +78,17 @@ public slots: { if (m_image != arg) { m_image = arg; - m_loadedImage = QImage(m_image.toLocalFile()); - if(m_loadedImage.isNull()) - qWarning() << "PictureAffector could not load picture " << m_image.toLocalFile(); + startLoadImage(); emit imageChanged(arg); } } +private slots: + void loadImage(); private: + void startLoadImage(); QUrl m_image; + QDeclarativePixmap* m_pix; QImage m_loadedImage; };