Configurable anchor point and parent origin of the items in an ItemView control
authorFerran Sole <ferran.sole@samsung.com>
Wed, 7 May 2014 12:31:42 +0000 (13:31 +0100)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Thu, 15 May 2014 11:53:38 +0000 (12:53 +0100)
[Issue] N/A
[Problem] ItemView set parent origin and anchor point of new items to the center
[Cause] N/A
[Solution] Added functions to set a different anchor point and parent origin

base/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp
base/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.h
base/dali-toolkit/public-api/controls/scrollable/item-view/item-view.cpp
capi/dali-toolkit/public-api/controls/scrollable/item-view/item-view.h

index 8bebcd5..93effd8 100644 (file)
@@ -411,7 +411,9 @@ ItemView::ItemView(ItemFactory& factory)
   mIsFlicking(false),
   mGestureState(Gesture::Clear),
   mAddingItems(false),
-  mRefreshEnabled(true)
+  mRefreshEnabled(true),
+  mItemsParentOrigin( ParentOrigin::CENTER),
+  mItemsAnchorPoint( AnchorPoint::CENTER)
 {
   SetRequiresMouseWheelEvents(true);
   SetKeyboardNavigationSupport(true);
@@ -1019,8 +1021,8 @@ void ItemView::AddNewActor( unsigned int itemId, float durationSeconds )
 
 void ItemView::SetupActor( Item item, float durationSeconds )
 {
-  item.second.SetParentOrigin( ParentOrigin::CENTER );
-  item.second.SetAnchorPoint( AnchorPoint::CENTER );
+  item.second.SetParentOrigin( mItemsParentOrigin );
+  item.second.SetAnchorPoint( mItemsAnchorPoint );
 
   if( mActiveLayout )
   {
@@ -1766,6 +1768,40 @@ void ItemView::AnimateScrollOvershoot(float overshootAmount, bool animateBack)
   mAnimatingOvershootOn = animatingOn;
 }
 
+void ItemView::SetItemsParentOrigin( const Vector3& parentOrigin )
+{
+  if( parentOrigin != mItemsParentOrigin )
+  {
+    mItemsParentOrigin = parentOrigin;
+    for (ItemPoolIter iter = mItemPool.begin(); iter != mItemPool.end(); ++iter)
+    {
+      iter->second.SetParentOrigin(parentOrigin);
+    }
+  }
+}
+
+Vector3 ItemView::GetItemsParentOrigin() const
+{
+  return mItemsParentOrigin;
+}
+
+void ItemView::SetItemsAnchorPoint( const Vector3& anchorPoint )
+{
+  if( anchorPoint != mItemsAnchorPoint )
+  {
+    mItemsAnchorPoint = anchorPoint;
+    for (ItemPoolIter iter = mItemPool.begin(); iter != mItemPool.end(); ++iter)
+    {
+      iter->second.SetAnchorPoint(anchorPoint);
+    }
+  }
+}
+
+Vector3 ItemView::GetItemsAnchorPoint() const
+{
+  return mItemsAnchorPoint;
+}
+
 } // namespace Internal
 
 } // namespace Toolkit
index d7e1340..242cf27 100644 (file)
@@ -262,6 +262,27 @@ public:
    */
   void DoRefresh(float currentLayoutPosition, bool cacheExtra);
 
+
+  /**
+   * @copydoc Toolkit::ItemView::SetItemsParentOrigin
+   */
+  void SetItemsParentOrigin( const Vector3& parentOrigin );
+
+  /**
+   * @copydoc Toolkit::ItemView::GetItemsParentOrigin
+   */
+  Vector3 GetItemsParentOrigin() const;
+
+  /**
+   * @copydoc Toolkit::ItemView::SetItemsAnchorPoint
+   */
+  void SetItemsAnchorPoint( const Vector3& anchorPoint );
+
+  /**
+   * @copydoc Toolkit::ItemView::GetItemsAnchorPoint
+   */
+  Vector3 GetItemsAnchorPoint() const;
+
 private:
 
   /**
@@ -564,6 +585,9 @@ private:
   Property::Index mPropertyScrollSpeed; ///< The current scroll speed of item view
 
   bool mRefreshEnabled; ///< Whether to refresh the cache automatically
+
+  Vector3 mItemsParentOrigin;
+  Vector3 mItemsAnchorPoint;
 };
 
 } // namespace Internal
index d9f856e..c41fd61 100644 (file)
@@ -227,6 +227,27 @@ void ItemView::ReplaceItems(const ItemContainer& replacementItems, float duratio
   GetImpl(*this).ReplaceItems( replacementItems, durationSeconds );
 }
 
+
+void ItemView::SetItemsParentOrigin( const Vector3& parentOrigin )
+{
+  GetImpl(*this).SetItemsParentOrigin( parentOrigin );
+}
+
+Vector3 ItemView::GetItemsParentOrigin() const
+{
+  return GetImpl(*this).GetItemsParentOrigin();
+}
+
+void ItemView::SetItemsAnchorPoint( const Vector3& anchorPoint )
+{
+  GetImpl(*this).SetItemsAnchorPoint(anchorPoint);
+}
+
+Vector3 ItemView::GetItemsAnchorPoint() const
+{
+  return GetImpl(*this).GetItemsAnchorPoint();
+}
+
 } // namespace Toolkit
 
 } // namespace Dali
index 82752b0..c8d101b 100644 (file)
@@ -381,6 +381,36 @@ public:
    */
   void ReplaceItems(const ItemContainer& replacementItems, float durationSeconds);
 
+  /**
+   * @brief Set the parent origin of the items
+   *
+   * A relayout will occur for all the items if the parent origin is different than the current one.
+   * @param[in] parentOrigin New parent origin position vector
+   */
+  void SetItemsParentOrigin( const Vector3& parentOrigin );
+
+  /**
+   * @brief Get the parent origin of the items
+   *
+   * @return The current parent origin of the items
+   */
+  Vector3 GetItemsParentOrigin() const;
+
+  /**
+   * @brief Set the anchor point of the items
+   *
+   * A relayout will occur for all the items if the anchor point is different than the current one.
+   * @param[in] anchorPoint New anchor point position vector
+   */
+  void SetItemsAnchorPoint( const Vector3& anchorPoint );
+
+  /**
+   * @brief Get the anchor point of the items
+   *
+   * @return The current anchor point of the items
+   */
+  Vector3 GetItemsAnchorPoint() const;
+
 public: // Not intended for application developers
 
   /**