// INTERNAL INCLUDES
#include <dali/public-api/events/mouse-wheel-event.h>
#include <dali-toolkit/public-api/controls/scrollable/item-view/item-factory.h>
-#include <dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.h>
#include <dali-toolkit/internal/controls/scrollable/scroll-connector-impl.h>
using namespace std;
mScrollOvershoot(0.0f),
mIsFlicking(false),
mGestureState(Gesture::Clear),
- mAddingItems(false)
+ mAddingItems(false),
+ mRefreshEnabled(true)
{
SetRequiresMouseWheelEvents(true);
SetKeyboardNavigationSupport(true);
}
// Refresh the new layout
- ItemRange range = GetItemRange(*mActiveLayout, targetSize, true/*reserve extra*/);
+ ItemRange range = GetItemRange(*mActiveLayout, targetSize, GetCurrentLayoutPosition(0), true/*reserve extra*/);
AddActorsWithinRange( range, durationSeconds );
// Scroll to an appropriate layout position
void ItemView::OnRefreshNotification(PropertyNotification& source)
{
+ if(mRefreshEnabled)
+ {
+ // Only refresh the cache during normal scrolling
+ DoRefresh(GetCurrentLayoutPosition(0), true);
+ }
+}
+
+void ItemView::DoRefresh(float currentLayoutPosition, bool cacheExtra)
+{
if (mActiveLayout)
{
- ItemRange range = GetItemRange(*mActiveLayout, mActiveLayoutTargetSize, true/*reserve extra*/);
+ ItemRange range = GetItemRange(*mActiveLayout, mActiveLayoutTargetSize, currentLayoutPosition, cacheExtra/*reserve extra*/);
RemoveActorsOutsideRange( range );
AddActorsWithinRange( range, 0.0f/*immediate*/ );
- Vector3 currentScrollPosition = GetCurrentScrollPosition();
- mScrollUpdatedSignalV2.Emit( currentScrollPosition );
+ mScrollUpdatedSignalV2.Emit( Vector3(0.0f, currentLayoutPosition, 0.0f) );
}
}
return mRefreshIntervalLayoutPositions;
}
+void ItemView::SetRefreshEnabled(bool enabled)
+{
+ mRefreshEnabled = enabled;
+}
+
Actor ItemView::GetItem(unsigned int itemId) const
{
Actor actor;
}
}
-ItemRange ItemView::GetItemRange(ItemLayout& layout, const Vector3& layoutSize, bool reserveExtra)
+ItemRange ItemView::GetItemRange(ItemLayout& layout, const Vector3& layoutSize, float layoutPosition, bool reserveExtra)
{
unsigned int itemCount = mItemFactory.GetNumberOfItems();
ItemRange available(0u, itemCount);
- ItemRange range = layout.GetItemsWithinArea( GetCurrentLayoutPosition(0), layoutSize );
+ ItemRange range = layout.GetItemsWithinArea( layoutPosition, layoutSize );
if (reserveExtra)
{
if(!mAddingItems)
{
// We don't want to do this downcast check for any item added by ItemView itself.
- Dali::Toolkit::ScrollBar scrollBar = Dali::Toolkit::ScrollBar::DownCast(child);
- if(scrollBar)
+ Dali::Toolkit::ScrollComponent scrollComponent = Dali::Toolkit::ScrollComponent::DownCast(child);
+ if(scrollComponent)
{
// Set the scroll connector when scroll bar is being added
- scrollBar.SetScrollConnector(mScrollConnector);
+ scrollComponent.SetScrollConnector(mScrollConnector);
}
}
}