Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Displaced items were moving unnecessarily
They should only move if they actually change from the last set position, and not if they are simply changing from their current item position, as that is wrong during an animation. This also cleans up some code for resetting the transition data. Task-number: QTBUG-24586 Change-Id: I0a6635903975ebc40d5cf8398b943a9de92d4493 Reviewed-by: Martin Jones <martin.jones@nokia.com>
- Loading branch information
Bea Lam
authored and
Qt by Nokia
committed
Mar 13, 2012
1 parent
fb1ce5e
commit 52d3d36
Showing
6 changed files
with
326 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
tests/auto/quick/qquickgridview/data/multipleDisplaced.qml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import QtQuick 2.0 | ||
|
||
Rectangle { | ||
id: root | ||
width: 500 | ||
height: 600 | ||
|
||
property int duration: 10 | ||
property int count: grid.count | ||
|
||
Component { | ||
id: myDelegate | ||
Rectangle { | ||
id: wrapper | ||
|
||
property string nameData: name | ||
|
||
objectName: "wrapper" | ||
width: 80 | ||
height: 60 | ||
border.width: 1 | ||
Column { | ||
Text { text: index } | ||
Text { | ||
text: wrapper.x + ", " + wrapper.y | ||
} | ||
Text { | ||
id: textName | ||
objectName: "textName" | ||
text: name | ||
} | ||
} | ||
color: GridView.isCurrentItem ? "lightsteelblue" : "white" | ||
} | ||
} | ||
|
||
GridView { | ||
id: grid | ||
|
||
property var displaceTransitionsStarted: new Object() | ||
property bool displaceTransitionsDone: false | ||
|
||
objectName: "grid" | ||
focus: true | ||
anchors.centerIn: parent | ||
width: 240 | ||
height: 320 | ||
cellWidth: 80 | ||
cellHeight: 60 | ||
model: testModel | ||
delegate: myDelegate | ||
|
||
displaced: Transition { | ||
id: transition | ||
SequentialAnimation { | ||
ScriptAction { | ||
script: { | ||
var name = transition.ViewTransition.item.nameData | ||
if (grid.displaceTransitionsStarted[name] == undefined) | ||
grid.displaceTransitionsStarted[name] = 0 | ||
grid.displaceTransitionsStarted[name] += 1 | ||
} | ||
} | ||
NumberAnimation { | ||
properties: "x,y" | ||
duration: root.duration | ||
easing.type: Easing.OutBounce | ||
easing.amplitude: 10.0 // longer-lasting bounce to trigger bug | ||
} | ||
PropertyAction { target: grid; property: "displaceTransitionsDone"; value: true } | ||
} | ||
} | ||
} | ||
|
||
Rectangle { | ||
anchors.fill: grid | ||
color: "lightsteelblue" | ||
opacity: 0.2 | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.