summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@nokia.com>2009-07-27 04:45:50 (GMT)
committerLars Knoll <lars.knoll@nokia.com>2009-07-29 03:47:20 (GMT)
commitd53f55357ed9581b02088dff95fbe955412f476d (patch)
tree235e6467ed32d59f5bbd9b78c3a0e5e109c2f004
parentb44728b41ccc24b272f49e878cd28b29430aad57 (diff)
downloadQt-d53f55357ed9581b02088dff95fbe955412f476d.zip
Qt-d53f55357ed9581b02088dff95fbe955412f476d.tar.gz
Qt-d53f55357ed9581b02088dff95fbe955412f476d.tar.bz2
make QFxItem use QGraphicsTransform
removed all the QFxTransform code and converted QFxItem::transform to use a QmlList instead of a QList.
-rw-r--r--src/declarative/fx/fx.pri2
-rw-r--r--src/declarative/fx/qfxflipable.cpp10
-rw-r--r--src/declarative/fx/qfxflipable.h8
-rw-r--r--src/declarative/fx/qfxitem.cpp81
-rw-r--r--src/declarative/fx/qfxitem.h15
-rw-r--r--src/declarative/fx/qfxitem_p.h10
-rw-r--r--src/declarative/fx/qfxtransform.cpp919
-rw-r--r--src/declarative/fx/qfxtransform.h356
-rw-r--r--src/declarative/fx/qfxwebview.cpp1
9 files changed, 83 insertions, 1319 deletions
diff --git a/src/declarative/fx/fx.pri b/src/declarative/fx/fx.pri
index 24c5536..9b4b5ab 100644
--- a/src/declarative/fx/fx.pri
+++ b/src/declarative/fx/fx.pri
@@ -36,7 +36,6 @@ HEADERS += \
fx/qfxtextedit_p.h \
fx/qfxtext.h \
fx/qfxtext_p.h \
- fx/qfxtransform.h \
fx/qfxpixmap.cpp \
fx/qfxvisualitemmodel.h \
fx/qfxlistview.h \
@@ -65,7 +64,6 @@ SOURCES += \
fx/qfxlineedit.cpp \
fx/qfxtext.cpp \
fx/qfxtextedit.cpp \
- fx/qfxtransform.cpp \
fx/qfxpixmap.cpp \
fx/qfxvisualitemmodel.cpp \
fx/qfxlistview.cpp \
diff --git a/src/declarative/fx/qfxflipable.cpp b/src/declarative/fx/qfxflipable.cpp
index fafd04a..bd01d48 100644
--- a/src/declarative/fx/qfxflipable.cpp
+++ b/src/declarative/fx/qfxflipable.cpp
@@ -41,7 +41,7 @@
#include "qfxflipable.h"
#include "private/qfxitem_p.h"
-#include "qfxtransform.h"
+#include "QtGui/qgraphicstransform.h"
#include <QtDeclarative/qmlinfo.h>
QT_BEGIN_NAMESPACE
@@ -59,8 +59,8 @@ public:
QFxFlipable::Side current;
QFxItem *front;
QFxItem *back;
- QFxAxis *axis;
- QFxRotation3D axisRotation;
+ QGraphicsAxis *axis;
+ QGraphicsRotation3D axisRotation;
qreal rotation;
};
@@ -180,13 +180,13 @@ void QFxFlipable::setBack(QFxItem *back)
information on specifying an axis.
*/
-QFxAxis *QFxFlipable::axis()
+QGraphicsAxis *QFxFlipable::axis()
{
Q_D(QFxFlipable);
return d->axis;
}
-void QFxFlipable::setAxis(QFxAxis *axis)
+void QFxFlipable::setAxis(QGraphicsAxis *axis)
{
Q_D(QFxFlipable);
//### disconnect if we are already connected?
diff --git a/src/declarative/fx/qfxflipable.h b/src/declarative/fx/qfxflipable.h
index 5aa038d..4306e9f 100644
--- a/src/declarative/fx/qfxflipable.h
+++ b/src/declarative/fx/qfxflipable.h
@@ -52,7 +52,7 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
-class QFxAxis;
+class QGraphicsAxis;
class QFxFlipablePrivate;
class Q_DECLARATIVE_EXPORT QFxFlipable : public QFxItem
{
@@ -61,7 +61,7 @@ class Q_DECLARATIVE_EXPORT QFxFlipable : public QFxItem
Q_ENUMS(Side)
Q_PROPERTY(QFxItem *front READ front WRITE setFront)
Q_PROPERTY(QFxItem *back READ back WRITE setBack)
- Q_PROPERTY(QFxAxis *axis READ axis WRITE setAxis)
+ Q_PROPERTY(QGraphicsAxis *axis READ axis WRITE setAxis)
Q_PROPERTY(qreal rotation READ rotation WRITE setRotation)
Q_PROPERTY(Side side READ side NOTIFY sideChanged)
public:
@@ -74,8 +74,8 @@ public:
QFxItem *back();
void setBack(QFxItem *);
- QFxAxis *axis();
- void setAxis(QFxAxis *axis);
+ QGraphicsAxis *axis();
+ void setAxis(QGraphicsAxis *axis);
qreal rotation() const;
void setRotation(qreal angle);
diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp
index 009e192..efdd4fc 100644
--- a/src/declarative/fx/qfxitem.cpp
+++ b/src/declarative/fx/qfxitem.cpp
@@ -48,6 +48,7 @@
#include <QGraphicsSceneMouseEvent>
#include <QtScript/qscriptengine.h>
#include <private/qfxperf_p.h>
+#include <QtGui/qgraphicstransform.h>
#include <QtDeclarative/qmlengine.h>
#include <private/qmlengine_p.h>
@@ -55,7 +56,6 @@
#include "qlistmodelinterface.h"
#include "qfxanchors_p.h"
-#include "qfxtransform.h"
#include "qfxscalegrid.h"
#include "qfxview.h"
#include "qmlstategroup.h"
@@ -74,6 +74,12 @@ QT_BEGIN_NAMESPACE
QML_DEFINE_NOCREATE_TYPE(QFxContents)
QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Item,QFxItem)
+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,Axis,QGraphicsAxis)
+QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Rotation,QGraphicsRotation)
+QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Rotation3D,QGraphicsRotation3D)
+
/*!
\group group_animation
\title Animation
@@ -633,6 +639,50 @@ void QFxItemPrivate::children_clear()
// ###
}
+
+void QFxItemPrivate::transform_removeAt(int i)
+{
+ if (!transformData)
+ return;
+ transformData->graphicsTransforms.removeAt(i);
+ dirtySceneTransform = 1;
+}
+
+int QFxItemPrivate::transform_count() const
+{
+ return transformData ? transformData->graphicsTransforms.size() : 0;
+}
+
+void QFxItemPrivate::transform_append(QGraphicsTransform *item)
+{
+ if (!transformData)
+ transformData = new QGraphicsItemPrivate::TransformData;
+ if (!transformData->graphicsTransforms.contains(item))
+ transformData->graphicsTransforms.append(item);
+ transformData->onlyTransform = false;
+ dirtySceneTransform = 1;
+}
+
+void QFxItemPrivate::transform_insert(int, QGraphicsTransform *)
+{
+ // ###
+}
+
+QGraphicsTransform *QFxItemPrivate::transform_at(int idx) const
+{
+ if (!transformData)
+ return 0;
+ return transformData->graphicsTransforms.at(idx);
+}
+
+void QFxItemPrivate::transform_clear()
+{
+ if (!transformData)
+ return;
+ transformData->graphicsTransforms.clear();
+ dirtySceneTransform = 1;
+}
+
/*!
\qmlproperty list<Object> Item::data
\default
@@ -1652,17 +1702,14 @@ void QFxItem::setState(const QString &state)
/*!
\property QFxItem::transform
- This property holds the list of transformations to apply.
-
- For more information see \l Transform.
+ This property holds a list of transformations set on the item.
*/
-QList<QFxTransform *> *QFxItem::transform()
+QmlList<QGraphicsTransform *>* QFxItem::transform()
{
Q_D(QFxItem);
- return &(d->_transform);
+ return &(d->transform);
}
-
/*!
Creates a new child of the given component \a type. The
newChildCreated() signal will be emitted when and if the child is
@@ -1733,25 +1780,6 @@ void QFxItem::componentComplete()
d->_stateGroup->componentComplete();
if (d->_anchors)
d->anchors()->d_func()->updateOnComplete();
- if (!d->_transform.isEmpty())
- updateTransform();
-}
-
-/*!
- \internal
-*/
-void QFxItem::updateTransform()
-{
- Q_D(QFxItem);
- QTransform trans;
- for (int ii = d->_transform.count() - 1; ii >= 0; --ii) {
- QFxTransform *a = d->_transform.at(ii);
- if (!a->isIdentity())
- trans = a->transform() * trans;
- }
-
- setTransform(trans);
- transformChanged(trans);
}
/*!
@@ -1759,6 +1787,7 @@ void QFxItem::updateTransform()
*/
void QFxItem::transformChanged(const QTransform &)
{
+ // ### FIXME
}
QmlStateGroup *QFxItemPrivate::states()
diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h
index 791d215..f4051e5 100644
--- a/src/declarative/fx/qfxitem.h
+++ b/src/declarative/fx/qfxitem.h
@@ -49,6 +49,7 @@
#include <QtDeclarative/qml.h>
#include <QtDeclarative/qmlcomponent.h>
#include <QtGui/qgraphicsitem.h>
+#include <QtGui/qgraphicstransform.h>
#include <QtGui/qfont.h>
QT_BEGIN_HEADER
@@ -57,6 +58,8 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
+class QGraphicsTransform;
+
class QFxItem;
class Q_DECLARATIVE_EXPORT QFxContents : public QObject
{
@@ -112,7 +115,6 @@ public:
class QmlState;
class QmlTransition;
-class QFxTransform;
class QFxKeyEvent;
class QFxAnchors;
class QFxItemPrivate;
@@ -145,7 +147,7 @@ class Q_DECLARATIVE_EXPORT QFxItem : public QGraphicsObject, public QmlParserSta
Q_PROPERTY(bool clip READ clip WRITE setClip) // ### move to QGI/QGO, NOTIFY
Q_PROPERTY(bool focus READ hasFocus WRITE setFocus NOTIFY focusChanged FINAL)
Q_PROPERTY(bool activeFocus READ hasActiveFocus NOTIFY activeFocusChanged FINAL)
- Q_PROPERTY(QList<QFxTransform *>* transform READ transform) // ## QGI/QGO
+ Q_PROPERTY(QmlList<QGraphicsTransform *>* transform READ transform DESIGNABLE false FINAL) // ## QGI/QGO
Q_PROPERTY(TransformOrigin transformOrigin READ transformOrigin WRITE setTransformOrigin) // ### move to QGI
Q_ENUMS(TransformOrigin)
Q_CLASSINFO("DefaultProperty", "data")
@@ -204,13 +206,11 @@ public:
qreal baselineOffset() const;
void setBaselineOffset(qreal);
- QList<QFxTransform *> *transform();
+ QmlList<QGraphicsTransform *> *transform();
bool isClassComplete() const;
bool isComponentComplete() const;
- void updateTransform(); // ### private!
-
bool keepMouseGrab() const;
void setKeepMouseGrab(bool);
@@ -327,6 +327,11 @@ QT_END_NAMESPACE
QML_DECLARE_TYPE(QFxContents)
QML_DECLARE_TYPE(QFxItem)
+QML_DECLARE_TYPE(QGraphicsTransform)
+QML_DECLARE_TYPE(QGraphicsScale)
+QML_DECLARE_TYPE(QGraphicsAxis)
+QML_DECLARE_TYPE(QGraphicsRotation)
+QML_DECLARE_TYPE(QGraphicsRotation3D)
QT_END_HEADER
diff --git a/src/declarative/fx/qfxitem_p.h b/src/declarative/fx/qfxitem_p.h
index 7bdd382..ebd77f8 100644
--- a/src/declarative/fx/qfxitem_p.h
+++ b/src/declarative/fx/qfxitem_p.h
@@ -130,7 +130,15 @@ public:
void children_clear();
QML_DECLARE_LIST_PROXY(QFxItemPrivate, QFxItem *, children)
- QList<QFxTransform *> _transform;
+ // transform property
+ void transform_removeAt(int);
+ int transform_count() const;
+ void transform_append(QGraphicsTransform *);
+ void transform_insert(int, QGraphicsTransform *);
+ QGraphicsTransform *transform_at(int) const;
+ void transform_clear();
+ QML_DECLARE_LIST_PROXY(QFxItemPrivate, QGraphicsTransform *, transform)
+
QFxAnchors *anchors() {
if (!_anchors) {
Q_Q(QFxItem);
diff --git a/src/declarative/fx/qfxtransform.cpp b/src/declarative/fx/qfxtransform.cpp
deleted file mode 100644
index 9fc66ef..0000000
--- a/src/declarative/fx/qfxtransform.cpp
+++ /dev/null
@@ -1,919 +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 <QDebug>
-#include "private/qfxitem_p.h"
-#include "qfxtransform.h"
-#include <QtDeclarative/qmlinfo.h>
-
-#include <math.h>
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
-QT_BEGIN_NAMESPACE
-
-QML_DEFINE_NOCREATE_TYPE(QFxTransform);
-
-/*!
- \qmlclass Transform
- \brief A transformation.
-*/
-QFxTransform::QFxTransform(QObject *parent) :
- QObject(parent)
-{
-}
-
-QFxTransform::~QFxTransform()
-{
-}
-
-bool QFxTransform::isIdentity() const
-{
- return true;
-}
-
-QTransform QFxTransform::transform() const
-{
- return QTransform();
-}
-
-void QFxTransform::update()
-{
- QFxItem *item = qobject_cast<QFxItem *>(parent());
- if (item)
- item->updateTransform();
-}
-
-/*!
- \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.);
-}
-
-QTransform QFxScale::transform() const
-{
- if (_dirty) {
- _transform = QTransform();
- _dirty = false;
- _transform.translate(_originX, _originY);
- _transform.scale(_xScale, _yScale);
- _transform.translate(-_originX, -_originY);
- }
- return _transform;
-}
-
-void QFxScale::update()
-{
- _dirty = true;
- QFxTransform::update();
-}
-
-QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Scale,QFxScale)
-
-
-/*!
- \qmlclass Axis
- \brief A Axis object defines an axis that can be used for rotation or translation.
-
- An axis is specified by 2 points in 3D space: a start point and
- an end point. While technically the axis is the line running through these two points
- (and thus many different sets of two points could define the same axis), the distance
- between the points does matter for translation along an axis.
-
- \image 3d-axis.png
-
- \qml
- Axis { startX: 20; startY: 0; endX: 40; endY: 60; endZ: 20 }
- \endqml
-*/
-
-QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Axis,QFxAxis)
-
-QFxAxis::QFxAxis(QObject *parent)
-: QObject(parent), _startX(0), _startY(0), _endX(0), _endY(0), _endZ(0)
-{
-}
-
-QFxAxis::~QFxAxis()
-{
-}
-
-/*!
- \qmlproperty real Axis::startX
- \qmlproperty real Axis::startY
-
- The start point of the axis. The z-position of the start point is assumed to be 0, and cannot
- be changed.
-*/
-qreal QFxAxis::startX() const
-{
- return _startX;
-}
-
-void QFxAxis::setStartX(qreal x)
-{
- _startX = x;
- emit updated();
-}
-
-qreal QFxAxis::startY() const
-{
- return _startY;
-}
-
-void QFxAxis::setStartY(qreal y)
-{
- _startY = y;
- emit updated();
-}
-
-/*!
- \qmlproperty real Axis::endX
- \qmlproperty real Axis::endY
- \qmlproperty real Axis::endZ
-
- The end point of the axis.
-*/
-qreal QFxAxis::endX() const
-{
- return _endX;
-}
-
-void QFxAxis::setEndX(qreal x)
-{
- _endX = x;
- emit updated();
-}
-
-qreal QFxAxis::endY() const
-{
- return _endY;
-}
-
-void QFxAxis::setEndY(qreal y)
-{
- _endY = y;
- emit updated();
-}
-
-qreal QFxAxis::endZ() const
-{
- return _endZ;
-}
-
-void QFxAxis::setEndZ(qreal z)
-{
- _endZ = z;
- emit updated();
-}
-
-/*!
- \qmlclass Rotation
- \brief A Rotation object provides a way to rotate an Item around a point.
-
- The following example rotates a Rect around its interior point 25, 25:
- \qml
- Rect {
- width: 100; height: 100
- color: "blue"
- transform: Rotation { originX: 25; originY: 25; angle: 45}
- }
- \endqml
-*/
-
-QFxRotation::QFxRotation(QObject *parent)
-: QFxTransform(parent), _originX(0), _originY(0), _angle(0), _dirty(true)
-{
-}
-
-QFxRotation::~QFxRotation()
-{
-}
-
-/*!
- \qmlproperty real Rotation::originX
- \qmlproperty real Rotation::originY
-
- The point to rotate around.
-*/
-qreal QFxRotation::originX() const
-{
- return _originX;
-}
-
-void QFxRotation::setOriginX(qreal ox)
-{
- _originX = ox;
- update();
-}
-
-qreal QFxRotation::originY() const
-{
- return _originY;
-}
-
-void QFxRotation::setOriginY(qreal oy)
-{
- _originY = oy;
- update();
-}
-
-/*!
- \qmlproperty real Rotation::angle
-
- The angle, in degrees, to rotate.
-*/
-qreal QFxRotation::angle() const
-{
- return _angle;
-}
-
-void QFxRotation::setAngle(qreal angle)
-{
- if (_angle == angle)
- return;
- _angle = angle;
- update();
- emit angleChanged();
-}
-
-bool QFxRotation::isIdentity() const
-{
- return (_angle == 0.);
-}
-
-QTransform QFxRotation::transform() const
-{
- if (_dirty) {
- _transform = QTransform();
- _dirty = false;
- _transform.translate(_originX, _originY);
- _transform.rotate(_angle);
- _transform.translate(-_originX, -_originY);
- }
- return _transform;
-}
-
-void QFxRotation::update()
-{
- _dirty = true;
- QFxTransform::update();
-}
-
-QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Rotation,QFxRotation)
-
-/*!
- \qmlclass Rotation3D
- \brief A Rotation3D object provides a way to rotate an Item around an axis.
-
- Here is an example of various rotations applied to an \l Image.
- \snippet doc/src/snippets/declarative/rotation.qml 0
-
- \image axisrotation.png
-*/
-
-QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Rotation3D,QFxRotation3D)
-
-QFxRotation3D::QFxRotation3D(QObject *parent)
-: QFxTransform(parent), _angle(0), _dirty(true)
-{
- connect(&_axis, SIGNAL(updated()), this, SLOT(update()));
-}
-
-QFxRotation3D::~QFxRotation3D()
-{
-}
-
-/*!
- \qmlproperty real Rotation3D::axis.startX
- \qmlproperty real Rotation3D::axis.startY
- \qmlproperty real Rotation3D::axis.endX
- \qmlproperty real Rotation3D::axis.endY
- \qmlproperty real Rotation3D::axis.endZ
-
- A rotation axis is specified by 2 points in 3D space: a start point and
- an end point. The z-position of the start point is assumed to be 0, and cannot
- be changed.
-
- \image 3d-rotation-axis.png
-
- \sa Axis
-*/
-QFxAxis *QFxRotation3D::axis()
-{
- return &_axis;
-}
-
-/*!
- \qmlproperty real Rotation3D::angle
-
- The angle, in degrees, to rotate around the specified axis.
-*/
-qreal QFxRotation3D::angle() const
-{
- return _angle;
-}
-
-void QFxRotation3D::setAngle(qreal angle)
-{
- _angle = angle;
- update();
-}
-
-bool QFxRotation3D::isIdentity() const
-{
- return (_angle == 0.) || (_axis.endZ() == 0. && _axis.endY() == _axis.startY() && _axis.endX() == _axis.startX());
-}
-
-const qreal inv_dist_to_plane = 1. / 1024.;
-QTransform QFxRotation3D::transform() const
-{
- if (_dirty) {
- _transform = QTransform();
-
- if (!isIdentity()) {
- if (angle() != 0.) {
- QTransform rotTrans;
- rotTrans.translate(-_axis.startX(), -_axis.startY());
- QTransform rotTrans2;
- rotTrans2.translate(_axis.startX(), _axis.startY());
-
- qreal rad = angle() * 2. * M_PI / 360.;
- qreal c = ::cos(rad);
- qreal s = ::sin(rad);
-
- qreal x = _axis.endX() - _axis.startX();
- qreal y = _axis.endY() - _axis.startY();
- qreal z = _axis.endZ();
-
- qreal len = x * x + y * y + z * z;
- if (len != 1.) {
- len = ::sqrt(len);
- x /= len;
- y /= len;
- z /= len;
- }
-
- QTransform rot(x*x*(1-c)+c, x*y*(1-c)-z*s, x*z*(1-c)+y*s*inv_dist_to_plane,
- y*x*(1-c)+z*s, y*y*(1-c)+c, y*z*(1-c)-x*s*inv_dist_to_plane,
- 0, 0, 1);
-
- _transform *= rotTrans;
- _transform *= rot;
- _transform *= rotTrans2;
- }
- }
-
- _dirty = false;
- }
-
- return _transform;
-}
-
-void QFxRotation3D::update()
-{
- _dirty = true;
- QFxTransform::update();
-}
-
-/*!
- \internal
- \qmlclass Translation3D
- \brief A Translation3D object provides a way to move an Item along an axis.
-
- The following example translates the image to 10, 3.
- \qml
-Image {
- source: "logo.png"
- transform: [
- Translation3D {
- axis.startX: 0
- axis.startY: 0
- axis.endX: 1
- axis.endY: .3
- distance: 10
- }
- ]
-}
- \endqml
-*/
-
-QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Translation3D,QFxTranslation3D)
-
-QFxTranslation3D::QFxTranslation3D(QObject *parent)
-: QFxTransform(parent), _distance(0), _dirty(true)
-{
- connect(&_axis, SIGNAL(updated()), this, SLOT(update()));
-}
-
-QFxTranslation3D::~QFxTranslation3D()
-{
-}
-
-/*!
- \qmlproperty real Translation3D::axis.startX
- \qmlproperty real Translation3D::axis.startY
- \qmlproperty real Translation3D::axis.endX
- \qmlproperty real Translation3D::axis.endY
- \qmlproperty real Translation3D::axis.endZ
-
- A translation axis is specified by 2 points in 3D space: a start
- point and an end point. The z-position of the start point is assumed
- to be 0, and cannot be changed. Changing the z-position of the end
- point is only valid when running under OpenGL.
-
- \sa Axis
-*/
-QFxAxis *QFxTranslation3D::axis()
-{
- return &_axis;
-}
-
-/*!
- \qmlproperty real Translation3D::distance
-
- The distance to translate along the specified axis. distance is a
- multiplier; in the example below, a distance of 1 would translate to
- 100, 50, while a distance of 0.5 would translate to 50, 25.
-
- \qml
- Translation3D { axis.startX: 0; axis.startY: 0; axis.endX: 100; axis.endY: 50 }
- \endqml
-*/
-qreal QFxTranslation3D::distance() const
-{
- return _distance;
-}
-
-void QFxTranslation3D::setDistance(qreal distance)
-{
- _distance = distance;
- update();
-}
-
-bool QFxTranslation3D::isIdentity() const
-{
- return (_distance == 0.) || (_axis.endZ() == 0. && _axis.endY() == _axis.startY() && _axis.endX() == _axis.startX());
-}
-
-QTransform QFxTranslation3D::transform() const
-{
- if (_dirty) {
- _transform = QTransform();
-
- if (!isIdentity()) {
- if (distance() != 0.) {
- QTransform trans;
- trans.translate((_axis.endX() - _axis.startX()) * distance(),
- (_axis.endY() - _axis.startY()) * distance());
- _transform *= trans;
- }
- }
-
- _dirty = false;
- }
-
- return _transform;
-}
-
-void QFxTranslation3D::update()
-{
- _dirty = true;
-
- if (_axis.endZ() != 0. && distance() != 0.) {
- qmlInfo(this) << "QTransform cannot translate along Z-axis.";
- }
-
- QFxTransform::update();
-}
-
-/*!
- \internal
- \qmlclass Perspective
- \brief A Perspective object specifies a perspective transformation.
-
- A Perspective transform only affects an item when running under
- OpenGL. When running under software rasterization it has no effect.
-*/
-
-QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Perspective,QFxPerspective)
-
-QFxPerspective::QFxPerspective(QObject *parent)
- : QFxTransform(parent)
-{
-}
-
-QFxPerspective::~QFxPerspective()
-{
-}
-
-/*!
- \qmlproperty real Perspective::angle
-*/
-
-/*!
- \qmlproperty real Perspective::aspect
-*/
-
-/*!
- \qmlproperty real Perspective::x
-*/
-
-/*!
- \qmlproperty real Perspective::y
-*/
-
-/*!
- \qmlproperty real Perspective::scale
-*/
-
-/*!
- \qmlclass Squish
- \brief A Squish object allows you to distort an item's appearance by 'squishing' it.
-
- Conceptually, a Squish works by allowing you to move the four corners of an item,
- and distorting the item to fit into the newly created polygon.
-
- \image squish-transform.png
-
- Here is an example of various \l Image squishes.
- \qml
- Rect {
- id: Screen
- width: 360; height: 80
- color: "white"
-
- HorizontalLayout {
- margin: 10
- spacing: 10
- Image { source: "qt.png" }
- Image {
- source: "qt.png"
- transform: Squish {
- x:0; y:0; width:60; height:60
- topLeftX:0; topLeftY:0
- topRightX:50; topRightY:10
- bottomLeftX:0; bottomLeftY:60
- bottomRightX: 60; bottomRightY:60
- }
- }
- Image {
- source: "qt.png"
- transform: Squish {
- x:0; y:0; width:60; height:60
- topLeftX:0; topLeftY:0
- topRightX:50; topRightY:0
- bottomLeftX:10; bottomLeftY:50
- bottomRightX: 60; bottomRightY:60
- }
- }
- Image {
- source: "qt.png"
- transform: Squish {
- x:0; y:0; width:60; height:60
- topLeftX:0; topLeftY:10
- topRightX:60; topRightY:10
- bottomLeftX:0; bottomLeftY:50
- bottomRightX: 60; bottomRightY:50
- }
- }
- Image {
- source: "qt.png"
- transform: Squish {
- x:0; y:0; width:60; height:60
- topLeftX:10; topLeftY:0
- topRightX:50; topRightY:0
- bottomLeftX:10; bottomLeftY:60
- bottomRightX: 50; bottomRightY:60
- }
- }
- }
- }
- \endqml
-
- \image squish.png
-*/
-QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Squish,QFxSquish)
-
-QFxSquish::QFxSquish(QObject *parent)
- : QFxTransform(parent)
-{
-}
-
-QFxSquish::~QFxSquish()
-{
-}
-
-/*!
- \qmlproperty real Squish::x
- \qmlproperty real Squish::y
- \qmlproperty real Squish::width
- \qmlproperty real Squish::height
-
- This is usually set to the original geometry of the item being squished.
-*/
-qreal QFxSquish::x() const
-{
- return p.x();
-}
-
-void QFxSquish::setX(qreal v)
-{
- p.setX(v);
- update();
-}
-
-qreal QFxSquish::y() const
-{
- return p.y();
-}
-
-void QFxSquish::setY(qreal v)
-{
- p.setY(v);
- update();
-}
-
-qreal QFxSquish::width() const
-{
- return s.width();
-}
-
-void QFxSquish::setWidth(qreal v)
-{
- s.setWidth(v);
- update();
-}
-
-qreal QFxSquish::height() const
-{
- return s.height();
-}
-
-void QFxSquish::setHeight(qreal v)
-{
- s.setHeight(v);
- update();
-}
-
-/*!
- \qmlproperty real Squish::topLeftX
- \qmlproperty real Squish::topLeftY
-
- The top left point for the squish.
-*/
-qreal QFxSquish::topLeft_x() const
-{
- return p1.x();
-}
-
-void QFxSquish::settopLeft_x(qreal v)
-{
- p1.setX(v);
- update();
-}
-
-qreal QFxSquish::topLeft_y() const
-{
- return p1.y();
-}
-
-void QFxSquish::settopLeft_y(qreal v)
-{
- p1.setY(v);
- update();
-}
-
-/*!
- \qmlproperty real Squish::topRightX
- \qmlproperty real Squish::topRightY
-
- The top right point for the squish.
-*/
-qreal QFxSquish::topRight_x() const
-{
- return p2.x();
-}
-
-void QFxSquish::settopRight_x(qreal v)
-{
- p2.setX(v);
- update();
-}
-
-qreal QFxSquish::topRight_y() const
-{
- return p2.y();
-}
-
-void QFxSquish::settopRight_y(qreal v)
-{
- p2.setY(v);
- update();
-}
-
-/*!
- \qmlproperty real Squish::bottomLeftX
- \qmlproperty real Squish::bottomLeftY
-
- The bottom left point for the squish.
-*/
-qreal QFxSquish::bottomLeft_x() const
-{
- return p3.x();
-}
-
-void QFxSquish::setbottomLeft_x(qreal v)
-{
- p3.setX(v);
- update();
-}
-
-qreal QFxSquish::bottomLeft_y() const
-{
- return p3.y();
-}
-
-void QFxSquish::setbottomLeft_y(qreal v)
-{
- p3.setY(v);
- update();
-}
-
-/*!
- \qmlproperty real Squish::bottomRightX
- \qmlproperty real Squish::bottomRightY
-
- The bottom right point for the squish.
-*/
-qreal QFxSquish::bottomRight_x() const
-{
- return p4.x();
-}
-
-void QFxSquish::setbottomRight_x(qreal v)
-{
- p4.setX(v);
- update();
-}
-
-qreal QFxSquish::bottomRight_y() const
-{
- return p4.y();
-}
-
-void QFxSquish::setbottomRight_y(qreal v)
-{
- p4.setY(v);
- update();
-}
-
-bool QFxSquish::isIdentity() const
-{
- return false;
-}
-
-QTransform QFxSquish::transform() const
-{
- QPolygonF poly;
- poly << p << QPointF(p.x() + s.width(), p.y()) << QPointF(p.x() + s.width(), p.y() + s.height()) << QPointF(p.x(), p.y() + s.height());
- QPolygonF poly2;
- poly2 << p1 << p2 << p4 << p3;
-
- QTransform t;
- QTransform::quadToQuad(poly, poly2, t);
- return t;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxtransform.h b/src/declarative/fx/qfxtransform.h
deleted file mode 100644
index fb49294..0000000
--- a/src/declarative/fx/qfxtransform.h
+++ /dev/null
@@ -1,356 +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 QFXTRANSFORM_H
-#define QFXTRANSFORM_H
-
-#include <QtCore/QObject>
-#include <QtGui/QTransform>
-#include <QtDeclarative/qfxitem.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class Q_DECLARATIVE_EXPORT QFxTransform : public QObject
-{
- Q_OBJECT
-public:
- QFxTransform(QObject *parent=0);
- ~QFxTransform();
-
- void update();
-
- virtual bool isIdentity() const;
- virtual QTransform transform() const;
-};
-
-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 QTransform transform() const;
-
-Q_SIGNALS:
- void scaleChanged();
-
-private Q_SLOTS:
- void update();
-private:
- qreal _originX;
- qreal _originY;
- qreal _xScale;
- qreal _yScale;
-
- mutable bool _dirty;
- mutable QTransform _transform;
-};
-
-class Q_DECLARATIVE_EXPORT QFxAxis : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(qreal startX READ startX WRITE setStartX)
- Q_PROPERTY(qreal startY READ startY WRITE setStartY)
- Q_PROPERTY(qreal endX READ endX WRITE setEndX)
- Q_PROPERTY(qreal endY READ endY WRITE setEndY)
- Q_PROPERTY(qreal endZ READ endZ WRITE setEndZ)
-public:
- QFxAxis(QObject *parent=0);
- ~QFxAxis();
-
- qreal startX() const;
- void setStartX(qreal);
-
- qreal startY() const;
- void setStartY(qreal);
-
- qreal endX() const;
- void setEndX(qreal);
-
- qreal endY() const;
- void setEndY(qreal);
-
- qreal endZ() const;
- void setEndZ(qreal);
-
-Q_SIGNALS:
- void updated();
-
-private:
- qreal _startX;
- qreal _startY;
- qreal _endX;
- qreal _endY;
- qreal _endZ;
-};
-
-class Q_DECLARATIVE_EXPORT QFxRotation : public QFxTransform
-{
- Q_OBJECT
-
- Q_PROPERTY(qreal originX READ originX WRITE setOriginX)
- Q_PROPERTY(qreal originY READ originY WRITE setOriginY)
- Q_PROPERTY(qreal angle READ angle WRITE setAngle NOTIFY angleChanged())
-public:
- QFxRotation(QObject *parent=0);
- ~QFxRotation();
-
- qreal originX() const;
- void setOriginX(qreal);
-
- qreal originY() const;
- void setOriginY(qreal);
-
- qreal angle() const;
- void setAngle(qreal);
-
- virtual bool isIdentity() const;
- virtual QTransform transform() const;
-
-Q_SIGNALS:
- void angleChanged();
-
-private Q_SLOTS:
- void update();
-private:
- qreal _originX;
- qreal _originY;
- qreal _angle;
-
- mutable bool _dirty;
- mutable QTransform _transform;
-};
-
-class Q_DECLARATIVE_EXPORT QFxRotation3D : public QFxTransform
-{
- Q_OBJECT
-
- Q_PROPERTY(QFxAxis *axis READ axis)
- Q_PROPERTY(qreal angle READ angle WRITE setAngle)
-public:
- QFxRotation3D(QObject *parent=0);
- ~QFxRotation3D();
-
- QFxAxis *axis();
-
- qreal angle() const;
- void setAngle(qreal);
-
- virtual bool isIdentity() const;
- virtual QTransform transform() const;
-
-private Q_SLOTS:
- void update();
-private:
- QFxAxis _axis;
- qreal _angle;
-
- mutable bool _dirty;
- mutable QTransform _transform;
-};
-
-class Q_DECLARATIVE_EXPORT QFxTranslation3D : public QFxTransform
-{
- Q_OBJECT
-
- Q_PROPERTY(QFxAxis *axis READ axis)
- Q_PROPERTY(qreal distance READ distance WRITE setDistance)
-public:
- QFxTranslation3D(QObject *parent=0);
- ~QFxTranslation3D();
-
- QFxAxis *axis();
-
- qreal distance() const;
- void setDistance(qreal);
-
- virtual bool isIdentity() const;
- virtual QTransform transform() const;
-
-private Q_SLOTS:
- void update();
-private:
- QFxAxis _axis;
- qreal _distance;
-
- mutable bool _dirty;
- mutable QTransform _transform;
-};
-
-class Q_DECLARATIVE_EXPORT QFxPerspective : public QFxTransform
-{
- Q_OBJECT
-
- Q_PROPERTY(qreal angle READ angle WRITE setAngle)
- Q_PROPERTY(qreal aspect READ aspect WRITE setAspect)
- Q_PROPERTY(qreal x READ x WRITE setX)
- Q_PROPERTY(qreal y READ y WRITE setY)
- Q_PROPERTY(qreal scale READ scale WRITE setScale)
-public:
- QFxPerspective(QObject *parent=0);
- ~QFxPerspective();
-
- qreal angle() const { return _angle; }
- void setAngle(qreal v) { _angle = v; update(); }
-
- qreal aspect() const { return _aspect; }
- void setAspect(qreal v) { _aspect = v; update(); }
-
- qreal x() const { return _x; }
- void setX(qreal v) { _x = v; update(); }
-
- qreal y() const { return _y; }
- void setY(qreal v) { _y = v; update(); }
-
- qreal scale() const { return _scale; }
- void setScale(qreal v) { _scale = v; update(); }
-
-private:
- qreal _scale;
- qreal _x;
- qreal _y;
- qreal _angle;
- qreal _aspect;
-};
-
-class Q_DECLARATIVE_EXPORT QFxSquish : public QFxTransform
-{
- Q_OBJECT
-
- Q_PROPERTY(qreal x READ x WRITE setX)
- Q_PROPERTY(qreal y READ y WRITE setY)
- Q_PROPERTY(qreal width READ width WRITE setWidth)
- Q_PROPERTY(qreal height READ height WRITE setHeight)
- Q_PROPERTY(qreal topLeftX READ topLeft_x WRITE settopLeft_x)
- Q_PROPERTY(qreal topLeftY READ topLeft_y WRITE settopLeft_y)
- Q_PROPERTY(qreal topRightX READ topRight_x WRITE settopRight_x)
- Q_PROPERTY(qreal topRightY READ topRight_y WRITE settopRight_y)
- Q_PROPERTY(qreal bottomLeftX READ bottomLeft_x WRITE setbottomLeft_x)
- Q_PROPERTY(qreal bottomLeftY READ bottomLeft_y WRITE setbottomLeft_y)
- Q_PROPERTY(qreal bottomRightX READ bottomRight_x WRITE setbottomRight_x)
- Q_PROPERTY(qreal bottomRightY READ bottomRight_y WRITE setbottomRight_y)
-public:
- QFxSquish(QObject *parent=0);
- ~QFxSquish();
-
- qreal x() const;
- void setX(qreal);
-
- qreal y() const;
- void setY(qreal);
-
- qreal width() const;
- void setWidth(qreal);
-
- qreal height() const;
- void setHeight(qreal);
-
- qreal topLeft_x() const;
- void settopLeft_x(qreal);
-
- qreal topLeft_y() const;
- void settopLeft_y(qreal);
-
- qreal topRight_x() const;
- void settopRight_x(qreal);
-
- qreal topRight_y() const;
- void settopRight_y(qreal);
-
- qreal bottomLeft_x() const;
- void setbottomLeft_x(qreal);
-
- qreal bottomLeft_y() const;
- void setbottomLeft_y(qreal);
-
- qreal bottomRight_y() const;
- void setbottomRight_y(qreal);
-
- qreal bottomRight_x() const;
- void setbottomRight_x(qreal);
-
- virtual bool isIdentity() const;
- virtual QTransform transform() const;
-
-private:
- QPointF p;
- QSizeF s;
- QPointF p1, p2, p3, p4;
-};
-
-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/qfxwebview.cpp b/src/declarative/fx/qfxwebview.cpp
index 4c6af69..83f9249 100644
--- a/src/declarative/fx/qfxwebview.cpp
+++ b/src/declarative/fx/qfxwebview.cpp
@@ -55,7 +55,6 @@
#include "qml.h"
#include "qmlengine.h"
#include "qmlstate.h"
-#include "qfxtransform.h"
#include "qfxscalegrid.h"
#include "qlistmodelinterface.h"