From 6b1da53ad4ee4fa9bd60c8c039ba18d386c5e1ad Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Fri, 8 May 2009 11:05:24 +1000 Subject: More path to path fixing. --- demos/declarative/flickr/flickr2.qml | 124 ++++++++++++++++------------------- src/declarative/fx/qfxpathview.cpp | 12 ++-- 2 files changed, 61 insertions(+), 75 deletions(-) diff --git a/demos/declarative/flickr/flickr2.qml b/demos/declarative/flickr/flickr2.qml index 3b1208c..41d7d88 100644 --- a/demos/declarative/flickr/flickr2.qml +++ b/demos/declarative/flickr/flickr2.qml @@ -29,11 +29,15 @@ Item { delegate: Package { Item { - id: Wrapper; width: 85; height: 85 - scale: Wrapper.PathView.scale; z: Wrapper.PathView.z + id: Wrapper; width: 85; height: 85; scale: {1.0} + z: RightBox.PathView.z + property real angle: 0 * 0 transform: [ - Rotation3D { id: Rotation; axis.startX: 30; axis.endX: 30; axis.endY: 60; angle: Wrapper.PathView.angle } + Rotation3D { + id: Rotation; axis.startX: 30; axis.endX: 30; axis.endY: 60 + angle: Wrapper.angle + } ] Connection { @@ -111,7 +115,7 @@ Item { Item { Package.name: "rightBox" - id: RightBox; x: 200; width: 85; height: 85 + id: RightBox; width: 85; height: 85 } Item { @@ -120,73 +124,58 @@ Item { } Item { - id: MyItem - states: [ - State { - name: "left" - when: MainWindow.showPathView == true - SetProperty { - target: Wrapper - property: "moveToParent" - value: LeftBox - } - }, - State { - name: "right" - when: MainWindow.showPathView == false - SetProperty { - target: Wrapper - property: "moveToParent" - value: RightBox + id: MyItem + state: MainWindow.showPathView ? "right" : "left" + states: [ + State { + name: "left" + SetProperty { target: Wrapper; property: "moveToParent"; value: LeftBox } + }, + State { + name: "right" + SetProperty { target: Wrapper; property: "scale"; value: RightBox.PathView.scale } + SetProperty { target: Wrapper; property: "scale"; binding: "RightBox.PathView.scale" } + SetProperty { target: Wrapper; property: "angle"; value: RightBox.PathView.angle } + SetProperty { target: Wrapper; property: "angle"; binding: "RightBox.PathView.angle" } + SetProperty { target: Wrapper; property: "moveToParent"; value: RightBox } } - } - ] - transitions: [ - Transition { - fromState: "left" - toState: "right" - SequentialAnimation { - SetPropertyAction { - target: Wrapper - property: "moveToParent" - } - ParallelAnimation { - NumericAnimation { - target: Wrapper - properties: "x,y" - to: 0 - easing: "easeOutQuad" - duration: 350 + ] + transitions: [ + Transition { + toState: "right" + SequentialAnimation { + SetPropertyAction { target: Wrapper; property: "moveToParent" } + ParallelAnimation { + NumericAnimation { + target: Wrapper + properties: "x,y" + to: 0 + easing: "easeOutQuad" + duration: 350 + } + NumericAnimation { target: Wrapper; properties: "scale,angle"; duration: 350 } } } - } - }, - Transition { - fromState: "right" - toState: "left" - SequentialAnimation { - PauseAnimation { - duration: Math.floor(index/7)*100 - } - SetPropertyAction { - target: Wrapper - property: "moveToParent" - } - ParallelAnimation { - NumericAnimation { - target: Wrapper - properties: "x,y" - to: 0 - easing: "easeOutQuad" - duration: 250 + }, + Transition { + toState: "left" + SequentialAnimation { + PauseAnimation { duration: Math.floor(index/7)*100 } + SetPropertyAction { target: Wrapper; property: "moveToParent" } + ParallelAnimation { + NumericAnimation { + target: Wrapper + properties: "x,y" + to: 0 + easing: "easeOutQuad" + duration: 250 + } + NumericAnimation { target: Wrapper; properties: "scale,angle"; duration: 250 } } } } - } - ] - state: "right" - } - + ] + } } } @@ -213,7 +202,7 @@ Item { PathLine { x: -50; y: 40 } PathPercent { value: 0.001 } - PathAttribute { name: "scale"; value: 1 } + PathAttribute { name: "scale"; value: 0.9 } PathAttribute { name: "angle"; value: -45 } PathCubic { @@ -232,14 +221,13 @@ Item { control1X: 590; control1Y: 220 } - PathAttribute { name: "scale"; value: 1 } + PathAttribute { name: "scale"; value: 0.9 } PathAttribute { name: "angle"; value: -45 } PathPercent { value: 0.999 } PathLine { x: 950; y: 40 } PathPercent { value: 1.0 } } - } ImageDetails { id: ImageDetails; width: 750; x: 25; y: 500; height: 410 } diff --git a/src/declarative/fx/qfxpathview.cpp b/src/declarative/fx/qfxpathview.cpp index 2b39d6e..77d5fa2 100644 --- a/src/declarative/fx/qfxpathview.cpp +++ b/src/declarative/fx/qfxpathview.cpp @@ -157,7 +157,6 @@ void QFxPathView::setModel(const QVariant &model) disconnect(d->model, SIGNAL(itemCreated(int, QFxItem*)), this, SLOT(itemCreated(int,QFxItem*))); for (int i=0; iitems.count(); i++){ QFxItem *p = d->items[i]; - attachedProperties.remove(p); d->model->release(p); } d->items.clear(); @@ -557,7 +556,6 @@ void QFxPathViewPrivate::regenerate() Q_Q(QFxPathView); for (int i=0; iattachedProperties.remove(p); model->release(p); } items.clear(); @@ -631,7 +629,6 @@ void QFxPathView::refill() while(wrapIndex-- >= 0){ QFxItem* p = d->items.takeFirst(); d->updateItem(p, 0.0); - attachedProperties.remove(p); d->model->release(p); d->firstIndex++; d->firstIndex %= d->model->count(); @@ -645,7 +642,6 @@ void QFxPathView::refill() while(wrapIndex++ < d->items.count()-1){ QFxItem* p = d->items.takeLast(); d->updateItem(p, 1.0); - attachedProperties.remove(p); d->model->release(p); d->firstIndex--; if (d->firstIndex < 0) @@ -704,7 +700,6 @@ void QFxPathView::itemsRemoved(int modelIndex, int count) if (d->pathItems == -1) { for (int i = 0; i < count; ++i) { QFxItem* p = d->items.takeAt(modelIndex); - attachedProperties.remove(p); d->model->release(p); } d->snapToCurrent(); @@ -876,8 +871,11 @@ void QFxPathViewPrivate::snapToCurrent() QHash QFxPathView::attachedProperties; QObject *QFxPathView::qmlAttachedProperties(QObject *obj) { - QFxPathViewAttached *rv = new QFxPathViewAttached(obj); - attachedProperties.insert(obj, rv); + QObject *rv = attachedProperties.value(obj); + if (!rv) { + rv = new QFxPathViewAttached(obj); + attachedProperties.insert(obj, rv); + } return rv; } -- cgit v0.12