X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fscrollable%2Fitem-view%2Fitem-view-impl.h;h=f92894ede81ab7b0458333df8bbd4a8f0242041c;hp=00262f22693c799b4ec255af126fba34bccec9cd;hb=ae1982a116aae1d8e25837fa553ba2e37bc062a7;hpb=e2eda444afbe82e9591fe198eef339227f90a616 diff --git a/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.h b/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.h index 00262f2..f92894e 100644 --- a/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.h +++ b/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.h @@ -19,11 +19,13 @@ // EXTERNAL INCLUDES #include +#include // INTERNAL INCLUDES #include #include #include +#include #include #include #include @@ -42,91 +44,6 @@ class ItemView; typedef IntrusivePtr ItemViewPtr; /** - * ItemPool is container of Actor/ID pairs stored by ItemView - */ -class ItemPool -{ -public: // types - - typedef std::pair IDKeyPair; - typedef std::map IDKeyContainer; - typedef IDKeyContainer::iterator IDKeyIter; - typedef IDKeyContainer::const_iterator IDKeyConstIter; - - typedef std::pair ActorKeyPair; - typedef std::map ActorKeyContainer; - typedef ActorKeyContainer::iterator ActorKeyIter; - typedef ActorKeyContainer::const_iterator ActorKeyConstIter; - -public: // Construction & Destruction - - /** - * Constructor - * @param[in] itemView A reference to the ItemView class that owns this. - */ - ItemPool(ItemView& itemView) - : mItemView(itemView) - { - } - -public: // Methods - - /** - * Returns a const reference to the IDKeyContainer whose key is based on the Item ID. - * @return Const reference to IDKeyContainer. - */ - const IDKeyContainer& GetIDKeyContainer() const - { - return mIdKeyContainer; - } - - /** - * Returns a const reference to the ActorKeyContainer whose key is based on the Actor. - * @return Const reference to IDKeyContainer. - */ - const ActorKeyContainer& GetActorKeyContainer() const - { - return mActorKeyContainer; - } - - /** - * Add a range of items to the ItemPool, if they are not already in the ItemPool. - * @param[in] scrollingTowardsLast Should be true if scrolling towards the last item in the range. - * @param[in] range The range of Item IDs to associate with the new actors. - * @param[in] targetSize The current size of the layout. - */ - void AddItems(bool scrollingTowardsLast, ItemRange range, const Vector3& targetSize); - - /** - * Remove items from the ItemPool that are outside the given range. - * @param[in] range The range of required items. - */ - void RemoveItems(ItemRange range); - - /** - * Remove an item from the ItemPool. - * @param[in] itemId The item to remove. - * @return Whether the item is found and removed or not. - */ - bool RemoveItem(unsigned int itemId); - -private: - - /** - * Adds an item, if not already in the ItemPool. - * @param[in] itemId The item to add. - * @param[in] targetSize The target size of the layout. - */ - void AddItem(unsigned int itemId, const Vector3& targetSize); - -private: - - IDKeyContainer mIdKeyContainer; - ActorKeyContainer mActorKeyContainer; - ItemView& mItemView; -}; - -/** * ItemView is a scrollable layout container. * Multiple ItemLayouts may be provided, to determine the logical position of each item a layout. * Actor-ID pairs are provided from a shared ItemFactory, to display the currently visible items. @@ -143,6 +60,11 @@ public: static Dali::Toolkit::ItemView New(ItemFactory& factory); /** + * @copydoc Toolkit::ItemView::GetScrollConnector + */ + Dali::Toolkit::ScrollConnector GetScrollConnector() const; + + /** * @copydoc Toolkit::ItemView::GetLayoutCount */ unsigned int GetLayoutCount() const; @@ -258,9 +180,34 @@ public: unsigned int GetItemId(Actor actor) const; /** + * @copydoc Toolkit::ItemView::InsertItem + */ + void InsertItem(Item newItem, float durationSeconds); + + /** + * @copydoc Toolkit::ItemView::InsertItem + */ + void InsertItems(const ItemContainer& newItems, float durationSeconds); + + /** * @copydoc Toolkit::ItemView::RemoveItem */ - void RemoveItem(unsigned int itemId, float durationSeconds); + void RemoveItem(ItemId itemId, float durationSeconds); + + /** + * @copydoc Toolkit::ItemView::InsertItem + */ + void RemoveItems(const ItemIdContainer& itemIds, float durationSeconds); + + /** + * @copydoc Toolkit::ItemView::InsertItem + */ + void ReplaceItem(Item replacementItem, float durationSeconds); + + /** + * @copydoc Toolkit::ItemView::InsertItem + */ + void ReplaceItems(const ItemContainer& replacementItems, float durationSeconds); /** * @copydoc Toolkit::Scrollable::GetDomainSize @@ -287,30 +234,40 @@ public: */ void ScrollTo(const Vector3& position, float duration); -public: // Used By ItemPool +private: + + /** + * Remove an Actor if found in the ItemPool. + * @param[in] itemId The item to remove. + * @return True if an actor was removed. + */ + bool RemoveActor( unsigned int itemId ); + + /** + * Remove any Actors outside a given range. + * @param[in] @param[in] range The range of required items. + */ + void RemoveActorsOutsideRange( ItemRange range ); /** - * Called by the ItemPool when it wishes to create an actor from the ItemFactory with the - * specified ItemId. - * @param[in] itemId The Item ID of the actor to create. + * Add a range of Actors, if they are not already in the ItemPool. + * @param[in] layout The active layout. + * @param[in] range The range of Item IDs to associate with the new actors. */ - Actor CreateActor(unsigned int itemId); + void AddActorsWithinRange( ItemRange range ); /** - * Called by the ItemPool when an actor is added to the ItemPool. - * @param[in] actor The actor that has been added. - * @param[in] itemId The associated Item ID. - * @param[in] targetSize The target size that was specified upon addition. + * Add a new Actor, if not already in the ItemPool. + * @param[in] item The ID for the new item. */ - void ActorAddedToItemPool(Actor actor, unsigned int itemId, const Vector3& targetSize); + void AddNewActor( ItemId item ); /** - * Called by the ItemPool when an actor with the specified itemId is about to be removed from the - * ItemPool. - * @param[in] actor The actor about to be removed. - * @param[in] itemId The associated Item ID. + * Apply the constraints etc. that are required for ItemView children. + * @param[in] item The item to setup. + * @param[in] durationSeconds The time taken to fully constrain the actor. */ - void ActorRemovedFromItemPool(Actor actor, unsigned int itemId); + void SetupActor( Item item, float durationSeconds ); private: // From CustomActorImpl @@ -381,6 +338,12 @@ private: void ApplyConstraints(Actor& actor, ItemLayout& layout, unsigned int itemId, float durationSeconds); /** + * Helper to re-apply all the constraints after items have been inserted, removed etc. + * @param[in] durationSeconds The time taken to fully constrain the actors. + */ + void ReapplyAllConstraints( float durationSeconds ); + + /** * Helper to remove items outside a given range. * @param[in] range The range of required items. */ @@ -508,7 +471,6 @@ private: */ void CalculateDomainSize(const Vector3& layoutSize); - /** * Calculates whether we want to allow current item view to scroll. * @param[in] layoutSize The current size of the layout. @@ -520,10 +482,15 @@ private: ItemFactory& mItemFactory; + typedef std::map ItemPool; + typedef ItemPool::iterator ItemPoolIter; + typedef ItemPool::const_iterator ConstItemPoolIter; + ItemPool mItemPool; ItemLayoutContainer mLayouts; ItemLayout* mActiveLayout; + Vector3 mActiveLayoutTargetSize; Animation mResizeAnimation; Animation mScrollAnimation; @@ -559,7 +526,9 @@ private: ImageActor mOvershootOverlay; ///< The overlay actor for overshoot effect OvershootRippleEffect mOvershootEffect; ///< The vertex/fragment shader used to display the overshoot ripple effect - Property::Index mPropertyLayoutPosition; ///< The logical position of the first item within the layout + Dali::Toolkit::ScrollConnector mScrollConnector; ///< Connects ItemView with scrollable components e.g. scroll bars + Constrainable mScrollPositionObject; ///< From mScrollConnector + Property::Index mPropertyPosition; ///< The physical position of the first item within the layout Property::Index mPropertyMinimumLayoutPosition; ///< The minimum valid layout position in the layout. Property::Index mPropertyScrollSpeed; ///< The current scroll speed of item view