if (transform.t < 0) {
mTmpTransform = mStackAlgorithm.getStackTransform(tasks.get(0), stackScroll, mTmpTransform);
} else {
- mTmpTransform = mStackAlgorithm.getStackTransform(tasks.get(Math.min(tasks.size() - 1, visibleRange[0] + 1)),
- stackScroll, mTmpTransform);
+ int nextTaskStackScroll = mStackAlgorithm.getStackScrollForTaskIndex(task, 1);
+ mStackAlgorithm.getStackTransform(nextTaskStackScroll, stackScroll, mTmpTransform);
}
tv.updateViewPropertiesToTaskTransform(mTmpTransform, 0);
}
transformOut.reset();
return transformOut;
}
+ return getStackTransform(getStackScrollForTaskIndex(task), stackScroll, transformOut);
+ }
+ /** Update/get the transform */
+ public TaskViewTransform getStackTransform(int taskStackScroll, int stackScroll, TaskViewTransform transformOut) {
// Map the items to an continuous position relative to the specified scroll
int numPeekCards = StackPeekNumCards;
float overlapHeight = StackOverlapPct * mTaskRect.height();
float peekHeight = StackPeekHeightPct * mStackRect.height();
- float t = (getStackScrollForTaskIndex(task) - stackScroll) / overlapHeight;
+ float t = (taskStackScroll - stackScroll) / overlapHeight;
float boundedT = Math.max(t, -(numPeekCards + 1));
// Set the scale relative to its position
float minScale = StackPeekMinScale;
float scaleRange = 1f - minScale;
float scaleInc = scaleRange / (numPeekCards + numFrontScaledCards);
- float scale = Math.max(minScale, Math.min(1f, minScale +
- ((boundedT + (numPeekCards + 1)) * scaleInc)));
+ float scale = Math.max(minScale, Math.min(1f, minScale +
+ ((boundedT + (numPeekCards + 1)) * scaleInc)));
float scaleYOffset = ((1f - scale) * mTaskRect.height()) / 2;
// Account for the bar offsets being scaled?
float scaleBarYOffset = (1f - scale) * mConfig.taskBarHeight;
}
/**
+ * Returns the scroll to such that the task transform at that task + index will have t=0.
+ * (If the scroll is not bounded)
+ */
+ int getStackScrollForTaskIndex(Task t, int relativeIndexOffset) {
+ return mTaskOffsetMap.get(t.key) + (int) (relativeIndexOffset * getTaskOverlapHeight());
+ }
+
+ /**
* Updates the cache of tasks to offsets.
*/
void updateTaskOffsets(ArrayList<Task> tasks) {