mActiveLayoutTargetSize = targetSize;
// Switch to the new layout
- ItemLayout* previousLayout = mActiveLayout;
mActiveLayout = mLayouts[layoutIndex].Get();
- // Calculate which items are within either layout
- ItemRange oldRange = previousLayout ? GetItemRange(*previousLayout, targetSize, false/*don't reserve extra*/) : ItemRange(0u, 0u);
- ItemRange newRange = GetItemRange(*mActiveLayout, targetSize, false/*don't reserve extra*/);
-
// Move the items to the new layout positions...
bool resizeAnimationNeeded(false);
unsigned int itemId = iter->first;
Actor actor = iter->second;
- // Immediately relayout items that aren't within either layout
- bool immediate = !oldRange.Within(itemId) &&
- !newRange.Within(itemId);
-
// Remove constraints from previous layout
actor.RemoveConstraints();
Vector3 size;
if(mActiveLayout->GetItemSize(itemId, targetSize, size))
{
- if (!immediate &&
- durationSeconds > 0.0f)
+ if( durationSeconds > 0.0f )
{
// Use a size animation
if (!resizeAnimationNeeded)
}
}
- ApplyConstraints(actor, *mActiveLayout, itemId, immediate ? 0.0f : durationSeconds);
+ ApplyConstraints(actor, *mActiveLayout, itemId, durationSeconds);
}
if (resizeAnimationNeeded)
// Refresh the new layout
ItemRange range = GetItemRange(*mActiveLayout, targetSize, true/*reserve extra*/);
- AddActorsWithinRange( range );
+ AddActorsWithinRange( range, durationSeconds );
// Scroll to an appropriate layout position
RemoveActorsOutsideRange( range );
- AddActorsWithinRange( range );
+ AddActorsWithinRange( range, 0.0f/*immediate*/ );
// Keep refreshing whilst the layout is moving
return mScrollAnimation || (mGestureState == Gesture::Started || mGestureState == Gesture::Continuing);
}
}
-void ItemView::AddActorsWithinRange( ItemRange range )
+void ItemView::AddActorsWithinRange( ItemRange range, float durationSeconds )
{
range.end = min(mItemFactory.GetNumberOfItems(), range.end);
{
for (unsigned int itemId = range.begin; itemId < range.end; ++itemId)
{
- AddNewActor( itemId );
+ AddNewActor( itemId, durationSeconds );
}
}
else
{
for (unsigned int itemId = range.end; itemId > range.begin; --itemId)
{
- AddNewActor( itemId-1 );
+ AddNewActor( itemId-1, durationSeconds );
}
}
}
-void ItemView::AddNewActor( unsigned int itemId )
+void ItemView::AddNewActor( unsigned int itemId, float durationSeconds )
{
if( mItemPool.end() == mItemPool.find( itemId ) )
{
mItemPool.insert( newItem );
- SetupActor( newItem, 0.0f/*immediate*/ );
+ SetupActor( newItem, durationSeconds );
Self().Add( actor );
}
}