summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-08-28 12:13:09 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-08-28 12:13:09 (GMT)
commite1dd37f6b54881aef3b9e1e686dc56bb96fc14ed (patch)
tree60edf1cbcf7c0af6be2af693ede84a04b9feae04
parent1a2a1418a201874b88afeb4d7fbe740b31376585 (diff)
downloadQt-e1dd37f6b54881aef3b9e1e686dc56bb96fc14ed.zip
Qt-e1dd37f6b54881aef3b9e1e686dc56bb96fc14ed.tar.gz
Qt-e1dd37f6b54881aef3b9e1e686dc56bb96fc14ed.tar.bz2
Add graphics effects support
-rw-r--r--examples/declarative/effects/pic.jpgbin0 -> 7016 bytes
-rw-r--r--examples/declarative/effects/test.qml75
-rw-r--r--src/declarative/fx/qfxitem.cpp21
-rw-r--r--src/declarative/fx/qfxitem.h1
4 files changed, 97 insertions, 0 deletions
diff --git a/examples/declarative/effects/pic.jpg b/examples/declarative/effects/pic.jpg
new file mode 100644
index 0000000..5775518
--- /dev/null
+++ b/examples/declarative/effects/pic.jpg
Binary files differ
diff --git a/examples/declarative/effects/test.qml b/examples/declarative/effects/test.qml
new file mode 100644
index 0000000..4cc8746
--- /dev/null
+++ b/examples/declarative/effects/test.qml
@@ -0,0 +1,75 @@
+import Qt 4.6
+
+Rectangle {
+ color: "white"
+ width: 800
+ height: 600
+
+ Image {
+ source: "pic.jpg"
+
+ effect: Blur {
+ blurRadius: NumberAnimation { id: BS; from: 0; to: 10; duration: 200; repeat: true }
+ }
+
+ MouseRegion { anchors.fill: parent; onClicked: BS.running = !BS.running }
+
+ Text { color: "white"; text: "Blur" }
+ }
+
+ Image {
+ source: "pic.jpg"
+
+ x: 200
+ effect: Grayscale {}
+
+ Text { color: "white"; text: "Grayscale" }
+ }
+
+ Image {
+ source: "pic.jpg"
+
+ x: 400
+ effect: Colorize { color: "blue" }
+
+ Text { color: "white"; text: "Colorize" }
+ }
+
+ Image {
+ source: "pic.jpg"
+
+ y: 300
+ effect: Pixelize {
+ pixelSize: NumberAnimation { id: PS; from: 0; to: 10; duration: 200; repeat: true }
+ }
+
+ MouseRegion { anchors.fill: parent; onClicked: PS.running = !PS.running }
+
+ Text { color: "white"; text: "Pixelize" }
+ }
+
+
+ Image {
+ source: "pic.jpg"
+
+ x: 200
+ y: 300
+ effect: DropShadow {
+ blurRadius: 3
+ offset.x: 3
+ offset.y: NumberAnimation { id: DS; from: 0; to: 10; duration: 200; repeat: true; }
+ }
+
+ MouseRegion { anchors.fill: parent; onClicked: DS.running = !DS.running }
+
+ Text { color: "white"; text: "DropShadow" }
+ }
+
+
+ Text {
+ x: 400; y: 300
+ text: "Clicking Blur, Pixelize or DropShadow will \ntoggle animation."
+ color: "black"
+ }
+
+}
diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp
index 9b9355e..c436622 100644
--- a/src/declarative/fx/qfxitem.cpp
+++ b/src/declarative/fx/qfxitem.cpp
@@ -49,6 +49,7 @@
#include <QtScript/qscriptengine.h>
#include <private/qfxperf_p.h>
#include <QtGui/qgraphicstransform.h>
+#include <QtGui/qgraphicseffect.h>
#include <QtDeclarative/qmlengine.h>
#include <QtDeclarative/qmlopenmetaobject.h>
@@ -75,6 +76,26 @@ QML_DEFINE_NOCREATE_TYPE(QGraphicsTransform);
QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Scale,QGraphicsScale)
QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Rotation,QGraphicsRotation)
+QML_DECLARE_TYPE(QGraphicsEffect)
+QML_DEFINE_NOCREATE_TYPE(QGraphicsEffect)
+
+QML_DECLARE_TYPE(QGraphicsBlurEffect)
+QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Blur,QGraphicsBlurEffect)
+
+QML_DECLARE_TYPE(QGraphicsGrayscaleEffect)
+QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Grayscale,QGraphicsGrayscaleEffect)
+
+QML_DECLARE_TYPE(QGraphicsColorizeEffect)
+QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Colorize,QGraphicsColorizeEffect)
+
+QML_DECLARE_TYPE(QGraphicsPixelizeEffect)
+QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Pixelize,QGraphicsPixelizeEffect)
+
+QML_DECLARE_TYPE(QGraphicsDropShadowEffect)
+QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,DropShadow,QGraphicsDropShadowEffect)
+
+QML_DECLARE_TYPE(QGraphicsOpacityEffect)
+QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Opacity,QGraphicsOpacityEffect)
/*!
\qmlclass Transform
\brief A transformation.
diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h
index 165e4cc..5b95478 100644
--- a/src/declarative/fx/qfxitem.h
+++ b/src/declarative/fx/qfxitem.h
@@ -93,6 +93,7 @@ class Q_DECLARATIVE_EXPORT QFxItem : public QGraphicsObject, public QmlParserSta
Q_PROPERTY(QmlList<QGraphicsTransform *>* transform READ transform DESIGNABLE false FINAL)
Q_PROPERTY(TransformOrigin transformOrigin READ transformOrigin WRITE setTransformOrigin)
Q_PROPERTY(bool smooth READ smoothTransform WRITE setSmoothTransform)
+ Q_PROPERTY(QGraphicsEffect *effect READ graphicsEffect WRITE setGraphicsEffect);
Q_ENUMS(TransformOrigin)
Q_CLASSINFO("DefaultProperty", "data")