summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar.sletta@nokia.com>2010-12-21 07:23:30 +0100
committerGunnar Sletta <gunnar.sletta@nokia.com>2010-12-21 07:23:30 +0100
commit4092945f09a12b53b545658cfa580f793864d2d9 (patch)
tree6895c4ab749ab0ac80caac58010db9e62bcbb3e1
parentc76e057dee1cf7033804ff5e2024a533ffa4be73 (diff)
parent45a3003c939f3c0cd1fbfbe4e26c828bb3c8c7e7 (diff)
Merge branch 'master' of scm.dev.nokia.troll.no:research/qt-scene-graph
-rw-r--r--src/canvas/qvsyncanimationdriver.cpp3
-rw-r--r--src/canvas/qvsyncanimationdriver_p.h2
-rw-r--r--src/effects/shadereffectitem.cpp64
-rw-r--r--src/effects/shadereffectitem.h48
-rw-r--r--src/graphicsitems/qxfocusscope_p.h2
-rw-r--r--src/graphicsitems/qxitem.h6
-rw-r--r--src/scenegraph/coreapi/material.h2
-rw-r--r--src/scenegraph/coreapi/node.h4
-rw-r--r--src/scenegraph/coreapi/qsgcontext.h2
-rw-r--r--src/scenegraph/coreapi/renderer.cpp4
-rw-r--r--src/scenegraph/coreapi/renderer.h2
-rw-r--r--tests/effects.qml155
12 files changed, 228 insertions, 66 deletions
diff --git a/src/canvas/qvsyncanimationdriver.cpp b/src/canvas/qvsyncanimationdriver.cpp
index dd84dd3..ff4e63d 100644
--- a/src/canvas/qvsyncanimationdriver.cpp
+++ b/src/canvas/qvsyncanimationdriver.cpp
@@ -1,6 +1,7 @@
#include "qvsyncanimationdriver_p.h"
#include "private/qabstractanimation_p.h"
+#include <private/qthread_p.h>
#include <QtGui/qevent.h>
#include <QtGui/qwidget.h>
@@ -68,7 +69,7 @@ bool QVSyncAnimationDriver::event(QEvent *e)
Q_D(QVSyncAnimationDriver);
if (e->type() == QEvent::User + 1) {
- while (isRunning() && !d->aborted) {
+ while (isRunning() && !d->aborted && !d->threadData->quitNow) {
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
QApplication::processEvents(QEventLoop::AllEvents, 1);
advance();
diff --git a/src/canvas/qvsyncanimationdriver_p.h b/src/canvas/qvsyncanimationdriver_p.h
index c1b92b8..8e8eb3e 100644
--- a/src/canvas/qvsyncanimationdriver_p.h
+++ b/src/canvas/qvsyncanimationdriver_p.h
@@ -9,7 +9,7 @@ class QVSyncAnimationDriver : public QAnimationDriver
{
Q_OBJECT
- Q_DECLARE_PRIVATE(QVSyncAnimationDriver);
+ Q_DECLARE_PRIVATE(QVSyncAnimationDriver)
public:
QVSyncAnimationDriver(QObject *parent = 0);
diff --git a/src/effects/shadereffectitem.cpp b/src/effects/shadereffectitem.cpp
index fe53cb9..de5bd83 100644
--- a/src/effects/shadereffectitem.cpp
+++ b/src/effects/shadereffectitem.cpp
@@ -181,7 +181,6 @@ ShaderEffectSource::ShaderEffectSource(QObject *parent)
, m_verticalWrap(ClampToEdge)
, m_margins(0, 0)
, m_size(0, 0)
- , m_static(false)
, m_fbo(0)
, m_multisampledFbo(0)
, m_renderer(0)
@@ -190,6 +189,8 @@ ShaderEffectSource::ShaderEffectSource(QObject *parent)
, m_dirtySceneGraph(true)
, m_multisamplingSupported(false)
, m_checkedForMultisamplingSupport(false)
+ , m_static(false)
+ , m_hideOriginal(true)
{
m_context = QSGContext::current;
}
@@ -211,7 +212,7 @@ void ShaderEffectSource::setSourceItem(QxItem *item)
if (m_sourceItem) {
disconnect(m_sourceItem, SIGNAL(widthChanged()), this, SLOT(markSourceSizeDirty()));
disconnect(m_sourceItem, SIGNAL(heightChanged()), this, SLOT(markSourceSizeDirty()));
- if (m_refs) {
+ if (m_refs && m_hideOriginal) {
Q_ASSERT(m_renderer);
QxItemPrivate *d = QxItemPrivate::get(m_sourceItem);
d->derefFromEffectItem();
@@ -227,7 +228,7 @@ void ShaderEffectSource::setSourceItem(QxItem *item)
}
if (m_sourceItem) {
- if (m_refs) {
+ if (m_refs && m_hideOriginal) {
Q_ASSERT(m_renderer);
QxItemPrivate *d = QxItemPrivate::get(m_sourceItem);
d->refFromEffectItem();
@@ -263,13 +264,12 @@ void ShaderEffectSource::setMipmap(FilterMode mode)
Q_ASSERT(m_sourceItem);
delete m_fbo;
m_fbo = 0;
+ m_dirtyTexture = true;
} else if (!m_texture.isNull()) {
Q_ASSERT(!m_sourceImage.isEmpty());
- if (!m_texture->hasMipmaps()) {
+ if (!m_texture->hasMipmaps())
updateSizeAndTexture();
- }
}
- m_dirtyTexture = true;
}
emit mipmapChanged();
emit repaintRequired();
@@ -331,6 +331,31 @@ void ShaderEffectSource::setStatic(bool s)
emit repaintRequired();
}
+void ShaderEffectSource::setHideOriginal(bool hide)
+{
+ if (hide == m_hideOriginal)
+ return;
+
+ if (m_refs && m_sourceItem && m_hideOriginal) {
+ Q_ASSERT(m_renderer);
+ m_renderer->setRootNode(0);
+ QxItemPrivate *d = QxItemPrivate::get(m_sourceItem);
+ d->derefFromEffectItem();
+ }
+
+ m_hideOriginal = hide;
+
+ if (m_refs && m_sourceItem && m_hideOriginal) {
+ Q_ASSERT(m_renderer);
+ QxItemPrivate *d = QxItemPrivate::get(m_sourceItem);
+ d->refFromEffectItem();
+ m_renderer->setRootNode(d->rootNode);
+ }
+
+ emit hideOriginalChanged();
+ emit repaintRequired();
+}
+
void ShaderEffectSource::bind() const
{
bool linear = m_filtering == Linear;
@@ -371,7 +396,7 @@ void ShaderEffectSource::bind() const
void ShaderEffectSource::refFromEffectItem()
{
if (m_refs++ == 0) {
- if (m_sourceItem) {
+ if (m_sourceItem && m_hideOriginal) {
Q_ASSERT(m_renderer);
QxItemPrivate *d = QxItemPrivate::get(m_sourceItem);
d->refFromEffectItem();
@@ -384,7 +409,7 @@ void ShaderEffectSource::refFromEffectItem()
void ShaderEffectSource::derefFromEffectItem()
{
if (--m_refs == 0) {
- if (m_sourceItem) {
+ if (m_sourceItem && m_hideOriginal) {
Q_ASSERT(m_renderer);
m_renderer->setRootNode(0);
QxItemPrivate *d = QxItemPrivate::get(m_sourceItem);
@@ -398,10 +423,16 @@ void ShaderEffectSource::derefFromEffectItem()
void ShaderEffectSource::update()
{
Q_ASSERT(m_refs);
- if (!m_dirtyTexture && (!m_dirtySceneGraph || m_static))
+ QxItemPrivate *src = m_sourceItem ? QxItemPrivate::get(m_sourceItem) : 0;
+ Node::DirtyFlags dirtyFlags = src ? src->transformNode.dirtyFlags() : Node::DirtyFlags(0);
+ if (!m_dirtyTexture && (!(m_dirtySceneGraph || dirtyFlags) || m_static))
return;
if (m_sourceItem) {
- QxItemPrivate *src = QxItemPrivate::get(m_sourceItem);
+ Q_ASSERT(m_hideOriginal == (m_renderer->rootNode() != 0));
+ if (!m_hideOriginal) {
+ src->refFromEffectItem();
+ m_renderer->setRootNode(src->rootNode);
+ }
Q_ASSERT(src->rootNode && src->rootNode == m_renderer->rootNode());
Q_ASSERT(m_renderer);
@@ -458,11 +489,24 @@ void ShaderEffectSource::update()
glBindTexture(GL_TEXTURE_2D, m_fbo->texture());
m_context->renderer()->glGenerateMipmap(GL_TEXTURE_2D);
}
+
+ if (!m_hideOriginal) {
+ m_renderer->setRootNode(0);
+ src->derefFromEffectItem();
+ src->transformNode.markDirty(dirtyFlags);
+ }
+
m_dirtySceneGraph = false;
}
m_dirtyTexture = false;
}
+void ShaderEffectSource::grab()
+{
+ m_dirtyTexture = true;
+ emit repaintRequired();
+}
+
void ShaderEffectSource::markSceneGraphDirty()
{
m_dirtySceneGraph = true;
diff --git a/src/effects/shadereffectitem.h b/src/effects/shadereffectitem.h
index 6fd7415..1aa5c5c 100644
--- a/src/effects/shadereffectitem.h
+++ b/src/effects/shadereffectitem.h
@@ -59,20 +59,21 @@ class QGLFramebufferObject;
class ShaderEffectSource : public QObject
{
Q_OBJECT
- Q_PROPERTY(QxItem *sourceItem READ sourceItem WRITE setSourceItem NOTIFY sourceItemChanged);
- Q_PROPERTY(QUrl sourceImage READ sourceImage WRITE setSourceImage NOTIFY sourceImageChanged);
- Q_PROPERTY(FilterMode mipmap READ mipmap WRITE setMipmap NOTIFY mipmapChanged);
- Q_PROPERTY(FilterMode filtering READ filtering WRITE setFiltering NOTIFY filteringChanged);
- Q_PROPERTY(WrapMode horizontalWrap READ horizontalWrap WRITE setHorizontalWrap NOTIFY horizontalWrapChanged);
- Q_PROPERTY(WrapMode verticalWrap READ verticalWrap WRITE setVerticalWrap NOTIFY verticalWrapChanged);
- Q_PROPERTY(QSize margins READ margins WRITE setMargins NOTIFY marginsChanged);
- Q_PROPERTY(QSize textureSize READ textureSize WRITE setTextureSize NOTIFY textureSizeChanged);
- Q_PROPERTY(int width READ width NOTIFY widthChanged);
- Q_PROPERTY(int height READ height NOTIFY heightChanged);
- Q_PROPERTY(bool static READ isStatic WRITE setStatic NOTIFY staticChanged);
- Q_PROPERTY(bool active READ isActive NOTIFY activeChanged);
- Q_ENUMS(FilterMode);
- Q_ENUMS(WrapMode);
+ Q_PROPERTY(QxItem *sourceItem READ sourceItem WRITE setSourceItem NOTIFY sourceItemChanged)
+ Q_PROPERTY(QUrl sourceImage READ sourceImage WRITE setSourceImage NOTIFY sourceImageChanged)
+ Q_PROPERTY(FilterMode mipmap READ mipmap WRITE setMipmap NOTIFY mipmapChanged)
+ Q_PROPERTY(FilterMode filtering READ filtering WRITE setFiltering NOTIFY filteringChanged)
+ Q_PROPERTY(WrapMode horizontalWrap READ horizontalWrap WRITE setHorizontalWrap NOTIFY horizontalWrapChanged)
+ Q_PROPERTY(WrapMode verticalWrap READ verticalWrap WRITE setVerticalWrap NOTIFY verticalWrapChanged)
+ Q_PROPERTY(QSize margins READ margins WRITE setMargins NOTIFY marginsChanged)
+ Q_PROPERTY(QSize textureSize READ textureSize WRITE setTextureSize NOTIFY textureSizeChanged)
+ Q_PROPERTY(int width READ width NOTIFY widthChanged)
+ Q_PROPERTY(int height READ height NOTIFY heightChanged)
+ Q_PROPERTY(bool static READ isStatic WRITE setStatic NOTIFY staticChanged)
+ Q_PROPERTY(bool hideOriginal READ hideOriginal WRITE setHideOriginal NOTIFY hideOriginalChanged)
+ Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)
+ Q_ENUMS(FilterMode)
+ Q_ENUMS(WrapMode)
public:
enum FilterMode
@@ -124,6 +125,9 @@ public:
bool isStatic() const { return m_static; }
void setStatic(bool s);
+ bool hideOriginal() const { return m_hideOriginal; }
+ void setHideOriginal(bool hide);
+
bool isActive() const { return m_refs; }
void bind() const;
@@ -132,6 +136,8 @@ public:
void derefFromEffectItem();
void update();
+ Q_INVOKABLE void grab();
+
Q_SIGNALS:
void sourceItemChanged();
void sourceImageChanged();
@@ -144,6 +150,7 @@ Q_SIGNALS:
void widthChanged();
void heightChanged();
void staticChanged();
+ void hideOriginalChanged();
void activeChanged();
void repaintRequired();
@@ -164,7 +171,6 @@ private:
QSize m_margins;
QSize m_textureSize;
QSize m_size;
- bool m_static;
QSGTextureRef m_texture;
QGLFramebufferObject *m_fbo;
@@ -176,6 +182,8 @@ private:
uint m_dirtySceneGraph : 1; // Causes update if not static.
uint m_multisamplingSupported : 1;
uint m_checkedForMultisamplingSupport : 1;
+ uint m_static : 1;
+ uint m_hideOriginal : 1;
};
class ShaderEffectNode : public GeometryNode
@@ -206,11 +214,11 @@ private:
class ShaderEffectItem : public QxItem, public AbstractEffect
{
Q_OBJECT
- Q_PROPERTY(QString fragmentShader READ fragmentShader WRITE setFragmentShader NOTIFY fragmentShaderChanged);
- Q_PROPERTY(QString vertexShader READ vertexShader WRITE setVertexShader NOTIFY vertexShaderChanged);
- Q_PROPERTY(bool blending READ blending WRITE setBlending NOTIFY blendingChanged);
- Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged);
- Q_PROPERTY(QSize meshResolution READ meshResolution WRITE setMeshResolution NOTIFY meshResolutionChanged);
+ Q_PROPERTY(QString fragmentShader READ fragmentShader WRITE setFragmentShader NOTIFY fragmentShaderChanged)
+ Q_PROPERTY(QString vertexShader READ vertexShader WRITE setVertexShader NOTIFY vertexShaderChanged)
+ Q_PROPERTY(bool blending READ blending WRITE setBlending NOTIFY blendingChanged)
+ Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged)
+ Q_PROPERTY(QSize meshResolution READ meshResolution WRITE setMeshResolution NOTIFY meshResolutionChanged)
public:
ShaderEffectItem(QxItem *parent = 0);
diff --git a/src/graphicsitems/qxfocusscope_p.h b/src/graphicsitems/qxfocusscope_p.h
index 4dabf62..60483e1 100644
--- a/src/graphicsitems/qxfocusscope_p.h
+++ b/src/graphicsitems/qxfocusscope_p.h
@@ -54,7 +54,7 @@ public:
private:
Q_DISABLE_COPY(QxFocusScope)
- Q_DECLARE_PRIVATE(QxItem);
+ Q_DECLARE_PRIVATE(QxItem)
};
QML_DECLARE_TYPE(QxFocusScope)
diff --git a/src/graphicsitems/qxitem.h b/src/graphicsitems/qxitem.h
index 818458f..0345023 100644
--- a/src/graphicsitems/qxitem.h
+++ b/src/graphicsitems/qxitem.h
@@ -76,8 +76,8 @@ class QT_SCENEGRAPH_EXPORT QxItem : public QObject, public QDeclarativeParserSta
Q_PROPERTY(qreal rotation READ rotation WRITE setRotation NOTIFY rotationChanged)
Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged RESET resetWidth FINAL)
Q_PROPERTY(qreal height READ height WRITE setHeight NOTIFY heightChanged RESET resetHeight FINAL)
- Q_PROPERTY(bool clip READ clip WRITE setClip NOTIFY clipChanged);
- Q_PROPERTY(QDeclarativeListProperty<QxItem> children READ children);
+ Q_PROPERTY(bool clip READ clip WRITE setClip NOTIFY clipChanged)
+ Q_PROPERTY(QDeclarativeListProperty<QxItem> children READ children)
Q_PROPERTY(TransformOrigin transformOrigin READ transformOrigin WRITE setTransformOrigin NOTIFY transformOriginChanged)
Q_PROPERTY(QDeclarativeListProperty<QGraphicsTransform> transform READ transformations DESIGNABLE false FINAL)
Q_PROPERTY(QxItem *parent READ parentItem WRITE setParentItem NOTIFY parentChanged DESIGNABLE false FINAL)
@@ -101,7 +101,7 @@ class QT_SCENEGRAPH_EXPORT QxItem : public QObject, public QDeclarativeParserSta
Q_PROPERTY(bool smooth READ smooth WRITE setSmooth NOTIFY smoothChanged)
// We might remove this property later.
- Q_PROPERTY(bool childrenDoNotOverlap READ childrenDoNotOverlap WRITE setChildrenDoNotOverlap NOTIFY childrenDoNotOverlapChanged);
+ Q_PROPERTY(bool childrenDoNotOverlap READ childrenDoNotOverlap WRITE setChildrenDoNotOverlap NOTIFY childrenDoNotOverlapChanged)
Q_ENUMS(TransformOrigin)
Q_CLASSINFO("DefaultProperty", "data")
diff --git a/src/scenegraph/coreapi/material.h b/src/scenegraph/coreapi/material.h
index aff14f8..70ecf6f 100644
--- a/src/scenegraph/coreapi/material.h
+++ b/src/scenegraph/coreapi/material.h
@@ -99,7 +99,7 @@ public:
Blending = 0x0001,
SupportsPicking = 0x0002
};
- Q_DECLARE_FLAGS(Flags, Flag);
+ Q_DECLARE_FLAGS(Flags, Flag)
virtual AbstractEffectType *type() const = 0;
virtual AbstractEffectProgram *createProgram() const = 0;
diff --git a/src/scenegraph/coreapi/node.h b/src/scenegraph/coreapi/node.h
index 247710e..43365d8 100644
--- a/src/scenegraph/coreapi/node.h
+++ b/src/scenegraph/coreapi/node.h
@@ -97,7 +97,7 @@ public:
// DirtyRenderOrderSubtree = DirtyRenderOrder << 16,
// DirtyAllSubtree = 0xffff0000
};
- Q_DECLARE_FLAGS(DirtyFlags, DirtyFlag);
+ Q_DECLARE_FLAGS(DirtyFlags, DirtyFlag)
enum Flag {
OwnedByParent = 0x0001,
@@ -105,7 +105,7 @@ public:
ChildrenDoNotOverloap = 0x0004,
ClipIsRectangular = 0x0008
};
- Q_DECLARE_FLAGS(Flags, Flag);
+ Q_DECLARE_FLAGS(Flags, Flag)
enum NodeSubType {
DefaultNodeSubType,
diff --git a/src/scenegraph/coreapi/qsgcontext.h b/src/scenegraph/coreapi/qsgcontext.h
index afdb34b..a5b0ebc 100644
--- a/src/scenegraph/coreapi/qsgcontext.h
+++ b/src/scenegraph/coreapi/qsgcontext.h
@@ -18,7 +18,7 @@ class QSGTextureManager;
class QT_SCENEGRAPH_EXPORT QSGContext : public QObject
{
Q_OBJECT
- Q_DECLARE_PRIVATE(QSGContext);
+ Q_DECLARE_PRIVATE(QSGContext)
public:
explicit QSGContext(QObject *parent = 0);
diff --git a/src/scenegraph/coreapi/renderer.cpp b/src/scenegraph/coreapi/renderer.cpp
index 8fa8da3..3b8bfa6 100644
--- a/src/scenegraph/coreapi/renderer.cpp
+++ b/src/scenegraph/coreapi/renderer.cpp
@@ -218,10 +218,10 @@ void Renderer::preprocess()
n->clearUpdateFlags();
}
- m_root_node->updateDirtyStates();
-
for (it = m_nodes_to_preprocess.begin(); it != m_nodes_to_preprocess.end(); ++it)
(*it)->preprocess();
+
+ m_root_node->updateDirtyStates();
}
void Renderer::addNodesToPreprocess(Node *node)
diff --git a/src/scenegraph/coreapi/renderer.h b/src/scenegraph/coreapi/renderer.h
index fc11a63..8da4010 100644
--- a/src/scenegraph/coreapi/renderer.h
+++ b/src/scenegraph/coreapi/renderer.h
@@ -92,7 +92,7 @@ public:
UpdateMaterials = 0x00000010,
UpdateAll = 0x7FFFFFFF
};
- Q_DECLARE_FLAGS(Updates, Update);
+ Q_DECLARE_FLAGS(Updates, Update)
enum ClipType
{
diff --git a/tests/effects.qml b/tests/effects.qml
index e55bb88..41d01d0 100644
--- a/tests/effects.qml
+++ b/tests/effects.qml
@@ -76,12 +76,17 @@ Rectangle {
onPressed: { drag.target.z = 1 }
onReleased: {
+ var effect = null
if (itemContains(effect1, mouse))
- effect1.source = effectSource1
+ effect = effect1
if (itemContains(effect2, mouse))
- effect2.source = effectSource1
+ effect = effect2
if (itemContains(effect3, mouse))
- effect3.source = effectSource1
+ effect = effect3
+ if (effect != null) {
+ effect.source = effectSource1
+ effect.active = true
+ }
drag.target.x = x
drag.target.y = y
drag.target.z = 0
@@ -117,6 +122,15 @@ Rectangle {
mipmap: controls.mipmap ? ShaderEffectSource.Linear : ShaderEffectSource.None
textureSize: Qt.size(effect1.width, effect1.height)
}
+ Text {
+ anchors.left: parent.left
+ anchors.top: parent.top
+ anchors.margins: 3
+ color: "red"
+ font.pixelSize: 12
+ text: effectSource1.hideOriginal ? "Hidden" : "Shown"
+ MouseArea { anchors.fill: parent; onClicked: { effectSource1.hideOriginal = !effectSource1.hideOriginal } }
+ }
}
MouseArea {
@@ -137,17 +151,22 @@ Rectangle {
onPressed: { drag.target.z = 1 }
onReleased: {
+ var effect = null
if (itemContains(effect1, mouse))
- effect1.source = effectSource2
+ effect = effect1
if (itemContains(effect2, mouse))
- effect2.source = effectSource2
+ effect = effect2
if (itemContains(effect3, mouse))
- effect3.source = effectSource2
+ effect = effect3
+ if (effect != null) {
+ effect.source = effectSource2
+ effect.active = true
+ }
drag.target.x = x
drag.target.y = y
drag.target.z = 0
}
- onClicked: { effectSource2.static = !effectSource2.static }
+ onClicked: { effectSource2.grab(); grabbedAnim2.restart() }
}
Item {
@@ -200,6 +219,30 @@ Rectangle {
color: "red"
font.pixelSize: 12
text: effectSource2.static ? "Static" : "Dynamic"
+ MouseArea { anchors.fill: parent; onClicked: { effectSource2.static = !effectSource2.static } }
+ }
+ Text {
+ anchors.left: parent.left
+ anchors.top: parent.top
+ anchors.margins: 3
+ color: "red"
+ font.pixelSize: 12
+ text: effectSource2.hideOriginal ? "Hidden" : "Shown"
+ MouseArea { anchors.fill: parent; onClicked: { effectSource2.hideOriginal = !effectSource2.hideOriginal } }
+ }
+ Text {
+ anchors.centerIn: parent
+ color: "red"
+ font.pixelSize: 12
+ text: "Grabbed"
+ opacity: 0
+ SequentialAnimation on opacity {
+ id: grabbedAnim2
+ running: false
+ PropertyAction { value: 1 }
+ PauseAnimation { duration: 1000 }
+ NumberAnimation { to: 0; duration: 1000 }
+ }
}
}
@@ -221,17 +264,22 @@ Rectangle {
onPressed: { drag.target.z = 1 }
onReleased: {
+ var effect = null
if (itemContains(effect1, mouse))
- effect1.source = effectSource3
+ effect = effect1
if (itemContains(effect2, mouse))
- effect2.source = effectSource3
+ effect = effect2
if (itemContains(effect3, mouse))
- effect3.source = effectSource3
+ effect = effect3
+ if (effect != null) {
+ effect.source = effectSource3
+ effect.active = true
+ }
drag.target.x = x
drag.target.y = y
drag.target.z = 0
}
- onClicked: { effectSource3.static = !effectSource3.static }
+ onClicked: { effectSource3.grab(); grabbedAnim3.restart() }
}
Item {
@@ -283,6 +331,30 @@ Rectangle {
color: "red"
font.pixelSize: 12
text: effectSource3.static ? "Static" : "Dynamic"
+ MouseArea { anchors.fill: parent; onClicked: { effectSource3.static = !effectSource3.static } }
+ }
+ Text {
+ anchors.left: parent.left
+ anchors.top: parent.top
+ anchors.margins: 3
+ color: "red"
+ font.pixelSize: 12
+ text: effectSource3.hideOriginal ? "Hidden" : "Shown"
+ MouseArea { anchors.fill: parent; onClicked: { effectSource3.hideOriginal = !effectSource3.hideOriginal } }
+ }
+ Text {
+ anchors.centerIn: parent
+ color: "red"
+ font.pixelSize: 12
+ text: "Grabbed"
+ opacity: 0
+ SequentialAnimation on opacity {
+ id: grabbedAnim3
+ running: false
+ PropertyAction { value: 1 }
+ PauseAnimation { duration: 1000 }
+ NumberAnimation { to: 0; duration: 1000 }
+ }
}
}
@@ -304,12 +376,17 @@ Rectangle {
onPressed: { drag.target.z = 1 }
onReleased: {
+ var effect = null
if (itemContains(effect1, mouse))
- effect1.source = effectSource4
+ effect = effect1
if (itemContains(effect2, mouse))
- effect2.source = effectSource4
+ effect = effect2
if (itemContains(effect3, mouse))
- effect3.source = effectSource4
+ effect = effect3
+ if (effect != null) {
+ effect.source = effectSource4
+ effect.active = true
+ }
drag.target.x = x
drag.target.y = y
drag.target.z = 0
@@ -328,7 +405,6 @@ Rectangle {
anchors.fill: parent
source: "qt-logo.png"
smooth: true
- visible: !effectSource4.active
}
ShaderEffectSource {
id: effectSource4
@@ -357,17 +433,22 @@ Rectangle {
onPressed: { drag.target.z = 1 }
onReleased: {
+ var effect = null
if (itemContains(effect1, mouse))
- effect1.source = effectSource5
+ effect = effect1
if (itemContains(effect2, mouse))
- effect2.source = effectSource5
+ effect = effect2
if (itemContains(effect3, mouse))
- effect3.source = effectSource5
+ effect = effect3
+ if (effect != null) {
+ effect.source = effectSource5
+ effect.active = true
+ }
drag.target.x = x
drag.target.y = y
drag.target.z = 0
}
- onClicked: { effectSource5.static = !effectSource5.static }
+ onClicked: { effectSource5.grab(); grabbedAnim5.restart() }
}
Item {
@@ -418,6 +499,30 @@ Rectangle {
color: "red"
font.pixelSize: 12
text: effectSource5.static ? "Static" : "Dynamic"
+ MouseArea { anchors.fill: parent; onClicked: { effectSource5.static = !effectSource5.static } }
+ }
+ Text {
+ anchors.left: parent.left
+ anchors.top: parent.top
+ anchors.margins: 3
+ color: "red"
+ font.pixelSize: 12
+ text: effectSource5.hideOriginal ? "Hidden" : "Shown"
+ MouseArea { anchors.fill: parent; onClicked: { effectSource5.hideOriginal = !effectSource5.hideOriginal } }
+ }
+ Text {
+ anchors.centerIn: parent
+ color: "red"
+ font.pixelSize: 12
+ text: "Grabbed"
+ opacity: 0
+ SequentialAnimation on opacity {
+ id: grabbedAnim5
+ running: false
+ PropertyAction { value: 1 }
+ PauseAnimation { duration: 1000 }
+ NumberAnimation { to: 0; duration: 1000 }
+ }
}
}
@@ -439,12 +544,17 @@ Rectangle {
onPressed: { drag.target.z = 1 }
onReleased: {
+ var effect = null
if (itemContains(effect1, mouse))
- effect1.source = effectSource6
+ effect = effect1
if (itemContains(effect2, mouse))
- effect2.source = effectSource6
+ effect = effect2
if (itemContains(effect3, mouse))
- effect3.source = effectSource6
+ effect = effect3
+ if (effect != null) {
+ effect.source = effectSource6
+ effect.active = true
+ }
drag.target.x = x
drag.target.y = y
drag.target.z = 0
@@ -463,7 +573,6 @@ Rectangle {
anchors.fill: parent
source: "face-smile.png"
smooth: true
- visible: !effectSource6.active
}
ShaderEffectSource {
id: effectSource6