summaryrefslogtreecommitdiffstats
path: root/src/declarative/fx
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-04-27 05:38:16 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-04-27 05:38:16 (GMT)
commitcd8542ca836b175377f3b3471725b86f8739e91a (patch)
treec2b48c384e7af568979f534ec64d867a0891940b /src/declarative/fx
parent9f941fd65083ae6d3f2f5441bf60346821932218 (diff)
parent7e3aee5b4f50733fa8d88def28b4fce78070f9e2 (diff)
downloadQt-cd8542ca836b175377f3b3471725b86f8739e91a.zip
Qt-cd8542ca836b175377f3b3471725b86f8739e91a.tar.gz
Qt-cd8542ca836b175377f3b3471725b86f8739e91a.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src/declarative/fx')
-rw-r--r--src/declarative/fx/qfxblendedimage.cpp37
-rw-r--r--src/declarative/fx/qfxblendedimage.h6
-rw-r--r--src/declarative/fx/qfxflickable.cpp15
-rw-r--r--src/declarative/fx/qfxflickable_p.h18
-rw-r--r--src/declarative/fx/qfxlistview.cpp9
-rw-r--r--src/declarative/fx/qfxparticles.cpp1
-rw-r--r--src/declarative/fx/qfxpathview.cpp15
-rw-r--r--src/declarative/fx/qfxpathview.h1
-rw-r--r--src/declarative/fx/qfxpathview_p.h7
9 files changed, 74 insertions, 35 deletions
diff --git a/src/declarative/fx/qfxblendedimage.cpp b/src/declarative/fx/qfxblendedimage.cpp
index b5d9a9a..b5b7bb3 100644
--- a/src/declarative/fx/qfxblendedimage.cpp
+++ b/src/declarative/fx/qfxblendedimage.cpp
@@ -73,7 +73,7 @@ QT_BEGIN_NAMESPACE
secondary image.
*/
QFxBlendedImage::QFxBlendedImage(QFxItem *parent)
-: QFxItem(parent), _blend(0), dirty(false)
+: QFxItem(parent), _blend(0), _smooth(false), dirty(false)
{
#if defined(QFX_RENDER_OPENGL2)
setOptions(HasContents);
@@ -154,16 +154,51 @@ void QFxBlendedImage::setBlend(qreal b)
update();
}
+/*!
+ \qmlproperty bool BlendedImage::smooth
+
+ Set this property if you want the image to be smoothly filtered when scaled or
+ transformed. Smooth filtering gives better visual quality, but is slower. If
+ the BlendedImage is displayed at its natural size, this property has no visual or
+ performance effect.
+
+ \note Generally scaling artifacts are only visible if the image is stationary on
+ the screen. A common pattern when animating an image is to disable smooth
+ filtering at the beginning of the animation and reenable it at the conclusion.
+ */
+bool QFxBlendedImage::smoothTransform() const
+{
+ return _smooth;
+}
+
+void QFxBlendedImage::setSmoothTransform(bool s)
+{
+ if(_smooth == s)
+ return;
+ _smooth = s;
+ update();
+}
+
#if defined(QFX_RENDER_QPAINTER)
void QFxBlendedImage::paintContents(QPainter &p)
{
if (primSrc.isNull() && secSrc.isNull())
return;
+
+ if(_smooth) {
+ p.save();
+ p.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, _smooth);
+ }
+
if (_blend < 0.75)
p.drawImage(0, 0, primPix);
else
p.drawImage(0, 0, secPix);
+
+ if(_smooth) {
+ p.restore();
+ }
}
#elif defined(QFX_RENDER_OPENGL2)
diff --git a/src/declarative/fx/qfxblendedimage.h b/src/declarative/fx/qfxblendedimage.h
index 96d3135..5cc0238 100644
--- a/src/declarative/fx/qfxblendedimage.h
+++ b/src/declarative/fx/qfxblendedimage.h
@@ -60,17 +60,22 @@ class QFxBlendedImage : public QFxItem
Q_PROPERTY(QString primaryUrl READ primaryUrl WRITE setPrimaryUrl)
Q_PROPERTY(QString secondaryUrl READ secondaryUrl WRITE setSecondaryUrl)
Q_PROPERTY(qreal blend READ blend WRITE setBlend)
+ Q_PROPERTY(bool smooth READ smoothTransform WRITE setSmoothTransform)
public:
QFxBlendedImage(QFxItem *parent=0);
QString primaryUrl() const;
void setPrimaryUrl(const QString &);
+
QString secondaryUrl() const;
void setSecondaryUrl(const QString &);
qreal blend() const;
void setBlend(qreal);
+ bool smoothTransform() const;
+ void setSmoothTransform(bool);
+
#if defined(QFX_RENDER_QPAINTER)
void paintContents(QPainter &painter);
#elif defined(QFX_RENDER_OPENGL2)
@@ -88,6 +93,7 @@ private:
QUrl secUrl;
qreal _blend;
+ bool _smooth;
bool dirty;
#if defined(QFX_RENDER_OPENGL2)
GLTexture prim;
diff --git a/src/declarative/fx/qfxflickable.cpp b/src/declarative/fx/qfxflickable.cpp
index 5715116..04b4a3d 100644
--- a/src/declarative/fx/qfxflickable.cpp
+++ b/src/declarative/fx/qfxflickable.cpp
@@ -43,13 +43,12 @@
#include "qfxflickable_p.h"
#include <QGraphicsSceneMouseEvent>
-#include <gfxeasing.h>
#include <QPointer>
#include <QTimer>
QT_BEGIN_NAMESPACE
-ElasticValue::ElasticValue(GfxValue &val)
+ElasticValue::ElasticValue(QmlTimeLineValue &val)
: _value(val)
{
_to = _value.value();
@@ -101,8 +100,8 @@ QFxFlickablePrivate::QFxFlickablePrivate()
, vTime(0), atXEnd(false), atXBeginning(true), pageXPosition(0.), pageWidth(0.)
, atYEnd(false), atYBeginning(true), pageYPosition(0.), pageHeight(0.)
{
- fixupXEvent = GfxEvent::gfxEvent<QFxFlickablePrivate, &QFxFlickablePrivate::fixupX>(&_moveX, this);
- fixupYEvent = GfxEvent::gfxEvent<QFxFlickablePrivate, &QFxFlickablePrivate::fixupY>(&_moveY, this);
+ fixupXEvent = QmlTimeLineEvent::timeLineEvent<QFxFlickablePrivate, &QFxFlickablePrivate::fixupX>(&_moveX, this);
+ fixupYEvent = QmlTimeLineEvent::timeLineEvent<QFxFlickablePrivate, &QFxFlickablePrivate::fixupY>(&_moveY, this);
}
void QFxFlickablePrivate::init()
@@ -128,11 +127,11 @@ void QFxFlickablePrivate::fixupX()
vTime = _tl.time();
if(_moveX.value() > q->minXExtent() || q->maxXExtent() > 0) {
- _tl.move(_moveX, q->minXExtent(), GfxEasing(GfxEasing::InOutQuad), 200);
+ _tl.move(_moveX, q->minXExtent(), QEasingCurve(QEasingCurve::InOutQuad), 200);
flicked = false;
//emit flickingChanged();
} else if(_moveX.value() < q->maxXExtent()) {
- _tl.move(_moveX, q->maxXExtent(), GfxEasing(GfxEasing::InOutQuad), 200);
+ _tl.move(_moveX, q->maxXExtent(), QEasingCurve(QEasingCurve::InOutQuad), 200);
flicked = false;
//emit flickingChanged();
}
@@ -147,10 +146,10 @@ void QFxFlickablePrivate::fixupY()
vTime = _tl.time();
if(_moveY.value() > q->minYExtent() || (q->maxYExtent() > q->minYExtent())) {
- _tl.move(_moveY, q->minYExtent(), GfxEasing(GfxEasing::InOutQuad), 200);
+ _tl.move(_moveY, q->minYExtent(), QEasingCurve(QEasingCurve::InOutQuad), 200);
//emit flickingChanged();
} else if(_moveY.value() < q->maxYExtent()) {
- _tl.move(_moveY, q->maxYExtent(), GfxEasing(GfxEasing::InOutQuad), 200);
+ _tl.move(_moveY, q->maxYExtent(), QEasingCurve(QEasingCurve::InOutQuad), 200);
//emit flickingChanged();
} else {
flicked = false;
diff --git a/src/declarative/fx/qfxflickable_p.h b/src/declarative/fx/qfxflickable_p.h
index 59450e0..ebd0327 100644
--- a/src/declarative/fx/qfxflickable_p.h
+++ b/src/declarative/fx/qfxflickable_p.h
@@ -57,7 +57,7 @@
#include "qfxflickable.h"
#include "qfxitem_p.h"
#include "qml.h"
-#include "gfxvalueproxy.h"
+#include "qmltimelinevalueproxy.h"
#include "private/qmlanimation_p.h"
QT_BEGIN_NAMESPACE
@@ -65,7 +65,7 @@ QT_BEGIN_NAMESPACE
class ElasticValue : public QAbstractAnimation {
Q_OBJECT
public:
- ElasticValue(GfxValue &);
+ ElasticValue(QmlTimeLineValue &);
void setValue(qreal to);
void clear();
@@ -81,7 +81,7 @@ private:
qreal _to;
qreal _myValue;
qreal _velocity;
- GfxValue &_value;
+ QmlTimeLineValue &_value;
QTime _startTime;
};
@@ -98,8 +98,8 @@ public:
public:
QFxItem *_flick;
- GfxValueProxy<QFxItem> _moveX;
- GfxValueProxy<QFxItem> _moveY;
+ QmlTimeLineValueProxy<QFxItem> _moveX;
+ QmlTimeLineValueProxy<QFxItem> _moveY;
QmlTimeLine _tl;
int vWidth;
int vHeight;
@@ -116,8 +116,8 @@ public:
qreal velocityX;
qreal velocityY;
QTime pressTime;
- GfxEvent fixupXEvent;
- GfxEvent fixupYEvent;
+ QmlTimeLineEvent fixupXEvent;
+ QmlTimeLineEvent fixupYEvent;
int maxVelocity;
bool locked;
QFxFlickable::DragMode dragMode;
@@ -128,12 +128,12 @@ public:
int velocityDecay;
void updateVelocity();
- struct Velocity : public GfxValue
+ struct Velocity : public QmlTimeLineValue
{
Velocity(QFxFlickablePrivate *p)
: parent(p) {}
virtual void setValue(qreal v) {
- GfxValue::setValue(v);
+ QmlTimeLineValue::setValue(v);
parent->updateVelocity();
}
QFxFlickablePrivate *parent;
diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp
index 3c8c12c..f25470b 100644
--- a/src/declarative/fx/qfxlistview.cpp
+++ b/src/declarative/fx/qfxlistview.cpp
@@ -43,7 +43,6 @@
#include "qmlfollow.h"
#include "qlistmodelinterface.h"
#include "qfxvisualitemmodel.h"
-#include "gfxeasing.h"
#include "qfxlistview.h"
#include <qmlexpression.h>
@@ -749,7 +748,7 @@ void QFxListViewPrivate::fixupY()
if (currentItem) {
moveReason = Mouse;
_tl.clear();
- _tl.move(_moveY, -(currentItem->position() - snapPos), GfxEasing(GfxEasing::InOutQuad), 200);
+ _tl.move(_moveY, -(currentItem->position() - snapPos), QEasingCurve(QEasingCurve::InOutQuad), 200);
}
} else if (currItemMode == QFxListView::Snap) {
moveReason = Mouse;
@@ -761,7 +760,7 @@ void QFxListViewPrivate::fixupY()
else if (pos < -q->minYExtent())
pos = -q->minYExtent();
_tl.clear();
- _tl.move(_moveY, -(pos), GfxEasing(GfxEasing::InOutQuad), 200);
+ _tl.move(_moveY, -(pos), QEasingCurve(QEasingCurve::InOutQuad), 200);
}
}
}
@@ -775,7 +774,7 @@ void QFxListViewPrivate::fixupX()
if (currItemMode == QFxListView::SnapAuto) {
moveReason = Mouse;
_tl.clear();
- _tl.move(_moveX, -(currentItem->position() - snapPos), GfxEasing(GfxEasing::InOutQuad), 200);
+ _tl.move(_moveX, -(currentItem->position() - snapPos), QEasingCurve(QEasingCurve::InOutQuad), 200);
} else if (currItemMode == QFxListView::Snap) {
moveReason = Mouse;
int idx = snapIndex();
@@ -786,7 +785,7 @@ void QFxListViewPrivate::fixupX()
else if (pos < -q->minXExtent())
pos = -q->minXExtent();
_tl.clear();
- _tl.move(_moveX, -(pos), GfxEasing(GfxEasing::InOutQuad), 200);
+ _tl.move(_moveX, -(pos), QEasingCurve(QEasingCurve::InOutQuad), 200);
}
}
}
diff --git a/src/declarative/fx/qfxparticles.cpp b/src/declarative/fx/qfxparticles.cpp
index 9319c46..54e3778 100644
--- a/src/declarative/fx/qfxparticles.cpp
+++ b/src/declarative/fx/qfxparticles.cpp
@@ -39,7 +39,6 @@
**
****************************************************************************/
-#include "gfxtimeline.h"
#include "qfxitem_p.h"
#if defined(QFX_RENDER_OPENGL)
#include "gltexture.h"
diff --git a/src/declarative/fx/qfxpathview.cpp b/src/declarative/fx/qfxpathview.cpp
index 99f6e86..b1cfaa5 100644
--- a/src/declarative/fx/qfxpathview.cpp
+++ b/src/declarative/fx/qfxpathview.cpp
@@ -43,7 +43,6 @@
#include <QDebug>
#include <QPen>
#include <QEvent>
-#include <gfxeasing.h>
#include "qmlbindablevalue.h"
#include "qmlstate.h"
#include "qlistmodelinterface.h"
@@ -595,6 +594,8 @@ void QFxPathViewPrivate::regenerate()
int minI = -1;
for(int i=0; i<numItems; i++){
QFxItem *item = model->item(i);
+ if (!item)
+ return;
items.append(item);
item->setZ(i);
item->setParent(q);
@@ -805,7 +806,7 @@ void QFxPathViewPrivate::snapToCurrent()
rounds--;
if(distance > 50)
rounds++;
- tl.move(moveOffset, targetOffset + 100.0*(-rounds), GfxEasing(GfxEasing::InOutQuad),
+ tl.move(moveOffset, targetOffset + 100.0*(-rounds), QEasingCurve(QEasingCurve::InOutQuad),
int(100*items.count()*qMax((qreal)(2.0/items.count()),(qreal)qAbs(rounds))));
tl.execute(fixupOffsetEvent);
return;
@@ -813,16 +814,16 @@ void QFxPathViewPrivate::snapToCurrent()
if (targetOffset - _offset > 50.0) {
qreal distance = 100 - targetOffset + _offset;
- tl.move(moveOffset, 0.0, GfxEasing(GfxEasing::OutQuad), int(200 * _offset / distance));
+ tl.move(moveOffset, 0.0, QEasingCurve(QEasingCurve::OutQuad), int(200 * _offset / distance));
tl.set(moveOffset, 100.0);
- tl.move(moveOffset, targetOffset, GfxEasing(GfxEasing::InQuad), int(200 * (100-targetOffset) / distance));
+ tl.move(moveOffset, targetOffset, QEasingCurve(QEasingCurve::InQuad), int(200 * (100-targetOffset) / distance));
} else if (targetOffset - _offset <= -50.0) {
qreal distance = 100 - _offset + targetOffset;
- tl.move(moveOffset, 100.0, GfxEasing(GfxEasing::OutQuad), int(200 * (100-_offset) / distance));
+ tl.move(moveOffset, 100.0, QEasingCurve(QEasingCurve::OutQuad), int(200 * (100-_offset) / distance));
tl.set(moveOffset, 0.0);
- tl.move(moveOffset, targetOffset, GfxEasing(GfxEasing::InQuad), int(200 * targetOffset / distance));
+ tl.move(moveOffset, targetOffset, QEasingCurve(QEasingCurve::InQuad), int(200 * targetOffset / distance));
} else {
- tl.move(moveOffset, targetOffset, GfxEasing(GfxEasing::InOutQuad), 200);
+ tl.move(moveOffset, targetOffset, QEasingCurve(QEasingCurve::InOutQuad), 200);
}
}
diff --git a/src/declarative/fx/qfxpathview.h b/src/declarative/fx/qfxpathview.h
index 6d4280d..2cc0769 100644
--- a/src/declarative/fx/qfxpathview.h
+++ b/src/declarative/fx/qfxpathview.h
@@ -44,7 +44,6 @@
#include <qfxitem.h>
#include <qfxpath.h>
-#include <gfxvalueproxy.h>
QT_BEGIN_HEADER
diff --git a/src/declarative/fx/qfxpathview_p.h b/src/declarative/fx/qfxpathview_p.h
index 31933c0..a19d778 100644
--- a/src/declarative/fx/qfxpathview_p.h
+++ b/src/declarative/fx/qfxpathview_p.h
@@ -58,6 +58,7 @@
#include "qfxitem_p.h"
#include "qfxvisualitemmodel.h"
#include "qml.h"
+#include "qmltimelinevalueproxy.h"
#include "private/qmlanimation_p.h"
QT_BEGIN_NAMESPACE
@@ -79,7 +80,7 @@ public:
, firstIndex(0), pathItems(-1), pathOffset(0), model(0)
, moveReason(Other)
{
- fixupOffsetEvent = GfxEvent::gfxEvent<QFxPathViewPrivate, &QFxPathViewPrivate::fixOffset>(&moveOffset, this);
+ fixupOffsetEvent = QmlTimeLineEvent::timeLineEvent<QFxPathViewPrivate, &QFxPathViewPrivate::fixOffset>(&moveOffset, this);
}
void init()
@@ -115,8 +116,8 @@ public:
qreal snapPos;
qreal dragMargin;
QmlTimeLine tl;
- GfxValueProxy<QFxPathViewPrivate> moveOffset;
- GfxEvent fixupOffsetEvent;
+ QmlTimeLineValueProxy<QFxPathViewPrivate> moveOffset;
+ QmlTimeLineEvent fixupOffsetEvent;
int firstIndex;
int pathItems;
int pathOffset;