Notify ItemFactory when an item is removed from ItemView 78/24178/1
authorRichard Huang <r.huang@samsung.com>
Wed, 18 Jun 2014 13:30:55 +0000 (14:30 +0100)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Tue, 8 Jul 2014 17:47:20 +0000 (18:47 +0100)
Change-Id: I0620a480d54d5fc78b7e032957f30829f5ae9feb
Signed-off-by: Adeel Kazmi <adeel.kazmi@samsung.com>
base/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp
base/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.h
capi/dali-toolkit/public-api/controls/scrollable/item-view/item-factory.h

index 73a25ff..b8899de 100644 (file)
@@ -585,7 +585,7 @@ void ItemView::ActivateLayout(unsigned int layoutIndex, const Vector3& targetSiz
   if (scrollAnimationNeeded)
   {
     RemoveAnimation(mScrollAnimation);
   if (scrollAnimationNeeded)
   {
     RemoveAnimation(mScrollAnimation);
-    mScrollAnimation = Animation::New(mAnchoringDuration);
+    mScrollAnimation = Animation::New(durationSeconds);
     mScrollAnimation.AnimateTo( Property( mScrollPositionObject, ScrollConnector::SCROLL_POSITION ), firstItemScrollPosition, AlphaFunctions::EaseOut );
     mScrollAnimation.AnimateTo( Property(self, mPropertyPosition), GetScrollPosition(firstItemScrollPosition, targetSize), AlphaFunctions::EaseOut );
     mScrollAnimation.Play();
     mScrollAnimation.AnimateTo( Property( mScrollPositionObject, ScrollConnector::SCROLL_POSITION ), firstItemScrollPosition, AlphaFunctions::EaseOut );
     mScrollAnimation.AnimateTo( Property(self, mPropertyPosition), GetScrollPosition(firstItemScrollPosition, targetSize), AlphaFunctions::EaseOut );
     mScrollAnimation.Play();
@@ -896,7 +896,8 @@ bool ItemView::RemoveActor(unsigned int itemId)
 
   if( removeIter != mItemPool.end() )
   {
 
   if( removeIter != mItemPool.end() )
   {
-    Self().Remove( removeIter->second );
+    ReleaseActor(itemId, removeIter->second);
+
     removed = true;
 
     // Adjust the remaining item IDs, for example if item 2 is removed:
     removed = true;
 
     // Adjust the remaining item IDs, for example if item 2 is removed:
@@ -932,7 +933,7 @@ void ItemView::ReplaceItem( Item replacementItem, float durationSeconds )
   const ItemPoolIter iter = mItemPool.find( replacementItem.first );
   if( mItemPool.end() != iter )
   {
   const ItemPoolIter iter = mItemPool.find( replacementItem.first );
   if( mItemPool.end() != iter )
   {
-    Self().Remove( iter->second );
+    ReleaseActor(iter->first, iter->second);
     iter->second = replacementItem.second;
   }
   else
     iter->second = replacementItem.second;
   }
   else
@@ -962,7 +963,7 @@ void ItemView::RemoveActorsOutsideRange( ItemRange range )
 
     if( ! range.Within( current ) )
     {
 
     if( ! range.Within( current ) )
     {
-      Self().Remove( iter->second );
+      ReleaseActor(iter->first, iter->second);
 
       mItemPool.erase( iter++ ); // erase invalidates the return value of post-increment; iter remains valid
     }
 
       mItemPool.erase( iter++ ); // erase invalidates the return value of post-increment; iter remains valid
     }
@@ -1037,6 +1038,12 @@ void ItemView::SetupActor( Item item, float durationSeconds )
   }
 }
 
   }
 }
 
+void ItemView::ReleaseActor( ItemId item, Actor actor )
+{
+  Self().Remove( actor );
+  mItemFactory.ItemReleased(item, actor);
+}
+
 ItemRange ItemView::GetItemRange(ItemLayout& layout, const Vector3& layoutSize, float layoutPosition, bool reserveExtra)
 {
   unsigned int itemCount = mItemFactory.GetNumberOfItems();
 ItemRange ItemView::GetItemRange(ItemLayout& layout, const Vector3& layoutSize, float layoutPosition, bool reserveExtra)
 {
   unsigned int itemCount = mItemFactory.GetNumberOfItems();
index bd143eb..62ba4df 100644 (file)
@@ -325,6 +325,13 @@ private:
    */
   void SetupActor( Item item, float durationSeconds );
 
    */
   void SetupActor( Item item, float durationSeconds );
 
+  /**
+   * Remove the Actor from the ItemPool and notify the ItemFactory the actor has been released by ItemView.
+   * @param[in] item The ID for the item to be released.
+   * @param[in] actor The actor to be removed from ItemView.
+   */
+  void ReleaseActor( ItemId item, Actor actor );
+
 private: // From CustomActorImpl
 
   /**
 private: // From CustomActorImpl
 
   /**
index fa5db20..f08a7e6 100644 (file)
@@ -33,7 +33,7 @@ namespace Toolkit
 {
 
 /**
 {
 
 /**
- * @brief ItemFactory is an abstract interface for providing actors to ItemView.
+ * @brief ItemFactory is for providing actors to ItemView.
  * Each actor is identified by a unique ID, and has a linear order from 0 to GetNumberOfItems()-1.
  */
 class ItemFactory
  * Each actor is identified by a unique ID, and has a linear order from 0 to GetNumberOfItems()-1.
  */
 class ItemFactory
@@ -60,6 +60,14 @@ public:
    * @return An actor, or an uninitialized pointer if the ID is out of range.
    */
   virtual Actor NewItem(unsigned int itemId) = 0;
    * @return An actor, or an uninitialized pointer if the ID is out of range.
    */
   virtual Actor NewItem(unsigned int itemId) = 0;
+
+  /**
+   * @brief Notify the factory the actor representing the item is removed from ItemView.
+   *
+   * @param[in] itemId The ID of the released item.
+   * @param[in] actor The actor that represents the released item.
+   */
+  virtual void ItemReleased(unsigned int itemId, Actor actor) {};
 };
 
 } // namespace Toolkit
 };
 
 } // namespace Toolkit