summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Bodson <yann.bodson@nokia.com>2009-10-28 05:05:49 (GMT)
committerYann Bodson <yann.bodson@nokia.com>2009-10-28 05:05:49 (GMT)
commit1545a7f0e67cc125a116f0d72b81cb325a675381 (patch)
tree486820827b02ede1eab5f713baa38e9e7098cb7b
parentf6b063eeef71b4cb7c1cff090166201f794c9679 (diff)
parent1f8a4748e860d259d525e47426fd3a1072d9fb5c (diff)
downloadQt-1545a7f0e67cc125a116f0d72b81cb325a675381.zip
Qt-1545a7f0e67cc125a116f0d72b81cb325a675381.tar.gz
Qt-1545a7f0e67cc125a116f0d72b81cb325a675381.tar.bz2
Merge branch 'kinetic-declarativeui' of scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
-rw-r--r--doc/src/declarative/globalobject.qdoc26
-rw-r--r--examples/declarative/listview/listview.qml1
-rw-r--r--examples/declarative/parallax/ParallaxView.qml3
-rw-r--r--src/declarative/fx/qfxflickable.cpp26
-rw-r--r--src/declarative/fx/qfxitem.cpp2
-rw-r--r--src/declarative/fx/qfxlistview.cpp80
-rw-r--r--src/declarative/fx/qfxpositioners.cpp6
-rw-r--r--src/declarative/util/qmleasefollow.cpp3
-rw-r--r--src/declarative/util/qmlspringfollow.cpp9
9 files changed, 129 insertions, 27 deletions
diff --git a/doc/src/declarative/globalobject.qdoc b/doc/src/declarative/globalobject.qdoc
index 2328c8a..afbe3db 100644
--- a/doc/src/declarative/globalobject.qdoc
+++ b/doc/src/declarative/globalobject.qdoc
@@ -56,6 +56,32 @@ Contains all the properties of the ECMAScript global object, plus:
\section1 Qt Object
+The Qt object contains functions for
+
+creating types:
+\list
+\o hsla
+\o rgba
+\o rect
+\o point
+\o size
+\o vector3d
+\endlist
+
+manipulating color:
+\list
+\o lighter
+\o darker
+\o tint
+\endlist
+
+and playing sound:
+\list
+\o playSound
+\endlist
+
+It also contains enum values used by some items.
+
\section1 Asynchronous JavaScript and XML
\section1 Offline Storage API
diff --git a/examples/declarative/listview/listview.qml b/examples/declarative/listview/listview.qml
index b614904..92acce1 100644
--- a/examples/declarative/listview/listview.qml
+++ b/examples/declarative/listview/listview.qml
@@ -72,5 +72,6 @@ Rectangle {
preferredHighlightBegin: 125
preferredHighlightEnd: 125
highlightRangeMode: "StrictlyEnforceRange"
+ flickDeceleration: 1000
}
}
diff --git a/examples/declarative/parallax/ParallaxView.qml b/examples/declarative/parallax/ParallaxView.qml
index bad9b85..50ab72c 100644
--- a/examples/declarative/parallax/ParallaxView.qml
+++ b/examples/declarative/parallax/ParallaxView.qml
@@ -25,7 +25,8 @@ Item {
anchors.fill: parent
model: VisualItemModel { id: visualModel }
- highlight: Item { height: 1; width: 1}
+ highlight: Rectangle { height: 1; width: 1 }
+ highlightMoveSpeed: 2000
preferredHighlightBegin: 0
preferredHighlightEnd: 0
highlightRangeMode: "StrictlyEnforceRange"
diff --git a/src/declarative/fx/qfxflickable.cpp b/src/declarative/fx/qfxflickable.cpp
index 92e79dd..659193d 100644
--- a/src/declarative/fx/qfxflickable.cpp
+++ b/src/declarative/fx/qfxflickable.cpp
@@ -57,6 +57,8 @@ QT_BEGIN_NAMESPACE
static const int DragThreshold = 8;
static const int FlickThreshold = 20;
+// Really slow flicks can be annoying.
+static const int minimumFlickVelocity = 200;
class QFxFlickableVisibleArea : public QObject
{
@@ -183,6 +185,8 @@ void QFxFlickablePrivate::flickX(qreal velocity)
{
Q_Q(QFxFlickable);
qreal maxDistance = -1;
+ if (qAbs(velocity) < minimumFlickVelocity) // Minimum velocity to avoid annoyingly slow flicks.
+ velocity = velocity < 0 ? -minimumFlickVelocity : minimumFlickVelocity;
// -ve velocity means list is moving up
if (velocity > 0) {
if (_moveX.value() < q->minXExtent())
@@ -686,8 +690,8 @@ void QFxFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent *event)
if (rejectX) velocityX = 0;
if (moved) {
- q->viewportMoved();
q->movementStarting();
+ q->viewportMoved();
}
lastPos = event->pos();
@@ -707,15 +711,23 @@ void QFxFlickablePrivate::handleMouseReleaseEvent(QGraphicsSceneMouseEvent *even
}
vTime = timeline.time();
- if (qAbs(velocityY) > 10 && qAbs(event->pos().y() - pressPos.y()) > FlickThreshold)
- flickY(velocityY);
- else
+ if (qAbs(velocityY) > 10 && qAbs(event->pos().y() - pressPos.y()) > FlickThreshold) {
+ qreal velocity = velocityY;
+ if (qAbs(velocity) < minimumFlickVelocity) // Minimum velocity to avoid annoyingly slow flicks.
+ velocity = velocity < 0 ? -minimumFlickVelocity : minimumFlickVelocity;
+ flickY(velocity);
+ } else {
fixupY();
+ }
- if (qAbs(velocityX) > 10 && qAbs(event->pos().x() - pressPos.x()) > FlickThreshold)
- flickX(velocityX);
- else
+ if (qAbs(velocityX) > 10 && qAbs(event->pos().x() - pressPos.x()) > FlickThreshold) {
+ qreal velocity = velocityX;
+ if (qAbs(velocity) < minimumFlickVelocity) // Minimum velocity to avoid annoyingly slow flicks.
+ velocity = velocity < 0 ? -minimumFlickVelocity : minimumFlickVelocity;
+ flickX(velocity);
+ } else {
fixupX();
+ }
stealMouse = false;
lastPosTime = QTime();
diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp
index e714494..7d60336 100644
--- a/src/declarative/fx/qfxitem.cpp
+++ b/src/declarative/fx/qfxitem.cpp
@@ -1199,7 +1199,7 @@ QFxKeysAttached *QFxKeysAttached::qmlAttachedProperties(QObject *obj)
/*!
\class QFxItem
- \brief QFxItem is the most basic of all visual items in QML.
+ \brief The QFxItem class provides the most basic of all visual items in QML.
All visual items in Qt Declarative inherit from QFxItem. Although QFxItem
has no visual appearance, it defines all the properties that are
diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp
index 18aa5d2..1f1b97b 100644
--- a/src/declarative/fx/qfxlistview.cpp
+++ b/src/declarative/fx/qfxlistview.cpp
@@ -691,8 +691,7 @@ void QFxListViewPrivate::updateHighlight()
{
if ((!currentItem && highlight) || (currentItem && !highlight))
createHighlight();
- updateTrackedItem();
- if (currentItem && autoHighlight && highlight && !pressed && moveReason != QFxListViewPrivate::Mouse) {
+ if (currentItem && autoHighlight && highlight && !moving) {
// auto-update highlight
highlightPosAnimator->setSourceValue(currentItem->position());
highlightSizeAnimator->setSourceValue(currentItem->size());
@@ -704,6 +703,7 @@ void QFxListViewPrivate::updateHighlight()
highlight->item->setHeight(currentItem->item->height());
}
}
+ updateTrackedItem();
}
void QFxListViewPrivate::updateSections()
@@ -832,8 +832,10 @@ void QFxListViewPrivate::flickX(qreal velocity)
{
Q_Q(QFxListView);
- if (!haveHighlightRange || highlightRange != QFxListView::StrictlyEnforceRange)
+ if (!haveHighlightRange || highlightRange != QFxListView::StrictlyEnforceRange) {
QFxFlickablePrivate::flickX(velocity);
+ return;
+ }
qreal maxDistance = -1;
// -ve velocity means list is moving up
@@ -855,19 +857,20 @@ void QFxListViewPrivate::flickX(qreal velocity)
v = maxVelocity;
}
qreal accel = deceleration;
- qreal maxAccel = (v * v) / (2.0f * maxDistance);
+ qreal v2 = v * v;
+ qreal maxAccel = v2 / (2.0f * maxDistance);
if (maxAccel < accel) {
// If we are not flicking to the end then attempt to stop exactly on an item boundary
- qreal dist = (v * v) / accel / 2.0;
+ qreal dist = v2 / accel / 2.0;
if (v > 0)
dist = -dist;
- dist = -_moveX.value() - snapPosAt(-_moveX.value() + dist + highlightRangeStart);
+ dist = -_moveX.value() - snapPosAt(-(_moveX.value() - highlightRangeStart) + dist) + highlightRangeStart;
if (v < 0 && dist >= 0 || v > 0 && dist <= 0) {
timeline.reset(_moveX);
fixupX();
return;
}
- accel = (v * v) / (2.0f * qAbs(dist));
+ accel = v2 / (2.0f * qAbs(dist));
}
timeline.reset(_moveX);
timeline.accel(_moveX, v, accel, maxDistance);
@@ -885,7 +888,60 @@ void QFxListViewPrivate::flickX(qreal velocity)
void QFxListViewPrivate::flickY(qreal velocity)
{
- QFxFlickablePrivate::flickY(velocity);
+ Q_Q(QFxListView);
+
+ if (!haveHighlightRange || highlightRange != QFxListView::StrictlyEnforceRange) {
+ QFxFlickablePrivate::flickY(velocity);
+ return;
+ }
+
+ qreal maxDistance = -1;
+ // -ve velocity means list is moving up
+ if (velocity > 0) {
+ if (_moveY.value() < q->minYExtent())
+ maxDistance = qAbs(q->minYExtent() -_moveY.value() + (overShoot?30:0));
+ flickTargetY = q->minYExtent();
+ } else {
+ if (_moveY.value() > q->maxYExtent())
+ maxDistance = qAbs(q->maxYExtent() - _moveY.value()) + (overShoot?30:0);
+ flickTargetY = q->maxYExtent();
+ }
+ if (maxDistance > 0) {
+ qreal v = velocity;
+ if (maxVelocity != -1 && maxVelocity < qAbs(v)) {
+ if (v < 0)
+ v = -maxVelocity;
+ else
+ v = maxVelocity;
+ }
+ qreal accel = deceleration;
+ qreal v2 = v * v;
+ qreal maxAccel = v2 / (2.0f * maxDistance);
+ if (maxAccel < accel) {
+ // If we are not flicking to the end then attempt to stop exactly on an item boundary
+ qreal dist = v2 / accel / 2.0;
+ if (v > 0)
+ dist = -dist;
+ dist = -_moveY.value() - snapPosAt(-(_moveY.value() - highlightRangeStart) + dist) + highlightRangeStart;
+ if (v < 0 && dist >= 0 || v > 0 && dist <= 0) {
+ timeline.reset(_moveY);
+ fixupY();
+ return;
+ }
+ accel = v2 / (2.0f * qAbs(dist));
+ }
+ timeline.reset(_moveY);
+ timeline.accel(_moveY, v, accel, maxDistance);
+ timeline.execute(fixupYEvent);
+ if (!flicked) {
+ flicked = true;
+ emit q->flickingChanged();
+ emit q->flickStarted();
+ }
+ } else {
+ timeline.reset(_moveY);
+ fixupY();
+ }
}
//----------------------------------------------------------------------------
@@ -1185,6 +1241,10 @@ void QFxListView::setHighlight(QmlComponent *highlight)
\snippet doc/src/snippets/declarative/listview/highlight.qml 1
+ Note that the highlight animation also affects the way that the view
+ is scrolled. This is because the view moves to maintain the
+ highlight within the preferred highlight range (or visible viewport).
+
\sa highlight
*/
bool QFxListView::highlightFollowsCurrentItem() const
@@ -1445,7 +1505,7 @@ void QFxListView::viewportMoved()
Q_D(QFxListView);
QFxFlickable::viewportMoved();
refill();
- if (isFlicking() || d->pressed)
+ if (isFlicking() || d->moving)
d->moveReason = QFxListViewPrivate::Mouse;
if (d->moveReason == QFxListViewPrivate::Mouse) {
if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange && d->highlight) {
@@ -1606,7 +1666,7 @@ void QFxListView::trackedPositionChanged()
Q_D(QFxListView);
if (!d->trackedItem)
return;
- if (!isFlicking() && !d->pressed && d->moveReason != QFxListViewPrivate::Mouse) {
+ if (!isFlicking() && !d->moving && d->moveReason != QFxListViewPrivate::Mouse) {
const qreal trackedPos = d->trackedItem->position();
if (d->haveHighlightRange) {
if (d->highlightRange == StrictlyEnforceRange) {
diff --git a/src/declarative/fx/qfxpositioners.cpp b/src/declarative/fx/qfxpositioners.cpp
index f8e7213..cc385e0 100644
--- a/src/declarative/fx/qfxpositioners.cpp
+++ b/src/declarative/fx/qfxpositioners.cpp
@@ -659,8 +659,10 @@ void QFxRow::doPositioning()
child->setX(hoffset);
setMovingItem(0);
}
- hoffset += child->width();
- hoffset += spacing();
+ if(!child->width() || !child->height()){//don't advance for invisible children
+ hoffset += child->width();
+ hoffset += spacing();
+ }
}
}
diff --git a/src/declarative/util/qmleasefollow.cpp b/src/declarative/util/qmleasefollow.cpp
index 99720f8..9d17d25 100644
--- a/src/declarative/util/qmleasefollow.cpp
+++ b/src/declarative/util/qmleasefollow.cpp
@@ -210,7 +210,6 @@ void QmlEaseFollowPrivate::tick(int t)
qreal value = 0.5 * a * time_seconds * time_seconds + vi * time_seconds;
value = (invert?-1.0:1.0) * value;
target.write(initialValue + value);
-
out = initialValue + value;
} else if (time_seconds < td) {
@@ -397,7 +396,7 @@ void QmlEaseFollow::setSourceValue(qreal s)
{
Q_D(QmlEaseFollow);
- if (d->source == s)
+ if (d->clock.state() == QAbstractAnimation::Running && d->source == s)
return;
d->source = s;
diff --git a/src/declarative/util/qmlspringfollow.cpp b/src/declarative/util/qmlspringfollow.cpp
index 34ec976..569cc48 100644
--- a/src/declarative/util/qmlspringfollow.cpp
+++ b/src/declarative/util/qmlspringfollow.cpp
@@ -272,10 +272,11 @@ qreal QmlSpringFollow::sourceValue() const
void QmlSpringFollow::setSourceValue(qreal value)
{
Q_D(QmlSpringFollow);
- if (d->sourceValue != value) {
- d->sourceValue = value;
- d->start();
- }
+ if (d->clock.state() == QAbstractAnimation::Running && d->sourceValue == value)
+ return;
+
+ d->sourceValue = value;
+ d->start();
}
/*!