summaryrefslogtreecommitdiffstats
path: root/src/declarative/fx
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/fx')
-rw-r--r--src/declarative/fx/fx.pri2
-rw-r--r--src/declarative/fx/qfxanchors.h6
-rw-r--r--src/declarative/fx/qfxblurfilter.h7
-rw-r--r--src/declarative/fx/qfxcomponentinstance.h5
-rw-r--r--src/declarative/fx/qfxcontentwrapper.h7
-rw-r--r--src/declarative/fx/qfxevents_p.h7
-rw-r--r--src/declarative/fx/qfxflickable.cpp8
-rw-r--r--src/declarative/fx/qfxflickable.h7
-rw-r--r--src/declarative/fx/qfxflipable.cpp2
-rw-r--r--src/declarative/fx/qfxflipable.h3
-rw-r--r--src/declarative/fx/qfxfocuspanel.h6
-rw-r--r--src/declarative/fx/qfxfocusrealm.h6
-rw-r--r--src/declarative/fx/qfxgridview.h4
-rw-r--r--src/declarative/fx/qfxhighlightfilter.h5
-rw-r--r--src/declarative/fx/qfximage.h3
-rw-r--r--src/declarative/fx/qfxitem.cpp4
-rw-r--r--src/declarative/fx/qfxitem.h8
-rw-r--r--src/declarative/fx/qfxkeyactions.h6
-rw-r--r--src/declarative/fx/qfxkeyproxy.h5
-rw-r--r--src/declarative/fx/qfxlayouts.h8
-rw-r--r--src/declarative/fx/qfxlistview.h6
-rw-r--r--src/declarative/fx/qfxmouseregion.h5
-rw-r--r--src/declarative/fx/qfxpainteditem.h5
-rw-r--r--src/declarative/fx/qfxparticles.cpp1201
-rw-r--r--src/declarative/fx/qfxparticles.h240
-rw-r--r--src/declarative/fx/qfxpath.h18
-rw-r--r--src/declarative/fx/qfxpathview.h3
-rw-r--r--src/declarative/fx/qfxrect.cpp4
-rw-r--r--src/declarative/fx/qfxrect.h9
-rw-r--r--src/declarative/fx/qfxreflectionfilter.h3
-rw-r--r--src/declarative/fx/qfxrepeater.h7
-rw-r--r--src/declarative/fx/qfxscalegrid.h5
-rw-r--r--src/declarative/fx/qfxshadowfilter.cpp4
-rw-r--r--src/declarative/fx/qfxshadowfilter.h7
-rw-r--r--src/declarative/fx/qfxtext.h5
-rw-r--r--src/declarative/fx/qfxtextedit.h5
-rw-r--r--src/declarative/fx/qfxtransform.cpp137
-rw-r--r--src/declarative/fx/qfxtransform.h58
-rw-r--r--src/declarative/fx/qfxvisualitemmodel.cpp2
-rw-r--r--src/declarative/fx/qfxvisualitemmodel.h3
-rw-r--r--src/declarative/fx/qfxwebview.cpp4
-rw-r--r--src/declarative/fx/qfxwebview.h11
-rw-r--r--src/declarative/fx/qfxwidgetcontainer.h3
43 files changed, 311 insertions, 1543 deletions
diff --git a/src/declarative/fx/fx.pri b/src/declarative/fx/fx.pri
index 69fada0..fd6e480 100644
--- a/src/declarative/fx/fx.pri
+++ b/src/declarative/fx/fx.pri
@@ -26,7 +26,6 @@ HEADERS += \
fx/qfxlayouts_p.h \
fx/qfxmouseregion.h \
fx/qfxmouseregion_p.h \
- fx/qfxparticles.h \
fx/qfxpath.h \
fx/qfxpath_p.h \
fx/qfxpathview.h \
@@ -67,7 +66,6 @@ SOURCES += \
fx/qfxkeyproxy.cpp \
fx/qfxlayouts.cpp \
fx/qfxmouseregion.cpp \
- fx/qfxparticles.cpp \
fx/qfxpath.cpp \
fx/qfxpathview.cpp \
fx/qfxrect.cpp \
diff --git a/src/declarative/fx/qfxanchors.h b/src/declarative/fx/qfxanchors.h
index 94c22a6..dcd5d79 100644
--- a/src/declarative/fx/qfxanchors.h
+++ b/src/declarative/fx/qfxanchors.h
@@ -77,8 +77,6 @@ public:
AnchorLine anchorLine;
};
-Q_DECLARE_METATYPE(QFxAnchorLine)
-
class QFxAnchorsPrivate;
class Q_DECLARATIVE_EXPORT QFxAnchors : public QObject
{
@@ -186,10 +184,12 @@ private:
Q_DISABLE_COPY(QFxAnchors)
Q_DECLARE_PRIVATE(QFxAnchors)
};
-QML_DECLARE_TYPE(QFxAnchors)
QT_END_NAMESPACE
+Q_DECLARE_METATYPE(QFxAnchorLine)
+QML_DECLARE_TYPE(QFxAnchors)
+
QT_END_HEADER
#endif
diff --git a/src/declarative/fx/qfxblurfilter.h b/src/declarative/fx/qfxblurfilter.h
index 90285de..830663f 100644
--- a/src/declarative/fx/qfxblurfilter.h
+++ b/src/declarative/fx/qfxblurfilter.h
@@ -45,12 +45,12 @@
#include <QtDeclarative/qsimplecanvasfilter.h>
#include <QtDeclarative/qml.h>
-
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
+
class QFxBlurFilterPrivate;
class Q_DECLARATIVE_EXPORT QFxBlurFilter : public QSimpleCanvasFilter
{
@@ -73,10 +73,11 @@ protected:
private:
QFxBlurFilterPrivate *d;
};
-QML_DECLARE_TYPE(QFxBlurFilter)
-
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxBlurFilter)
+
QT_END_HEADER
+
#endif // QFXBLURFILTER_H
diff --git a/src/declarative/fx/qfxcomponentinstance.h b/src/declarative/fx/qfxcomponentinstance.h
index e749272..f3bf6b3 100644
--- a/src/declarative/fx/qfxcomponentinstance.h
+++ b/src/declarative/fx/qfxcomponentinstance.h
@@ -44,12 +44,12 @@
#include <QtDeclarative/qfxitem.h>
-
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
+
class QFxComponentInstancePrivate;
class Q_DECLARATIVE_EXPORT QFxComponentInstance : public QFxItem
{
@@ -80,10 +80,11 @@ protected:
private:
Q_DECLARE_PRIVATE(QFxComponentInstance)
};
-QML_DECLARE_TYPE(QFxComponentInstance)
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxComponentInstance)
+
QT_END_HEADER
#endif // QFXCOMPONENTINSTANCE_H
diff --git a/src/declarative/fx/qfxcontentwrapper.h b/src/declarative/fx/qfxcontentwrapper.h
index d8fe0b8..9a9a89c 100644
--- a/src/declarative/fx/qfxcontentwrapper.h
+++ b/src/declarative/fx/qfxcontentwrapper.h
@@ -44,12 +44,12 @@
#include <QtDeclarative/qfxitem.h>
-
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
+
class QFxContentWrapperPrivate;
class Q_DECLARATIVE_EXPORT QFxContentWrapper : public QFxItem
{
@@ -73,7 +73,6 @@ protected:
private:
Q_DECLARE_PRIVATE(QFxContentWrapper)
};
-QML_DECLARE_TYPE(QFxContentWrapper)
class Q_DECLARATIVE_EXPORT QFxContent : public QFxItem
{
@@ -81,10 +80,12 @@ class Q_DECLARATIVE_EXPORT QFxContent : public QFxItem
public:
QFxContent(QFxItem *parent=0) : QFxItem(parent) {}
};
-QML_DECLARE_TYPE(QFxContent)
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxContentWrapper)
+QML_DECLARE_TYPE(QFxContent)
+
QT_END_HEADER
#endif // QFXCONTENTWRAPPER_H
diff --git a/src/declarative/fx/qfxevents_p.h b/src/declarative/fx/qfxevents_p.h
index 60494e6..fbf0c5f 100644
--- a/src/declarative/fx/qfxevents_p.h
+++ b/src/declarative/fx/qfxevents_p.h
@@ -89,8 +89,6 @@ private:
QKeyEvent event;
};
-QML_DECLARE_TYPE(QFxKeyEvent)
-
class QFxMouseEvent : public QObject
{
Q_OBJECT
@@ -131,8 +129,9 @@ private:
bool _accepted;
};
-QML_DECLARE_TYPE(QFxMouseEvent)
-
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxKeyEvent)
+QML_DECLARE_TYPE(QFxMouseEvent)
+
#endif // QFXEVENTS_P_H
diff --git a/src/declarative/fx/qfxflickable.cpp b/src/declarative/fx/qfxflickable.cpp
index 3580edb..a82385a 100644
--- a/src/declarative/fx/qfxflickable.cpp
+++ b/src/declarative/fx/qfxflickable.cpp
@@ -597,7 +597,13 @@ void QFxFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent *event)
int dx = int(event->pos().x() - pressPos.x());
if (qAbs(dx) > FlickThreshold || pressTime.elapsed() > 200) {
qreal newX = dx + pressX;
- if (q->overShoot() || (newX <= q->minXExtent() && newX >= q->maxXExtent())) {
+ const qreal minX = q->minXExtent();
+ const qreal maxX = q->maxXExtent();
+ if (newX > minX)
+ newX = minX + (newX - minX) / 2;
+ if (newX < maxX && maxX - minX < 0)
+ newX = maxX + (newX - maxX) / 2;
+ if (q->overShoot() || (newX <= minX && newX >= maxX)) {
if (dragMode == QFxFlickable::Hard)
_moveX.setValue(newX);
else
diff --git a/src/declarative/fx/qfxflickable.h b/src/declarative/fx/qfxflickable.h
index 2c858bc..da38df8 100644
--- a/src/declarative/fx/qfxflickable.h
+++ b/src/declarative/fx/qfxflickable.h
@@ -44,12 +44,12 @@
#include <QtDeclarative/qfxitem.h>
-
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
+
class QFxFlickablePrivate;
class Q_DECLARATIVE_EXPORT QFxFlickable : public QFxItem
{
@@ -186,10 +186,11 @@ private:
Q_DISABLE_COPY(QFxFlickable)
Q_DECLARE_PRIVATE(QFxFlickable)
};
-QML_DECLARE_TYPE(QFxFlickable)
-
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxFlickable)
+
QT_END_HEADER
+
#endif
diff --git a/src/declarative/fx/qfxflipable.cpp b/src/declarative/fx/qfxflipable.cpp
index 9595724..7672858 100644
--- a/src/declarative/fx/qfxflipable.cpp
+++ b/src/declarative/fx/qfxflipable.cpp
@@ -44,6 +44,8 @@
#include "qfxtransform.h"
#include <QtDeclarative/qmlinfo.h>
+QT_BEGIN_NAMESPACE
+
QML_DEFINE_TYPE(QFxFlipable,Flipable)
class QFxFlipablePrivate : public QFxItemPrivate
diff --git a/src/declarative/fx/qfxflipable.h b/src/declarative/fx/qfxflipable.h
index 6630633..06f8b93 100644
--- a/src/declarative/fx/qfxflipable.h
+++ b/src/declarative/fx/qfxflipable.h
@@ -97,10 +97,11 @@ private:
Q_DISABLE_COPY(QFxFlipable)
Q_DECLARE_PRIVATE(QFxFlipable)
};
-QML_DECLARE_TYPE(QFxFlipable)
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxFlipable)
+
QT_END_HEADER
#endif // QFXFLIPABLE_H
diff --git a/src/declarative/fx/qfxfocuspanel.h b/src/declarative/fx/qfxfocuspanel.h
index 60f9118..623c9fb 100644
--- a/src/declarative/fx/qfxfocuspanel.h
+++ b/src/declarative/fx/qfxfocuspanel.h
@@ -44,12 +44,12 @@
#include <QtDeclarative/qfxitem.h>
-
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
+
class Q_DECLARATIVE_EXPORT QFxFocusPanel : public QFxItem
{
Q_OBJECT
@@ -72,10 +72,10 @@ private:
Q_DISABLE_COPY(QFxFocusPanel)
};
-QML_DECLARE_TYPE(QFxFocusPanel)
-
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxFocusPanel)
+
QT_END_HEADER
#endif // QFXFOCUSPANEL_H
diff --git a/src/declarative/fx/qfxfocusrealm.h b/src/declarative/fx/qfxfocusrealm.h
index d2aadce..20fc5ad 100644
--- a/src/declarative/fx/qfxfocusrealm.h
+++ b/src/declarative/fx/qfxfocusrealm.h
@@ -44,12 +44,12 @@
#include <QtDeclarative/qfxitem.h>
-
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
+
class Q_DECLARATIVE_EXPORT QFxFocusRealm : public QFxItem
{
Q_OBJECT
@@ -58,10 +58,10 @@ public:
virtual ~QFxFocusRealm();
};
-QML_DECLARE_TYPE(QFxFocusRealm)
-
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxFocusRealm)
+
QT_END_HEADER
#endif // QFXFOCUSREALM_H
diff --git a/src/declarative/fx/qfxgridview.h b/src/declarative/fx/qfxgridview.h
index 19c21c4..b6d585e 100644
--- a/src/declarative/fx/qfxgridview.h
+++ b/src/declarative/fx/qfxgridview.h
@@ -139,10 +139,10 @@ private:
void refill();
};
-QML_DECLARE_TYPE(QFxGridView)
-
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxGridView)
+
QT_END_HEADER
#endif
diff --git a/src/declarative/fx/qfxhighlightfilter.h b/src/declarative/fx/qfxhighlightfilter.h
index 33f0963..56509a3 100644
--- a/src/declarative/fx/qfxhighlightfilter.h
+++ b/src/declarative/fx/qfxhighlightfilter.h
@@ -45,12 +45,12 @@
#include <QtDeclarative/qsimplecanvasfilter.h>
#include <QtDeclarative/qml.h>
-
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
+
class QFxHighlightFilterPrivate;
class Q_DECLARATIVE_EXPORT QFxHighlightFilter : public QSimpleCanvasFilter
{
@@ -89,10 +89,11 @@ protected:
private:
QFxHighlightFilterPrivate *d;
};
-QML_DECLARE_TYPE(QFxHighlightFilter)
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxHighlightFilter)
+
QT_END_HEADER
#endif // QFXHIGHLIGHTFILTER_H
diff --git a/src/declarative/fx/qfximage.h b/src/declarative/fx/qfximage.h
index 35b921a..3071a9e 100644
--- a/src/declarative/fx/qfximage.h
+++ b/src/declarative/fx/qfximage.h
@@ -120,10 +120,11 @@ private:
Q_DECLARE_PRIVATE(QFxImage)
void setGridScaledImage(const QFxGridScaledImage& sci);
};
-QML_DECLARE_TYPE(QFxImage)
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxImage)
+
QT_END_HEADER
#endif // QFXIMAGE_H
diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp
index 1c35290..7ccad5f 100644
--- a/src/declarative/fx/qfxitem.cpp
+++ b/src/declarative/fx/qfxitem.cpp
@@ -133,7 +133,9 @@ QFxContents::QFxContents() : m_height(0), m_width(0)
The contents properties allow an item access to the size of its
children. This property is useful if you have an item that needs to be
- sized to fit its children.
+ sized to fit its children.
+*/
+
/*!
\property QFxContents::height
\brief The height of the contents.
diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h
index 67a4553..2b45f73 100644
--- a/src/declarative/fx/qfxitem.h
+++ b/src/declarative/fx/qfxitem.h
@@ -86,7 +86,6 @@ private:
qreal m_height;
qreal m_width;
};
-QML_DECLARE_TYPE(QFxContents)
Q_DECLARE_OPERATORS_FOR_FLAGS(QFxAnchors::UsedAnchors)
class QmlState;
@@ -266,12 +265,13 @@ private:
Q_DISABLE_COPY(QFxItem)
Q_DECLARE_PRIVATE(QFxItem)
};
-QML_DECLARE_TYPE(QFxItem)
-
-QML_DECLARE_TYPE(QSimpleCanvasFilter)
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxContents)
+QML_DECLARE_TYPE(QFxItem)
+QML_DECLARE_TYPE(QSimpleCanvasFilter)
+
QT_END_HEADER
#endif // QFXITEM_H
diff --git a/src/declarative/fx/qfxkeyactions.h b/src/declarative/fx/qfxkeyactions.h
index cea992a..91c2806 100644
--- a/src/declarative/fx/qfxkeyactions.h
+++ b/src/declarative/fx/qfxkeyactions.h
@@ -47,12 +47,12 @@
#include <QtDeclarative/qml.h>
#include <QtDeclarative/qfxitem.h>
-
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
+
class QFxKeyActionsPrivate;
class Q_DECLARATIVE_EXPORT QFxKeyActions : public QFxItem
{
@@ -310,10 +310,10 @@ private:
QFxKeyActionsPrivate *d;
};
-QML_DECLARE_TYPE(QFxKeyActions)
-
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxKeyActions)
+
QT_END_HEADER
#endif // QFXKEYACTIONS_H
diff --git a/src/declarative/fx/qfxkeyproxy.h b/src/declarative/fx/qfxkeyproxy.h
index 38cff7a..d075295 100644
--- a/src/declarative/fx/qfxkeyproxy.h
+++ b/src/declarative/fx/qfxkeyproxy.h
@@ -49,6 +49,7 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
+
class QFxKeyProxyPrivate;
class Q_DECLARATIVE_EXPORT QFxKeyProxy : public QFxItem
{
@@ -69,10 +70,10 @@ private:
QFxKeyProxyPrivate *d;
};
-QML_DECLARE_TYPE(QFxKeyProxy)
-
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxKeyProxy)
+
QT_END_HEADER
#endif // QFXKEYPROXY_H
diff --git a/src/declarative/fx/qfxlayouts.h b/src/declarative/fx/qfxlayouts.h
index b119d6f..112fe85 100644
--- a/src/declarative/fx/qfxlayouts.h
+++ b/src/declarative/fx/qfxlayouts.h
@@ -128,7 +128,6 @@ protected Q_SLOTS:
private:
Q_DISABLE_COPY(QFxVerticalLayout)
};
-QML_DECLARE_TYPE(QFxVerticalLayout)
class Q_DECLARATIVE_EXPORT QFxHorizontalLayout: public QFxBaseLayout
{
@@ -140,7 +139,6 @@ protected Q_SLOTS:
private:
Q_DISABLE_COPY(QFxHorizontalLayout)
};
-QML_DECLARE_TYPE(QFxHorizontalLayout)
class Q_DECLARATIVE_EXPORT QFxGridLayout : public QFxBaseLayout
{
@@ -163,9 +161,13 @@ private:
int _columns;
Q_DISABLE_COPY(QFxGridLayout)
};
-QML_DECLARE_TYPE(QFxGridLayout)
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxVerticalLayout)
+QML_DECLARE_TYPE(QFxHorizontalLayout)
+QML_DECLARE_TYPE(QFxGridLayout)
+
QT_END_HEADER
+
#endif
diff --git a/src/declarative/fx/qfxlistview.h b/src/declarative/fx/qfxlistview.h
index 5dfb0e4..6e9451e 100644
--- a/src/declarative/fx/qfxlistview.h
+++ b/src/declarative/fx/qfxlistview.h
@@ -44,12 +44,12 @@
#include <QtDeclarative/qfxflickable.h>
-
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
+
class QFxVisualItemModel;
class QFxListViewPrivate;
class Q_DECLARATIVE_EXPORT QFxListView : public QFxFlickable
@@ -145,10 +145,10 @@ private Q_SLOTS:
void destroyingItem(QFxItem *item);
};
-QML_DECLARE_TYPE(QFxListView)
-
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxListView)
+
QT_END_HEADER
#endif
diff --git a/src/declarative/fx/qfxmouseregion.h b/src/declarative/fx/qfxmouseregion.h
index d7db1dc..429ad00 100644
--- a/src/declarative/fx/qfxmouseregion.h
+++ b/src/declarative/fx/qfxmouseregion.h
@@ -86,7 +86,6 @@ private:
int _ymax;
Q_DISABLE_COPY(QFxDrag)
};
-QML_DECLARE_TYPE(QFxDrag)
class QFxMouseEvent;
class QFxMouseRegionPrivate;
@@ -154,10 +153,12 @@ private:
Q_DISABLE_COPY(QFxMouseRegion)
Q_DECLARE_PRIVATE(QFxMouseRegion)
};
-QML_DECLARE_TYPE(QFxMouseRegion)
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxDrag)
+QML_DECLARE_TYPE(QFxMouseRegion)
+
QT_END_HEADER
#endif // QFXMOUSEREGION_H
diff --git a/src/declarative/fx/qfxpainteditem.h b/src/declarative/fx/qfxpainteditem.h
index 6cb8fe7..7a0a9a9 100644
--- a/src/declarative/fx/qfxpainteditem.h
+++ b/src/declarative/fx/qfxpainteditem.h
@@ -101,10 +101,11 @@ private:
Q_DISABLE_COPY(QFxPaintedItem)
Q_DECLARE_PRIVATE(QFxPaintedItem)
};
-QML_DECLARE_TYPE(QFxPaintedItem)
-
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxPaintedItem)
+
QT_END_HEADER
+
#endif
diff --git a/src/declarative/fx/qfxparticles.cpp b/src/declarative/fx/qfxparticles.cpp
deleted file mode 100644
index 4cd34c4..0000000
--- a/src/declarative/fx/qfxparticles.cpp
+++ /dev/null
@@ -1,1201 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** 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.0, 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.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qfxitem_p.h"
-#if defined(QFX_RENDER_OPENGL)
-#include "gltexture.h"
-#endif
-
-#include <stdlib.h>
-#include <math.h>
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#define M_PI_2 (M_PI / 2.)
-#endif
-#ifndef INT_MAX
-#define INT_MAX 2147483647
-#endif
-#include <qfxpixmap.h>
-#include <qfxperf.h>
-#include <private/qmlanimation_p.h>
-
-#include "qfxparticles.h"
-
-
-QT_BEGIN_NAMESPACE
-#define PI_SQR 9.8696044
-// parabolic approximation
-inline qreal fastSin(qreal theta)
-{
- const qreal b = 4 / M_PI;
- const qreal c = -4 / PI_SQR;
-
- qreal y = b * theta + c * theta * qAbs(theta);
- return y;
-}
-
-inline qreal fastCos(qreal theta)
-{
- theta += M_PI_2;
- if (theta > M_PI)
- theta -= 2 * M_PI;
-
- return fastSin(theta);
-}
-
-class QFxParticle
-{
-public:
- QFxParticle(int time) : lifeSpan(1000), fadeOutAge(800)
- , opacity(0), birthTime(time), x_velocity(0), y_velocity(0)
- , state(FadeIn), data(0)
- {
- }
-
- int lifeSpan;
- int fadeOutAge;
- qreal x;
- qreal y;
- qreal opacity;
- int birthTime;
- qreal x_velocity;
- qreal y_velocity;
- enum State { FadeIn, Solid, FadeOut };
- State state;
- void *data;
-};
-
-//---------------------------------------------------------------------------
-
-QML_DEFINE_TYPE(QFxParticleMotion,ParticleMotion)
-
-/*!
- \class QFxParticleMotion
- \ingroup group_effects
- \brief The QFxParticleMotion class is the base class for particle motion.
-
- This class causes the particles to remain static.
-*/
-
-/*!
- Constructs a QFxParticleMotion with parent object \a parent.
-*/
-QFxParticleMotion::QFxParticleMotion(QObject *parent) :
- QObject(parent)
-{
-}
-
-/*!
- Move the \a particle to its new position. \a interval is the number of
- milliseconds elapsed since it was last moved.
-*/
-void QFxParticleMotion::advance(QFxParticle &particle, int interval)
-{
- Q_UNUSED(particle);
- Q_UNUSED(interval);
-}
-
-/*!
- The \a particle has just been created. Some motion strategies require
- additional state information. This can be allocated by this function.
-*/
-void QFxParticleMotion::created(QFxParticle &particle)
-{
- Q_UNUSED(particle);
-}
-
-/*!
- The \a particle is about to be destroyed. Any additional memory
- that has been allocated for the particle should be freed.
-*/
-void QFxParticleMotion::destroy(QFxParticle &particle)
-{
- Q_UNUSED(particle);
-}
-
-/*!
- \qmlclass ParticleMotionLinear
- \brief The ParticleMotionLinear object moves particles linearly.
-
- \sa Particles
-*/
-
-/*!
- \internal
- \class QFxParticleMotionLinear
- \ingroup group_effects
- \brief The QFxParticleMotionLinear class moves the particles linearly.
-*/
-
-QML_DEFINE_TYPE(QFxParticleMotionLinear,ParticleMotionLinear)
-
-void QFxParticleMotionLinear::advance(QFxParticle &p, int interval)
-{
- p.x += interval * p.x_velocity;
- p.y += interval * p.y_velocity;
-}
-
-/*!
- \qmlclass ParticleMotionGravity
- \brief The ParticleMotionGravity object moves particles towards a point.
-
- \sa Particles
-*/
-
-/*!
- \internal
- \class QFxParticleMotionGravity
- \ingroup group_effects
- \brief The QFxParticleMotionGravity class moves the particles towards a point.
-*/
-
-QML_DEFINE_TYPE(QFxParticleMotionGravity,ParticleMotionGravity)
-
-/*!
- \qmlproperty int ParticleMotionGravity::xattractor
- \qmlproperty int ParticleMotionGravity::yattractor
- These properties hold the x and y coordinates of the point attracting the particles.
-*/
-
-/*!
- \qmlproperty int ParticleMotionGravity::acceleration
- This property holds the acceleration to apply to the particles.
-*/
-
-/*!
- \property QFxParticleMotionGravity::xattractor
- \brief the x coordinate of the point attracting the particles.
-*/
-
-/*!
- \property QFxParticleMotionGravity::yattractor
- \brief the y coordinate of the point attracting the particles.
-*/
-
-/*!
- \property QFxParticleMotionGravity::acceleration
- \brief the acceleration to apply to the particles.
-*/
-
-void QFxParticleMotionGravity::advance(QFxParticle &p, int interval)
-{
- qreal xdiff = p.x - _xAttr;
- qreal ydiff = p.y - _yAttr;
-
- qreal xcomp = xdiff / (xdiff + ydiff);
- qreal ycomp = ydiff / (xdiff + ydiff);
-
- p.x_velocity += xcomp * _accel * interval;
- p.y_velocity += ycomp * _accel * interval;
-
- p.x += interval * p.x_velocity;
- p.y += interval * p.y_velocity;
-}
-
-/*!
- \qmlclass ParticleMotionWander
- \brief The ParticleMotionWander object moves particles in a somewhat random fashion.
-
- The particles will continue roughly in the original direction, however will randomly
- drift to each side.
-
- The code below produces an effect similar to falling snow.
-
- \qml
-Rect {
- width: 240
- height: 320
- color: "black"
-
- Particles {
- y: 0
- width: parent.width
- height: 30
- source: "star.png"
- lifeSpan: 5000
- count: 50
- angle: 70
- angleDeviation: 36
- velocity: 30
- velocityDeviation: 10
- ParticleMotionWander {
- xvariance: 30
- pace: 100
- }
- }
-}
- \endqml
-
- \sa Particles
-*/
-
-/*!
- \internal
- \class QFxParticleMotionWander
- \ingroup group_effects
- \brief The QFxParticleMotionWander class moves particles in a somewhat random fashion.
-
- The particles will continue roughly in the original direction, however will randomly
- drift to each side.
-*/
-
-/*!
- \qmlproperty int QFxParticleMotionWander::xvariance
- \qmlproperty int QFxParticleMotionWander::yvariance
-
- These properties set the amount to wander in the x and y directions.
-*/
-
-/*!
- \qmlproperty int QFxParticleMotionWander::pace
- This property holds how quickly the paricles will move from side to side.
-*/
-
-QML_DEFINE_TYPE(QFxParticleMotionWander,ParticleMotionWander)
-
-void QFxParticleMotionWander::advance(QFxParticle &p, int interval)
-{
- if (!particles)
- particles = qobject_cast<QFxParticles*>(parent());
- if (particles) {
- Data *d = (Data*)p.data;
- if (_xvariance != 0.) {
- qreal xdiff = p.x_velocity - d->x_targetV;
- if ((xdiff > d->x_peak && d->x_var > 0.0) || (xdiff < -d->x_peak && d->x_var < 0.0)) {
- d->x_var = -d->x_var;
- d->x_peak = _xvariance + _xvariance * qreal(rand()) / RAND_MAX;
- }
- p.x_velocity += d->x_var * interval;
- }
- p.x += interval * p.x_velocity;
-
- if (_yvariance != 0.) {
- qreal ydiff = p.y_velocity - d->y_targetV;
- if ((ydiff > d->y_peak && d->y_var > 0.0) || (ydiff < -d->y_peak && d->y_var < 0.0)) {
- d->y_var = -d->y_var;
- d->y_peak = _yvariance + _yvariance * qreal(rand()) / RAND_MAX;
- }
- p.y_velocity += d->y_var * interval;
- }
- p.y += interval * p.y_velocity;
- }
-}
-
-void QFxParticleMotionWander::created(QFxParticle &p)
-{
- if (!p.data) {
- Data *d = new Data;
- p.data = (void*)d;
- d->x_targetV = p.x_velocity;
- d->y_targetV = p.y_velocity;
- d->x_peak = _xvariance;
- d->y_peak = _yvariance;
- d->x_var = _pace * qreal(rand()) / RAND_MAX / 1000.0;
- d->y_var = _pace * qreal(rand()) / RAND_MAX / 1000.0;
- }
-}
-
-void QFxParticleMotionWander::destroy(QFxParticle &p)
-{
- if (p.data)
- delete (Data*)p.data;
-}
-
-//---------------------------------------------------------------------------
-class QFxParticlesPainter : public QFxItem
-{
-public:
- QFxParticlesPainter(QFxParticlesPrivate *p, QFxItem* parent)
- : QFxItem(parent), d(p)
- {
- setOptions(HasContents);
- maxX = minX = maxY = minY = 0;
- }
-
-#if defined(QFX_RENDER_QPAINTER)
- void paintContents(QPainter &p);
-#elif defined(QFX_RENDER_OPENGL2)
- void paintGLContents(GLPainter &);
-#endif
-
- void updateSize();
-
- qreal maxX;
- qreal minX;
- qreal maxY;
- qreal minY;
- QFxParticlesPrivate* d;
-};
-
-//---------------------------------------------------------------------------
-class QFxParticlesPrivate : public QFxItemPrivate
-{
- Q_DECLARE_PUBLIC(QFxParticles)
-public:
- QFxParticlesPrivate()
- : count(1), lifeSpan(1000), lifeSpanDev(1000), fadeInDur(200), fadeOutDur(300)
- , angle(0), angleDev(0), velocity(0), velocityDev(0)
- , addParticleTime(0), addParticleCount(0), lastAdvTime(0), stream(false), streamDelay(0)
- , emitting(true), motion(0), clock(this)
-#if defined(QFX_RENDER_OPENGL)
- , texDirty(true)
-#endif
- {
- }
-
- ~QFxParticlesPrivate()
- {
- }
-
- void init()
- {
- Q_Q(QFxParticles);
- paintItem = new QFxParticlesPainter(this, q);
- }
-
- void tick(int time);
- void createParticle(int time);
- void updateOpacity(QFxParticle &p, int age);
-
- QUrl url;
- QPixmap image;
- int count;
- int lifeSpan;
- int lifeSpanDev;
- int fadeInDur;
- int fadeOutDur;
- qreal angle;
- qreal angleDev;
- qreal velocity;
- qreal velocityDev;
- int addParticleTime;
- int addParticleCount;
- int lastAdvTime;
- bool stream;
- int streamDelay;
- bool emitting;
- QFxParticleMotion *motion;
- QFxParticlesPainter *paintItem;
-
- QList<QFxParticle> particles;
- QTickAnimationProxy<QFxParticlesPrivate, &QFxParticlesPrivate::tick> clock;
-
-#if defined(QFX_RENDER_OPENGL)
- bool texDirty;
- GLTexture tex;
-#endif
-};
-
-//TODO: Stop the clock if no visible particles and not emitting (restart on emittingChanged)
-void QFxParticlesPrivate::tick(int time)
-{
- Q_Q(QFxParticles);
- if (!motion)
- motion = new QFxParticleMotionLinear(q);
-
- int oldCount = particles.count();
- int removed = 0;
- int interval = time - lastAdvTime;
- for (int i = 0; i < particles.count(); ) {
- QFxParticle &particle = particles[i];
- int age = time - particle.birthTime;
- if (age >= particle.lifeSpan) {
- QFxParticle part = particles.takeAt(i);
- motion->destroy(part);
- ++removed;
- } else {
- updateOpacity(particle, age);
- motion->advance(particle, interval);
- ++i;
- }
- }
-
- while(removed-- && particles.count() < count && emitting)
- createParticle(time);
-
- if (!addParticleTime)
- addParticleTime = time;
-
- if (particles.count() < count && emitting) {
- qreal perc = (lifeSpanDev <= 0)?(1.):(qreal(time - addParticleTime) / qreal(lifeSpanDev));
- int percCount = addParticleCount + (int)perc * (count - addParticleCount);
- int streamWidth = -1;
- if (stream){
- if (streamDelay > time){
- streamWidth = 0;
- }else{
- int missed = time - streamDelay;
- qreal streamWidthReal = qreal(count)/qreal(lifeSpan);
- if (streamWidthReal < 1){
- streamDelay = time + (int)(1.0/streamWidthReal);
- streamWidth = 1;
- streamWidth += missed/streamDelay;
- }else{
- streamWidth = qRound(streamWidthReal * (time-lastAdvTime));
- }
- }
- }
- while(particles.count() < count && particles.count() < percCount && streamWidth--)
- createParticle(time);
- }
-
- lastAdvTime = time;
- if (oldCount || particles.count()) {
- if (q->itemParent())
- q->itemParent()->update();
- else
- q->update();
- } else if (!count) {
- lastAdvTime = 0;
- clock.stop();
- }
-}
-
-void QFxParticlesPrivate::createParticle(int time)
-{
-#ifdef Q_ENABLE_PERFORMANCE_LOG
- QFxPerfTimer<QFxPerf::CreateParticle> x;
-#endif
- Q_Q(QFxParticles);
- QFxParticle p(time);
- p.x = q->x() + q->width() * qreal(rand()) / RAND_MAX - image.width()/2.0;
- p.y = q->y() + q->height() * qreal(rand()) / RAND_MAX - image.height()/2.0;
- p.lifeSpan = lifeSpan;
- if (lifeSpanDev)
- p.lifeSpan += int(lifeSpanDev/2 - lifeSpanDev * qreal(rand()) / RAND_MAX);
- p.fadeOutAge = p.lifeSpan - fadeOutDur;
- if (fadeInDur == 0.) {
- p.state= QFxParticle::Solid;
- p.opacity = 1.0;
- }
- qreal a = angle;
- if (angleDev)
- a += angleDev/2 - angleDev * qreal(rand()) / RAND_MAX;
- if (a > M_PI)
- a = a - 2 * M_PI;
- qreal v = velocity;
- if (velocityDev)
- v += velocityDev/2 - velocityDev * qreal(rand()) / RAND_MAX;
- p.x_velocity = v * fastCos(a);
- p.y_velocity = v * fastSin(a);
- particles.append(p);
- motion->created(particles.last());
-}
-
-void QFxParticlesPrivate::updateOpacity(QFxParticle &p, int age)
-{
- switch (p.state) {
- case QFxParticle::FadeIn:
- if (age <= fadeInDur) {
- p.opacity = qreal(age) / fadeInDur;
- break;
- } else {
- p.opacity = 1.0;
- p.state = QFxParticle::Solid;
- // Fall through
- }
- case QFxParticle::Solid:
- if (age <= p.fadeOutAge) {
- break;
- } else {
- p.state = QFxParticle::FadeOut;
- // Fall through
- }
- case QFxParticle::FadeOut:
- p.opacity = qreal(p.lifeSpan - age) / fadeOutDur;
- break;
- }
-}
-
-QML_DEFINE_TYPE(QFxParticles,Particles)
-
-/*!
- \qmlclass Particles
- \brief The Particles object generates and moves particles.
- \inherits Item
-
- The particles created by this object cannot be dealt with directly, they can only be controlled through the parameters of the Particles object. The particles are all the same pixmap, specified by the user.
-
- The particles are painted relative to the parent of the Particles object. Moving the
- Particles object will not move the particles already emitted.
-
- The below example creates two differently behaving particle sources.
- The top one has particles falling from the top like snow,
- the lower one has particles expelled up like a fountain.
-
- \qml
-Rect {
- width: 240
- height: 320
- color: "black"
- Particles {
- y: 0
- width: parent.width
- height: 30
- source: "star.png"
- lifeSpan: 5000
- count: 50
- angle: 70
- angleDeviation: 36
- velocity: 30
- velocityDeviation: 10
- ParticleMotionWander {
- xvariance: 30
- pace: 100
- }
- }
- Particles {
- y: 300
- x: 120
- width: 1
- height: 1
- source: "star.png"
- lifeSpan: 5000
- count: 200
- angle: 270
- angleDeviation: 45
- velocity: 50
- velocityDeviation: 30
- ParticleMotionGravity {
- yattractor: 1000
- xattractor: 0
- acceleration: 25
- }
- }
-}
- \endqml
- \image particles.gif
-*/
-
-/*!
- \internal
- \class QFxParticles
- \ingroup group_effects
- \brief The QFxParticles class generates and moves particles.
-*/
-
-QFxParticles::QFxParticles(QFxItem *parent)
- : QFxItem(*(new QFxParticlesPrivate), parent)
-{
- Q_D(QFxParticles);
- d->init();
- setOptions(HasContents);
-}
-
-QFxParticles::QFxParticles(QFxParticlesPrivate &dd, QFxItem *parent)
- : QFxItem(dd, parent)
-{
- Q_D(QFxParticles);
- d->init();
- setOptions(HasContents);
-}
-
-QFxParticles::~QFxParticles()
-{
- Q_D(QFxParticles);
- if (!d->url.isEmpty())
- QFxPixmap::cancelGet(d->url, this);
-}
-
-/*!
- \qmlproperty string Particles::src
- This property holds the URL of the particle image.
-*/
-
-/*!
- \property QFxParticles::source
- \brief the URL of the particle image.
-*/
-QUrl QFxParticles::source() const
-{
- Q_D(const QFxParticles);
- return d->url;
-}
-
-void QFxParticles::imageLoaded()
-{
- Q_D(QFxParticles);
- d->image = QFxPixmap(d->url);
-#if defined(QFX_RENDER_OPENGL)
- d->texDirty = true;
- d->tex.clear();
-#endif
- update();
-}
-
-void QFxParticles::setSource(const QUrl &name)
-{
- Q_D(QFxParticles);
-
- if (name == d->url)
- return;
-
- if (!d->url.isEmpty())
- QFxPixmap::cancelGet(d->url, this);
- if (name.isEmpty()) {
- d->url = name;
- d->image = QPixmap();
-#if defined(QFX_RENDER_OPENGL)
- d->texDirty = true;
- d->tex.clear();
-#endif
- update();
- } else {
- d->url = name;
- Q_ASSERT(!name.isRelative());
- QFxPixmap::get(qmlEngine(this), d->url, this, SLOT(imageLoaded()));
- }
-}
-
-/*!
- \qmlproperty int Particles::count
- This property holds the target number of particles
-*/
-
-/*!
- \property QFxParticles::count
- \brief the target number of particles
-*/
-int QFxParticles::count() const
-{
- Q_D(const QFxParticles);
- return d->count;
-}
-
-void QFxParticles::setCount(int cnt)
-{
- Q_D(QFxParticles);
- if (cnt != d->count) {
- if (!d->count && d->clock.state() != QAbstractAnimation::Running)
- d->clock.start(); // infinity??
- d->count = cnt;
- d->addParticleTime = 0;
- d->addParticleCount = d->particles.count();
- update();
- }
-}
-
-/*!
- \qmlproperty int Particles::lifeSpan
- \qmlproperty int Particles::lifeSpanDeviation
-
- These properties describe the life span of each particle.
-
- The default lifespan for a particle is 1000ms.
-
- lifeSpanDeviation randomly varies the lifeSpan up to the specified variation. For
- example, the following creates particles whose lifeSpan will vary
- from 150ms to 250ms:
-
- \qml
-Particles {
- source: "star.png"
- lifeSpan: 200
- lifeSpanDeviation: 100
-}
- \endqml
-*/
-
-/*!
- \property QFxParticles::lifeSpan
- \brief the life span of each particle.
-
- Default value is 1000ms.
-
- \sa QFxParticles::lifeSpanDeviation
-*/
-int QFxParticles::lifeSpan() const
-{
- Q_D(const QFxParticles);
- return d->lifeSpan;
-}
-
-void QFxParticles::setLifeSpan(int ls)
-{
- Q_D(QFxParticles);
- d->lifeSpan = ls;
-}
-
-/*!
- \property QFxParticles::lifeSpanDeviation
- \brief the maximum possible deviation from the set lifeSpan.
-
- Randomly varies the lifeSpan up to the specified variation. For
- example, the following creates particles whose lifeSpan will vary
- from 150ms to 250ms:
-
-\qml
-Particles {
- source: "star.png"
- lifeSpan: 200
- lifeSpanDeviation: 100
-}
-\endqml
-
- \sa QFxParticles::lifeSpan
-*/
-int QFxParticles::lifeSpanDeviation() const
-{
- Q_D(const QFxParticles);
- return d->lifeSpanDev;
-}
-
-void QFxParticles::setLifeSpanDeviation(int dev)
-{
- Q_D(QFxParticles);
- d->lifeSpanDev = dev;
-}
-
-/*!
- \qmlproperty int Particles::fadeInDuration
- \qmlproperty int Particles::fadeOutDuration
- These properties hold the time taken to fade the particles in and out.
-
- By default fade in is 200ms and fade out is 300ms.
-*/
-
-/*!
- \property QFxParticles::fadeInDuration
- \brief the time taken to fade in the particles.
-
- Default value is 200ms.
-*/
-int QFxParticles::fadeInDuration() const
-{
- Q_D(const QFxParticles);
- return d->fadeInDur;
-}
-
-void QFxParticles::setFadeInDuration(int dur)
-{
- Q_D(QFxParticles);
- if (dur >= 0.0)
- d->fadeInDur = dur;
-}
-
-/*!
- \property QFxParticles::fadeOutDuration
- \brief the time taken to fade out the particles.
-
- Default value is 300ms.
-*/
-int QFxParticles::fadeOutDuration() const
-{
- Q_D(const QFxParticles);
- return d->fadeOutDur;
-}
-
-void QFxParticles::setFadeOutDuration(int dur)
-{
- Q_D(QFxParticles);
- if (dur >= 0.0)
- d->fadeOutDur = dur;
-}
-
-/*!
- \qmlproperty real Particles::angle
- \qmlproperty real Particles::angleDeviation
-
- These properties control particle direction.
-
- angleDeviation randomly varies the direction up to the specified variation. For
- example, the following creates particles whose initial direction will
- vary from 15 degrees to 105 degrees:
-
- \qml
-Particles {
- source: "star.png"
- angle: 60
- angleDeviation: 90
-}
- \endqml
-*/
-
-/*!
- \property QFxParticles::angle
- \brief the initial angle of direction.
-
- \sa QFxParticles::angleDeviation
-*/
-qreal QFxParticles::angle() const
-{
- Q_D(const QFxParticles);
- return d->angle * 180.0 / M_PI;
-}
-
-void QFxParticles::setAngle(qreal angle)
-{
- Q_D(QFxParticles);
- d->angle = angle * M_PI / 180.0;
-}
-
-/*!
- \property QFxParticles::angleDeviation
- \brief the maximum possible deviation from the set angle.
-
- Randomly varies the direction up to the specified variation. For
- example, the following creates particles whose initial direction will
- vary from 15 degrees to 105 degrees:
-
-\qml
-Particles {
- source: "star.png"
- angle: 60
- angleDeviation: 90
-}
-\endqml
-
- \sa QFxParticles::angle
-*/
-qreal QFxParticles::angleDeviation() const
-{
- Q_D(const QFxParticles);
- return d->angleDev * 180.0 / M_PI;
-}
-
-void QFxParticles::setAngleDeviation(qreal dev)
-{
- Q_D(QFxParticles);
- d->angleDev = dev * M_PI / 180.0;;
-}
-
-/*!
- \qmlproperty real Particles::velocity
- \qmlproperty real Particles::velocityDeviation
-
- These properties control the velocity of the particles.
-
- velocityDeviation randomly varies the velocity up to the specified variation. For
- example, the following creates particles whose initial velocity will
- vary from 40 to 60.
-
- \qml
-Particles {
- source: "star.png"
- velocity: 50
- velocityDeviation: 20
-}
- \endqml
-*/
-
-/*!
- \property QFxParticles::velocity
- \brief the initial velocity of the particles.
-
- \sa QFxParticles::velocityDeviation
-*/
-qreal QFxParticles::velocity() const
-{
- Q_D(const QFxParticles);
- return d->velocity * 1000.0;
-}
-
-void QFxParticles::setVelocity(qreal velocity)
-{
- Q_D(QFxParticles);
- d->velocity = velocity / 1000.0;
-}
-
-/*!
- \property QFxParticles::velocityDeviation
- \brief the maximum possible deviation from the set velocity.
-
- Randomly varies the velocity up to the specified variation. For
- example, the following creates particles whose initial velocity will
- vary from 40 to 60.
-
-\qml
-Particles {
- source: "star.png"
- velocity: 50
- velocityDeviation: 20
-}
-\endqml
-
- \sa QFxParticles::velocity
-*/
-qreal QFxParticles::velocityDeviation() const
-{
- Q_D(const QFxParticles);
- return d->velocityDev * 1000.0;
-}
-
-void QFxParticles::setVelocityDeviation(qreal velocity)
-{
- Q_D(QFxParticles);
- d->velocityDev = velocity / 1000.0;
-}
-
-/*!
- \qmlproperty bool Particles::streamIn
- This property determines whether the particles stream in at a constant rate
-
- When stream is set to true the particles will stream in at a constant rate.
- Otherwise the particles will appear as a clump. Note that this only affects the
- start of the particle effect, variables such as lifespan deviation can cause the
- particles to unclump over time.
-*/
-/*!
- \property QFxParticles::streamIn
- \brief determines whether the particles stream in at a constant rate
-
- When stream is set to true the particles will stream in at a constant rate.
- Otherwise the particles will appear as a clump. Note that this only affects the
- start of the particle effect, variables such as lifespan deviation can cause the
-
-*/
-//The name may need a rethink
-bool QFxParticles::streamIn() const
-{
- Q_D(const QFxParticles);
- return d->stream;
-}
-
-void QFxParticles::setStreamIn(bool b)
-{
- Q_D(QFxParticles);
- d->stream = b;
-}
-
-/*!
- \qmlproperty bool Particles::emitting
- This property determines whether new particles are created
-
- If emitting is set to false no new particles will be created. This means that
- when a particle reaches the end of its lifespan it is not replaced. This
- property can be used to turn particles on and off with a more natural look.
-
- The default setting is true. Note that if it initialized to false no particles
- will be produced until it is set to true.
-*/
-/*!
- \property QFxParticles::emitting
- If emitting is set to false no new particles will be created. This means that
- when a particle reaches the end of its lifespan it is not replaced. This
- property can be used to turn particles on and off with a more natural look.
-
- The default setting is true. Note that if it initialized to false no particles
- will be produced until it is set to true.
-*/
-bool QFxParticles::emitting() const
-{
- Q_D(const QFxParticles);
- return d->emitting;
-}
-
-void QFxParticles::setEmitting(bool r)
-{
- Q_D(QFxParticles);
- d->emitting = r;
-}
-/*!
- \qmlproperty ParticleMotion Particles::motion
- This property sets the type of motion to apply to the particles.
-
- When a particle is created it will have an initial direction and velocity.
- The motion of the particle during its lifeSpan is then influenced by the
- motion property.
-
- Default motion is ParticleMotionLinear.
-*/
-
-/*!
- \property QFxParticles::motion
- \brief sets the type of motion to apply to the particles.
-
- When a particle is created it will have an initial direction and velocity.
- The motion of the particle during its lifeSpan is then influenced by the
- motion property.
-
- Default motion is QFxParticleMotionLinear.
-*/
-QFxParticleMotion *QFxParticles::motion() const
-{
- Q_D(const QFxParticles);
- return d->motion;
-}
-
-void QFxParticles::setMotion(QFxParticleMotion *motion)
-{
- Q_D(QFxParticles);
- d->motion = motion;
-}
-
-void QFxParticles::dump(int depth)
-{
- Q_D(QFxParticles);
- QByteArray ba(depth * 4, ' ');
- qWarning() << ba.constData() << "URL:" << d->url << "Count:" << d->count;
- QFxItem::dump(depth);
-}
-
-QString QFxParticles::propertyInfo() const
-{
- Q_D(const QFxParticles);
- return d->url.toString();
-}
-
-void QFxParticlesPainter::updateSize(){
- setX(-500);
- setY(-500);
- setWidth(1000);
- setHeight(1000);
- return ;
- const int parentX = parent()->x();
- const int parentY = parent()->y();
- //Have to use statistical approach to needed size as arbitrary particle
- //motions make it impossible to calculate.
- //max/min vars stored to give a never shrinking rect
- for (int i = 0; i < d->particles.count(); ++i) {
- const QFxParticle &particle = d->particles.at(i);
- if(particle.x > maxX)
- maxX = particle.x;
- if(particle.x < minX)
- minX = particle.x;
- if(particle.y > maxY)
- maxY = particle.y;
- if(particle.y < minY)
- minY = particle.y;
- }
-
- int myWidth = (int)(maxX-minX+0.5)+d->image.width();
- int myX = (int)(minX - parentX);
- int myHeight = (int)(maxY-minY+0.5)+d->image.height();
- int myY = (int)(minY - parentY);
- setWidth(myWidth);
- setHeight(myHeight);
- setX(myX);
- setY(myY);
-}
-
-#if defined(QFX_RENDER_QPAINTER)
-void QFxParticles::paintContents(QPainter &p)
-{
- Q_UNUSED(p);
- //painting is done by the ParticlesPainter, so it can have the right size
-}
-
-void QFxParticlesPainter::paintContents(QPainter &p)
-{
- if (d->image.isNull())
- return;
-
- updateSize();
- const int myX = x() + parent()->x();
- const int myY = y() + parent()->y();
-
- for (int i = 0; i < d->particles.count(); ++i) {
- const QFxParticle &particle = d->particles.at(i);
- p.setOpacity(particle.opacity);
- p.drawPixmap(particle.x - myX, particle.y - myY, d->image);
- }
- update();//Should I need this? (GV does)
-}
-#elif defined(QFX_RENDER_OPENGL2)
-void QFxParticles::paintGLContents(GLPainter &)
-{
- //painting is done by the ParticlesPainter, so it can have the right size
-}
-
-void QFxParticlesPainter::paintGLContents(GLPainter &p)
-{
-
- if (d->image.isNull())
- return;
-
- updateSize();
-
- if (d->texDirty && !d->image.isNull()) {
- d->tex.setImage(d->image.toImage());
- d->tex.setHorizontalWrap(GLTexture::Repeat);
- d->tex.setVerticalWrap(GLTexture::Repeat);
- }
- d->texDirty = false;
-
- SingleTextureOpacityShader *shader = basicShaders()->singleTextureOpacity();
- shader->enable();
- shader->setTransform(p.activeTransform);
-
- glBindTexture(GL_TEXTURE_2D, d->tex.texture());
-
- const int myX = (int)(x() + parent()->x());
- const int myY = (int)(y() + parent()->y());
- float widthV = d->image.width();
- float heightV = d->image.height();
- for (int i = 0; i < d->particles.count(); ++i) {
- const QFxParticle &particle = d->particles.at(i);
- float left = particle.x - myX;
- float right = particle.x - myX + widthV;
- float top = particle.y - myY;
- float bottom = particle.y - myY + heightV;
-
- GLfloat vertices[] = { left, bottom,
- right, bottom,
- left, top,
- right, top };
-
- GLfloat texVertices[] = { 0, 0,
- 1, 0,
- 0, 1,
- 1, 1 };
-
- shader->setAttributeArray(SingleTextureShader::Vertices, vertices, 2);
- shader->setAttributeArray(SingleTextureShader::TextureCoords, texVertices, 2);
- shader->setOpacity(particle.opacity * p.activeOpacity);
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
- }
-
- shader->disableAttributeArray(SingleTextureShader::Vertices);
- shader->disableAttributeArray(SingleTextureShader::TextureCoords);
-}
-#endif
-
-void QFxParticles::componentComplete()
-{
- Q_D(QFxParticles);
- QFxItem::componentComplete();
- if (d->count)
- d->clock.start(); // infinity??
- if (d->lifeSpanDev > d->lifeSpan)
- d->lifeSpanDev = d->lifeSpan;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxparticles.h b/src/declarative/fx/qfxparticles.h
deleted file mode 100644
index b3a569b..0000000
--- a/src/declarative/fx/qfxparticles.h
+++ /dev/null
@@ -1,240 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** 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.0, 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.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QFXPARTICLES_H
-#define QFXPARTICLES_H
-
-#include <QtDeclarative/qfxitem.h>
-
-#if defined(QFX_RENDER_OPENGL)
-#include "gltexture.h"
-#endif
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QFxParticle;
-class QFxParticles;
-class Q_DECLARATIVE_EXPORT QFxParticleMotion : public QObject
-{
- Q_OBJECT
-public:
- QFxParticleMotion(QObject *parent=0);
-
- virtual void advance(QFxParticle &, int interval);
- virtual void created(QFxParticle &);
- virtual void destroy(QFxParticle &);
-};
-QML_DECLARE_TYPE(QFxParticleMotion)
-
-class Q_DECLARATIVE_EXPORT QFxParticleMotionLinear : public QFxParticleMotion
-{
- Q_OBJECT
-public:
- QFxParticleMotionLinear(QObject *parent=0)
- : QFxParticleMotion(parent) {}
-
- virtual void advance(QFxParticle &, int interval);
-};
-QML_DECLARE_TYPE(QFxParticleMotionLinear)
-
-class Q_DECLARATIVE_EXPORT QFxParticleMotionGravity : public QFxParticleMotion
-{
- Q_OBJECT
-
- Q_PROPERTY(int xattractor READ xAttractor WRITE setXAttractor)
- Q_PROPERTY(int yattractor READ yAttractor WRITE setYAttractor)
- Q_PROPERTY(int acceleration READ acceleration WRITE setAcceleration)
-public:
- QFxParticleMotionGravity(QObject *parent=0)
- : QFxParticleMotion(parent), _xAttr(0), _yAttr(0), _accel(0.00005) {}
-
- int xAttractor() const { return _xAttr; }
- void setXAttractor(int x) { _xAttr = x; }
-
- int yAttractor() const { return _yAttr; }
- void setYAttractor(int y) { _yAttr = y; }
-
- int acceleration() const { return int(_accel * 1000000); }
- void setAcceleration(int accel) { _accel = qreal(accel)/1000000.0; }
-
- virtual void advance(QFxParticle &, int interval);
-
-private:
- int _xAttr;
- int _yAttr;
- qreal _accel;
-};
-QML_DECLARE_TYPE(QFxParticleMotionGravity)
-
-class Q_DECLARATIVE_EXPORT QFxParticleMotionWander : public QFxParticleMotion
-{
- Q_OBJECT
-public:
- QFxParticleMotionWander()
- : QFxParticleMotion(), particles(0), _xvariance(0), _yvariance(0) {}
-
- virtual void advance(QFxParticle &, int interval);
- virtual void created(QFxParticle &);
- virtual void destroy(QFxParticle &);
-
- struct Data {
- qreal x_targetV;
- qreal y_targetV;
- qreal x_peak;
- qreal y_peak;
- qreal x_var;
- qreal y_var;
- };
-
- Q_PROPERTY(int xvariance READ xVariance WRITE setXVariance)
- int xVariance() const { return int(_xvariance * 1000); }
- void setXVariance(int var) { _xvariance = var / 1000.0; }
-
- Q_PROPERTY(int yvariance READ yVariance WRITE setYVariance)
- int yVariance() const { return int(_yvariance * 1000); }
- void setYVariance(int var) { _yvariance = var / 1000.0; }
-
- Q_PROPERTY(int pace READ pace WRITE setPace)
- int pace() const { return int(_pace * 1000); }
- void setPace(int pace) { _pace = pace / 1000.0; }
-
-private:
- QFxParticles *particles;
- qreal _xvariance;
- qreal _yvariance;
- qreal _pace;
-};
-QML_DECLARE_TYPE(QFxParticleMotionWander)
-
-class QFxParticlesPrivate;
-class Q_DECLARATIVE_EXPORT QFxParticles : public QFxItem
-{
- Q_OBJECT
-
- Q_PROPERTY(QUrl source READ source WRITE setSource)
- Q_PROPERTY(int count READ count WRITE setCount)
- Q_PROPERTY(int lifeSpan READ lifeSpan WRITE setLifeSpan)
- Q_PROPERTY(int lifeSpanDeviation READ lifeSpanDeviation WRITE setLifeSpanDeviation)
- Q_PROPERTY(int fadeInDuration READ fadeInDuration WRITE setFadeInDuration)
- Q_PROPERTY(int fadeOutDuration READ fadeOutDuration WRITE setFadeOutDuration)
- Q_PROPERTY(qreal angle READ angle WRITE setAngle)
- Q_PROPERTY(qreal angleDeviation READ angleDeviation WRITE setAngleDeviation)
- Q_PROPERTY(qreal velocity READ velocity WRITE setVelocity)
- Q_PROPERTY(qreal velocityDeviation READ velocityDeviation WRITE setVelocityDeviation)
- Q_PROPERTY(bool streamIn READ streamIn WRITE setStreamIn)
- Q_PROPERTY(bool emitting READ emitting WRITE setEmitting)
- Q_PROPERTY(QFxParticleMotion *motion READ motion WRITE setMotion)
- Q_CLASSINFO("DefaultProperty", "motion")
-
-public:
- QFxParticles(QFxItem *parent=0);
- ~QFxParticles();
-
- QUrl source() const;
- void setSource(const QUrl &);
-
- int count() const;
- void setCount(int cnt);
-
- int lifeSpan() const;
- void setLifeSpan(int);
-
- int lifeSpanDeviation() const;
- void setLifeSpanDeviation(int);
-
- int fadeInDuration() const;
- void setFadeInDuration(int);
-
- int fadeOutDuration() const;
- void setFadeOutDuration(int);
-
- qreal angle() const;
- void setAngle(qreal);
-
- qreal angleDeviation() const;
- void setAngleDeviation(qreal);
-
- qreal velocity() const;
- void setVelocity(qreal);
-
- qreal velocityDeviation() const;
- void setVelocityDeviation(qreal);
-
- bool streamIn() const;
- void setStreamIn(bool);
-
- bool emitting() const;
- void setEmitting(bool);
-
- QFxParticleMotion *motion() const;
- void setMotion(QFxParticleMotion *);
-
- virtual void dump(int depth);
- virtual QString propertyInfo() const;
-
-#if defined(QFX_RENDER_QPAINTER)
- void paintContents(QPainter &p);
-#elif defined(QFX_RENDER_OPENGL2)
- void paintGLContents(GLPainter &);
-#endif
-
-protected:
- virtual void componentComplete();
- QFxParticles(QFxParticlesPrivate &dd, QFxItem *parent);
-
-private Q_SLOTS:
- void imageLoaded();
-
-private:
- Q_DISABLE_COPY(QFxParticles)
- Q_DECLARE_PRIVATE(QFxParticles)
-};
-QML_DECLARE_TYPE(QFxParticles)
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/declarative/fx/qfxpath.h b/src/declarative/fx/qfxpath.h
index 39b9d01..04d24c6 100644
--- a/src/declarative/fx/qfxpath.h
+++ b/src/declarative/fx/qfxpath.h
@@ -61,7 +61,6 @@ public:
Q_SIGNALS:
void changed();
};
-QML_DECLARE_TYPE(QFxPathElement)
class Q_DECLARATIVE_EXPORT QFxPathAttribute : public QFxPathElement
{
@@ -83,7 +82,6 @@ private:
QString _name;
qreal _value;
};
-QML_DECLARE_TYPE(QFxPathAttribute)
class Q_DECLARATIVE_EXPORT QFxCurve : public QFxPathElement
{
@@ -106,7 +104,6 @@ private:
qreal _x;
qreal _y;
};
-QML_DECLARE_TYPE(QFxCurve)
class Q_DECLARATIVE_EXPORT QFxPathLine : public QFxCurve
{
@@ -116,7 +113,6 @@ public:
void addToPath(QPainterPath &path);
};
-QML_DECLARE_TYPE(QFxPathLine)
class Q_DECLARATIVE_EXPORT QFxPathQuad : public QFxCurve
{
@@ -139,7 +135,6 @@ private:
qreal _controlX;
qreal _controlY;
};
-QML_DECLARE_TYPE(QFxPathQuad)
class Q_DECLARATIVE_EXPORT QFxPathCubic : public QFxCurve
{
@@ -172,7 +167,6 @@ private:
int _control2X;
int _control2Y;
};
-QML_DECLARE_TYPE(QFxPathCubic)
class Q_DECLARATIVE_EXPORT QFxPathPercent : public QFxPathElement
{
@@ -187,7 +181,6 @@ public:
private:
qreal _value;
};
-QML_DECLARE_TYPE(QFxPathPercent)
class QFxPathPrivate;
class Q_DECLARATIVE_EXPORT QFxPath : public QObject, public QmlParserStatus
@@ -249,9 +242,18 @@ private:
Q_DISABLE_COPY(QFxPath)
Q_DECLARE_PRIVATE(QFxPath)
};
-QML_DECLARE_TYPE(QFxPath)
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxPathElement)
+QML_DECLARE_TYPE(QFxPathAttribute)
+QML_DECLARE_TYPE(QFxCurve)
+QML_DECLARE_TYPE(QFxPathLine)
+QML_DECLARE_TYPE(QFxPathQuad)
+QML_DECLARE_TYPE(QFxPathCubic)
+QML_DECLARE_TYPE(QFxPathPercent)
+QML_DECLARE_TYPE(QFxPath)
+
QT_END_HEADER
+
#endif // QFXPATH_H
diff --git a/src/declarative/fx/qfxpathview.h b/src/declarative/fx/qfxpathview.h
index cbdafa8..159c865 100644
--- a/src/declarative/fx/qfxpathview.h
+++ b/src/declarative/fx/qfxpathview.h
@@ -127,10 +127,11 @@ private:
Q_DISABLE_COPY(QFxPathView)
Q_DECLARE_PRIVATE(QFxPathView)
};
-QML_DECLARE_TYPE(QFxPathView)
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxPathView)
+
QT_END_HEADER
#endif // QFXPATHVIEW_H
diff --git a/src/declarative/fx/qfxrect.cpp b/src/declarative/fx/qfxrect.cpp
index 0536f12..b521d00 100644
--- a/src/declarative/fx/qfxrect.cpp
+++ b/src/declarative/fx/qfxrect.cpp
@@ -617,7 +617,7 @@ void QFxRect::drawRect(QPainter &p)
if (d->gradient && d->gradient->gradient() /*|| p.usingQt() */) {
// XXX This path is still slower than the image path
// Image path won't work for gradients though
- QPainter::RenderHints oldHints = p.renderHints();
+ bool oldAA = p.testRenderHint(QPainter::Antialiasing);
p.setRenderHint(QPainter::Antialiasing);
if (d->pen && d->pen->isValid()) {
QPen pn(QColor(d->pen->color()), d->pen->width());
@@ -630,7 +630,7 @@ void QFxRect::drawRect(QPainter &p)
p.drawRoundedRect(0, 0, width(), height(), d->radius, d->radius);
else
p.drawRect(0, 0, width(), height());
- p.setRenderHints(oldHints);
+ p.setRenderHint(QPainter::Antialiasing, oldAA);
} else {
int offset = 0;
const int pw = d->pen && d->pen->isValid() ? (d->pen->width()+1)/2*2 : 0;
diff --git a/src/declarative/fx/qfxrect.h b/src/declarative/fx/qfxrect.h
index df490b0..2b35d8d 100644
--- a/src/declarative/fx/qfxrect.h
+++ b/src/declarative/fx/qfxrect.h
@@ -77,7 +77,6 @@ private:
QColor _color;
bool _valid;
};
-QML_DECLARE_TYPE(QFxPen)
class Q_DECLARATIVE_EXPORT QFxGradientStop : public QObject
{
@@ -102,7 +101,6 @@ private:
qreal m_position;
QColor m_color;
};
-QML_DECLARE_TYPE(QFxGradientStop)
class Q_DECLARATIVE_EXPORT QFxGradient : public QObject
{
@@ -130,7 +128,6 @@ private:
mutable QGradient *m_gradient;
friend class QFxGradientStop;
};
-QML_DECLARE_TYPE(QFxGradient)
class QFxRectPrivate;
class Q_DECLARATIVE_EXPORT QFxRect : public QFxItem
@@ -184,10 +181,14 @@ private:
Q_DISABLE_COPY(QFxRect)
Q_DECLARE_PRIVATE(QFxRect)
};
-QML_DECLARE_TYPE(QFxRect)
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxPen)
+QML_DECLARE_TYPE(QFxGradientStop)
+QML_DECLARE_TYPE(QFxGradient)
+QML_DECLARE_TYPE(QFxRect)
+
QT_END_HEADER
#endif // QFXRECT_H
diff --git a/src/declarative/fx/qfxreflectionfilter.h b/src/declarative/fx/qfxreflectionfilter.h
index 6e56b5e..d862040 100644
--- a/src/declarative/fx/qfxreflectionfilter.h
+++ b/src/declarative/fx/qfxreflectionfilter.h
@@ -87,10 +87,11 @@ private:
Q_DISABLE_COPY(QFxReflectionFilter)
QFxReflectionFilterPrivate *d;
};
-QML_DECLARE_TYPE(QFxReflectionFilter)
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxReflectionFilter)
+
QT_END_HEADER
#endif // QFXREFLECTIONFILTER_H
diff --git a/src/declarative/fx/qfxrepeater.h b/src/declarative/fx/qfxrepeater.h
index c1b194a..b82b9b0 100644
--- a/src/declarative/fx/qfxrepeater.h
+++ b/src/declarative/fx/qfxrepeater.h
@@ -44,12 +44,12 @@
#include <QtDeclarative/qfxitem.h>
-
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
+
class QFxRepeaterPrivate;
class Q_DECLARATIVE_EXPORT QFxRepeater : public QFxItem
{
@@ -80,10 +80,11 @@ private:
Q_DISABLE_COPY(QFxRepeater)
Q_DECLARE_PRIVATE(QFxRepeater)
};
-QML_DECLARE_TYPE(QFxRepeater)
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxRepeater)
+
QT_END_HEADER
-#endif // _QFXREPEATER_H_
+#endif // QFXREPEATER_H
diff --git a/src/declarative/fx/qfxscalegrid.h b/src/declarative/fx/qfxscalegrid.h
index c59cb32..03b2dd3 100644
--- a/src/declarative/fx/qfxscalegrid.h
+++ b/src/declarative/fx/qfxscalegrid.h
@@ -110,10 +110,11 @@ private:
int _b;
QString _pix;
};
-QML_DECLARE_TYPE(QFxScaleGrid)
-
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxScaleGrid)
+
QT_END_HEADER
+
#endif // QFXSCALEGRID_H
diff --git a/src/declarative/fx/qfxshadowfilter.cpp b/src/declarative/fx/qfxshadowfilter.cpp
index 10c332c..d37d565 100644
--- a/src/declarative/fx/qfxshadowfilter.cpp
+++ b/src/declarative/fx/qfxshadowfilter.cpp
@@ -47,9 +47,9 @@
#include <glbasicshaders.h>
#endif
-class QFxShadowFilterPrivate
-
QT_BEGIN_NAMESPACE
+
+class QFxShadowFilterPrivate
{
public:
QFxShadowFilterPrivate()
diff --git a/src/declarative/fx/qfxshadowfilter.h b/src/declarative/fx/qfxshadowfilter.h
index 67d165a..1cbe54f 100644
--- a/src/declarative/fx/qfxshadowfilter.h
+++ b/src/declarative/fx/qfxshadowfilter.h
@@ -77,10 +77,11 @@ protected:
private:
QFxShadowFilterPrivate *d;
};
-QML_DECLARE_TYPE(QFxShadowFilter)
-
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxShadowFilter)
+
QT_END_HEADER
-#endif // _QFXSHADOWFILTER_H_
+
+#endif // QFXSHADOWFILTER_H
diff --git a/src/declarative/fx/qfxtext.h b/src/declarative/fx/qfxtext.h
index b929a6f..1f5a7b8 100644
--- a/src/declarative/fx/qfxtext.h
+++ b/src/declarative/fx/qfxtext.h
@@ -143,10 +143,11 @@ private:
Q_DISABLE_COPY(QFxText)
Q_DECLARE_PRIVATE(QFxText)
};
-QML_DECLARE_TYPE(QFxText)
-
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxText)
+
QT_END_HEADER
+
#endif
diff --git a/src/declarative/fx/qfxtextedit.h b/src/declarative/fx/qfxtextedit.h
index b761a1b..24ba3fe 100644
--- a/src/declarative/fx/qfxtextedit.h
+++ b/src/declarative/fx/qfxtextedit.h
@@ -202,10 +202,11 @@ private:
Q_DISABLE_COPY(QFxTextEdit)
Q_DECLARE_PRIVATE(QFxTextEdit)
};
-QML_DECLARE_TYPE(QFxTextEdit)
-
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxTextEdit)
+
QT_END_HEADER
+
#endif
diff --git a/src/declarative/fx/qfxtransform.cpp b/src/declarative/fx/qfxtransform.cpp
index a4c5d22..0f0ce80 100644
--- a/src/declarative/fx/qfxtransform.cpp
+++ b/src/declarative/fx/qfxtransform.cpp
@@ -46,11 +46,11 @@
#include <math.h>
#ifndef M_PI
-
-QT_BEGIN_NAMESPACE
#define M_PI 3.14159265358979323846
#endif
+QT_BEGIN_NAMESPACE
+
QML_DEFINE_NOCREATE_TYPE(QFxTransform);
/*!
@@ -84,6 +84,139 @@ void QFxTransform::update()
}
/*!
+ \qmlclass Scale
+ \brief A Scale object provides a way to scale an Item.
+
+ The scale object gives more control over scaling than using Item's scale property. Specifically,
+ it allows a different scale for the x and y axes, and allows the scale to be relative to an
+ arbitrary point.
+
+ The following example scales the X axis of the Rect, relative to its interior point 25, 25:
+ \qml
+ Rect {
+ width: 100; height: 100
+ color: "blue"
+ transform: Scale { originX: 25; originY: 25; xScale: 3}
+ }
+ \endqml
+*/
+
+QFxScale::QFxScale(QObject *parent)
+: QFxTransform(parent), _originX(0), _originY(0), _xScale(1), _yScale(1), _dirty(true)
+{
+}
+
+QFxScale::~QFxScale()
+{
+}
+
+/*!
+ \qmlproperty real Scale::originX
+ \qmlproperty real Scale::originY
+
+ The origin point for the scale. The scale will be relative to this point.
+*/
+qreal QFxScale::originX() const
+{
+ return _originX;
+}
+
+void QFxScale::setOriginX(qreal ox)
+{
+ _originX = ox;
+ update();
+}
+
+qreal QFxScale::originY() const
+{
+ return _originY;
+}
+
+void QFxScale::setOriginY(qreal oy)
+{
+ _originY = oy;
+ update();
+}
+
+/*!
+ \qmlproperty real Scale::xScale
+
+ The scaling factor for the X axis.
+*/
+qreal QFxScale::xScale() const
+{
+ return _xScale;
+}
+
+void QFxScale::setXScale(qreal scale)
+{
+ if (_xScale == scale)
+ return;
+ _xScale = scale;
+ update();
+ emit scaleChanged();
+}
+
+/*!
+ \qmlproperty real Scale::yScale
+
+ The scaling factor for the Y axis.
+*/
+qreal QFxScale::yScale() const
+{
+ return _yScale;
+}
+
+void QFxScale::setYScale(qreal scale)
+{
+ if (_yScale == scale)
+ return;
+ _yScale = scale;
+ update();
+ emit scaleChanged();
+}
+
+bool QFxScale::isIdentity() const
+{
+ return (_xScale == 1. && _yScale == 1.);
+}
+
+#if defined(QFX_RENDER_QPAINTER)
+QTransform QFxScale::transform() const
+{
+ if (_dirty) {
+ _transform = QTransform();
+ _dirty = false;
+ _transform.translate(_originX, _originY);
+ _transform.scale(_xScale, _yScale);
+ _transform.translate(-_originX, -_originY);
+ }
+ return _transform;
+}
+#elif defined(QFX_RENDER_OPENGL)
+QMatrix4x4 QFxScale::transform() const
+{
+ if (_dirty) {
+ _transform = QMatrix4x4();
+ _dirty = false;
+ _transform.translate(_originX, _originY);
+ _transform.scale(_xScale, _yScale);
+ _transform.translate(-_originX, -_originY);
+ }
+ return _transform;
+}
+#endif
+
+void QFxScale::update()
+{
+ _dirty = true;
+ QFxTransform::update();
+}
+
+QML_DEFINE_TYPE(QFxScale, Scale)
+
+
+/*!
\qmlclass Axis
\brief A Axis object defines an axis that can be used for rotation or translation.
diff --git a/src/declarative/fx/qfxtransform.h b/src/declarative/fx/qfxtransform.h
index 7be8adc..e0bd276 100644
--- a/src/declarative/fx/qfxtransform.h
+++ b/src/declarative/fx/qfxtransform.h
@@ -67,7 +67,48 @@ public:
virtual bool isIdentity() const;
virtual QSimpleCanvas::Matrix transform() const;
};
-QML_DECLARE_TYPE(QFxTransform)
+
+class Q_DECLARATIVE_EXPORT QFxScale : public QFxTransform
+{
+ Q_OBJECT
+
+ Q_PROPERTY(qreal originX READ originX WRITE setOriginX)
+ Q_PROPERTY(qreal originY READ originY WRITE setOriginY)
+ Q_PROPERTY(qreal xScale READ xScale WRITE setXScale NOTIFY scaleChanged())
+ Q_PROPERTY(qreal yScale READ yScale WRITE setYScale NOTIFY scaleChanged())
+public:
+ QFxScale(QObject *parent=0);
+ ~QFxScale();
+
+ qreal originX() const;
+ void setOriginX(qreal);
+
+ qreal originY() const;
+ void setOriginY(qreal);
+
+ qreal xScale() const;
+ void setXScale(qreal);
+
+ qreal yScale() const;
+ void setYScale(qreal);
+
+ virtual bool isIdentity() const;
+ virtual QSimpleCanvas::Matrix transform() const;
+
+Q_SIGNALS:
+ void scaleChanged();
+
+private Q_SLOTS:
+ void update();
+private:
+ qreal _originX;
+ qreal _originY;
+ qreal _xScale;
+ qreal _yScale;
+
+ mutable bool _dirty;
+ mutable QSimpleCanvas::Matrix _transform;
+};
class Q_DECLARATIVE_EXPORT QFxAxis : public QObject
{
@@ -107,7 +148,6 @@ private:
qreal _endY;
qreal _endZ;
};
-QML_DECLARE_TYPE(QFxAxis)
class Q_DECLARATIVE_EXPORT QFxRotation : public QFxTransform
{
@@ -145,7 +185,6 @@ private:
mutable bool _dirty;
mutable QSimpleCanvas::Matrix _transform;
};
-QML_DECLARE_TYPE(QFxRotation)
class Q_DECLARATIVE_EXPORT QFxRotation3D : public QFxTransform
{
@@ -174,7 +213,6 @@ private:
mutable bool _dirty;
mutable QSimpleCanvas::Matrix _transform;
};
-QML_DECLARE_TYPE(QFxRotation3D)
class Q_DECLARATIVE_EXPORT QFxTranslation3D : public QFxTransform
{
@@ -203,7 +241,6 @@ private:
mutable bool _dirty;
mutable QSimpleCanvas::Matrix _transform;
};
-QML_DECLARE_TYPE(QFxTranslation3D)
class Q_DECLARATIVE_EXPORT QFxPerspective : public QFxTransform
{
@@ -244,7 +281,6 @@ private:
qreal _angle;
qreal _aspect;
};
-QML_DECLARE_TYPE(QFxPerspective)
class Q_DECLARATIVE_EXPORT QFxSquish : public QFxTransform
{
@@ -310,10 +346,18 @@ private:
QSizeF s;
QPointF p1, p2, p3, p4;
};
-QML_DECLARE_TYPE(QFxSquish)
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxTransform)
+QML_DECLARE_TYPE(QFxScale)
+QML_DECLARE_TYPE(QFxAxis)
+QML_DECLARE_TYPE(QFxRotation)
+QML_DECLARE_TYPE(QFxRotation3D)
+QML_DECLARE_TYPE(QFxTranslation3D)
+QML_DECLARE_TYPE(QFxPerspective)
+QML_DECLARE_TYPE(QFxSquish)
+
QT_END_HEADER
#endif // QFXTRANSFORM_H
diff --git a/src/declarative/fx/qfxvisualitemmodel.cpp b/src/declarative/fx/qfxvisualitemmodel.cpp
index c60a379..d3ab4cc 100644
--- a/src/declarative/fx/qfxvisualitemmodel.cpp
+++ b/src/declarative/fx/qfxvisualitemmodel.cpp
@@ -52,9 +52,9 @@
#include "qmllistaccessor.h"
#include "qfxvisualitemmodel.h"
+QML_DECLARE_TYPE(QListModelInterface)
QT_BEGIN_NAMESPACE
-QML_DECLARE_TYPE(QListModelInterface)
class QFxVisualItemModelParts;
class QFxVisualItemModelData;
diff --git a/src/declarative/fx/qfxvisualitemmodel.h b/src/declarative/fx/qfxvisualitemmodel.h
index 968cc2e..9cacde4 100644
--- a/src/declarative/fx/qfxvisualitemmodel.h
+++ b/src/declarative/fx/qfxvisualitemmodel.h
@@ -123,10 +123,11 @@ private Q_SLOTS:
private:
Q_DISABLE_COPY(QFxVisualItemModel)
};
-QML_DECLARE_TYPE(QFxVisualItemModel)
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxVisualItemModel)
+
QT_END_HEADER
#endif // QFXVISUALITEMMODEL_H
diff --git a/src/declarative/fx/qfxwebview.cpp b/src/declarative/fx/qfxwebview.cpp
index f4a06ce..3ab64bc 100644
--- a/src/declarative/fx/qfxwebview.cpp
+++ b/src/declarative/fx/qfxwebview.cpp
@@ -1010,6 +1010,6 @@ QObject *QFxWebPage::createPlugin(const QString &, const QUrl &url, const QStrin
return new QWidget_Dummy_Plugin(comp,view(),paramNames,paramValues);
}
-#include "qfxwebview.moc"
-
QT_END_NAMESPACE
+
+#include "qfxwebview.moc"
diff --git a/src/declarative/fx/qfxwebview.h b/src/declarative/fx/qfxwebview.h
index 0ac1895..f5fd721 100644
--- a/src/declarative/fx/qfxwebview.h
+++ b/src/declarative/fx/qfxwebview.h
@@ -49,14 +49,14 @@
#include <QtNetwork/qnetworkaccessmanager.h>
#include <QtWebKit/QWebPage>
-
QT_BEGIN_HEADER
+class QWebHistory;
+class QWebSettings;
+
QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
-class QWebHistory;
-class QWebSettings;
class QFxWebViewPrivate;
class QNetworkRequest;
class QFxWebView;
@@ -206,10 +206,11 @@ private:
Q_DISABLE_COPY(QFxWebView)
Q_DECLARE_PRIVATE(QFxWebView)
};
-QML_DECLARE_TYPE(QFxWebView)
-
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxWebView)
+
QT_END_HEADER
+
#endif
diff --git a/src/declarative/fx/qfxwidgetcontainer.h b/src/declarative/fx/qfxwidgetcontainer.h
index cc36010..862a280 100644
--- a/src/declarative/fx/qfxwidgetcontainer.h
+++ b/src/declarative/fx/qfxwidgetcontainer.h
@@ -72,10 +72,11 @@ protected:
private:
QGraphicsWidget *_graphicsWidget;
};
-QML_DECLARE_TYPE(QFxWidgetContainer)
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxWidgetContainer)
+
QT_END_HEADER
#endif // QFXGRAPHICSWIDGET_H