X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Fpublic-api%2Fcontrols%2Fscrollable%2Fitem-view%2Fitem-layout.h;h=995bb1bbf5205813f15227d750f67d238d12150f;hp=169ad2b069c0ceb62ee578b128aa077bbab315fc;hb=b694e7e2ae624e206e1548b1a863c554eb9cd4d7;hpb=030e7c680a6eb0e8d87bfdb8ec359a0267ef7db2 diff --git a/dali-toolkit/public-api/controls/scrollable/item-view/item-layout.h b/dali-toolkit/public-api/controls/scrollable/item-view/item-layout.h old mode 100644 new mode 100755 index 169ad2b..995bb1b --- a/dali-toolkit/public-api/controls/scrollable/item-view/item-layout.h +++ b/dali-toolkit/public-api/controls/scrollable/item-view/item-layout.h @@ -1,8 +1,8 @@ -#ifndef __DALI_TOOLKIT_ITEM_LAYOUT_H__ -#define __DALI_TOOLKIT_ITEM_LAYOUT_H__ +#ifndef DALI_TOOLKIT_ITEM_LAYOUT_H +#define DALI_TOOLKIT_ITEM_LAYOUT_H /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,9 +19,9 @@ */ // EXTERNAL INCLUDES -#include #include -#include +#include +#include // INTERNAL INCLUDES #include @@ -32,26 +32,27 @@ namespace Dali namespace Toolkit { +/** + * @addtogroup dali_toolkit_controls_item_view + * @{ + */ class ItemLayout; -typedef IntrusivePtr ItemLayoutPtr; ///< Pointer to a Dali::Toolkit::ItemLayout object - -typedef std::vector ItemLayoutContainer; ///< Container of Dali::Toolkit::ItemLayout objects -typedef ItemLayoutContainer::iterator ItemLayoutIter; ///< Iterator for Dali::Toolkit::ItemLayoutContainer -typedef ItemLayoutContainer::const_iterator ItemLayoutConstIter; ///< Const Iterator for Dali::Toolkit::ItemLayoutContainer - +typedef IntrusivePtr ItemLayoutPtr; ///< Pointer to a Dali::Toolkit::ItemLayout object @SINCE_1_0.0 /** * @brief A support class for managing ranges of items. + * @SINCE_1_0.0 */ struct ItemRange { /** - * @brief Create a range of item identifiers. + * @brief Creates a range of item identifiers. * - * @param[in] beginItem The first item within the range. - * @param[in] endItem The past-the-end item. + * @SINCE_1_0.0 + * @param[in] beginItem The first item within the range + * @param[in] endItem The past-the-end item */ ItemRange(unsigned int beginItem, unsigned int endItem) : begin(beginItem), @@ -62,7 +63,8 @@ struct ItemRange /** * @brief Copy Constructor. * - * @param[in] copy ItemRange we should copy from. + * @SINCE_1_0.0 + * @param[in] copy ItemRange we should copy from */ ItemRange(const ItemRange& copy) : begin(copy.begin), @@ -73,21 +75,26 @@ struct ItemRange /** * @brief Assignment operator. * - * @param[in] range The Range to assign from. - * @return The updated range. + * @SINCE_1_0.0 + * @param[in] range The Range to assign from + * @return The updated range */ ItemRange& operator=(const ItemRange& range) { - begin = range.begin; - end = range.end; + if( this != &range ) + { + begin = range.begin; + end = range.end; + } return *this; } /** - * @brief Test whether an item is within the range. + * @brief Tests whether an item is within the range. * - * @param[in] itemId The item identifier. - * @return True if the item is within the range. + * @SINCE_1_0.0 + * @param[in] itemId The item identifier + * @return true if the item is within the range */ bool Within(unsigned int itemId) { @@ -96,10 +103,11 @@ struct ItemRange } /** - * @brief Create the intersection of two ranges. + * @brief Creates the intersection of two ranges. * - * @param[in] second The second range. - * @return The intersection. + * @SINCE_1_0.0 + * @param[in] second The second range + * @return The intersection */ ItemRange Intersection(const ItemRange& second) { @@ -128,46 +136,77 @@ struct ItemRange * * An ItemLayout also describes the direction of input gestures, used to scroll through the layout. * Whilst scrolling, the layout provides a range of items that are within a layout-area (3D bounding volume). + * @SINCE_1_0.0 */ -class DALI_IMPORT_API ItemLayout : public RefObject +class DALI_TOOLKIT_API ItemLayout : public RefObject { public: - /// @brief Function signature of a boolean constraint - typedef boost::function BoolFunction; - - /// @brief Function signature of a Vector3 constraint - typedef boost::function Vector3Function; - - /// @brief Function signature of a Vector4 constraint - typedef boost::function Vector4Function; - - /// @brief Function signature of a Quaternion constraint - typedef boost::function QuaternionFunction; + class Extension; ///< Forward declare future extension interface /** * @brief Virtual destructor. + * @SINCE_1_0.0 */ - DALI_IMPORT_API virtual ~ItemLayout(); + virtual ~ItemLayout(); /** * @brief Set the orientation of the layout. * + * @SINCE_1_0.0 * @param[in] orientation The orientation of the layout. */ - DALI_IMPORT_API void SetOrientation(ControlOrientation::Type orientation); + void SetOrientation(ControlOrientation::Type orientation); /** * @brief Query the orientation of the layout. * + * @SINCE_1_0.0 * @return the orientation of the layout. */ - DALI_IMPORT_API ControlOrientation::Type GetOrientation() const; + ControlOrientation::Type GetOrientation() const; + + /** + * @brief Apply the layout Properties. + * @SINCE_1_2.20 + * @param[in] properties The properties the layout. + */ + void SetLayoutProperties(const Property::Map& properties); + + /** + * @brief Get the layout Properties. + * @SINCE_1_2.20 + * @return the property of the layout. + */ + Property::Map GetLayoutProperties(); + + /** + * @brief Retrieve the target size of an item in the layout. + * + * This will return the default size for the layout unless overridden by calling SetItemSize(). + * + * @SINCE_1_0.0 + * @param[in] itemId The ID of an item in the layout. + * @param[in] layoutSize The layout size + * @param[out] itemSize The target size of an item. + * @note layout-position is not provided as a parameter, since applying size constraints is not recommended. + * Animating to target-sizes is preferable, since this allows controls to perform layouting without constraints. + */ + void GetItemSize( unsigned int itemId, const Vector3& layoutSize, Vector3& itemSize ) const; + + /** + * @brief Overrides the default size for the layout. + * + * @SINCE_1_0.0 + * @param[in] itemSize The size of each item. + */ + void SetItemSize( const Vector3& itemSize ); /** * @brief Query the minimum valid layout position; this is a negative value. * * When scrolling, the first item will move within the range 0 to GetMinimumLayoutPosition(). + * @SINCE_1_0.0 * @param[in] numberOfItems The current number of items in the layout. * @param[in] layoutSize The size of the layout area. * @return The minimum layout position. @@ -179,6 +218,7 @@ public: * * This anchor position is the position where all the items in the layout are aligned to * their rounded layout positions in integer. + * @SINCE_1_0.0 * @param[in] layoutPosition The layout position. * @return The closest anchor position for the given layout position. */ @@ -188,6 +228,7 @@ public: * @brief Query the layout position for the first item in the layout to move to when the layout * needs to scroll to a particular item. * + * @SINCE_1_0.0 * @param[in] itemId The ID of an item in the layout. * @return The layout position for the first item in the layout to move to. */ @@ -196,6 +237,7 @@ public: /** * @brief Query the items within a given layout-area. * + * @SINCE_1_0.0 * @param[in] firstItemPosition The layout-position of the first item in the layout. * @param[in] layoutSize The size of the layout area. * @return The ID of the first & last visible item. @@ -213,16 +255,18 @@ public: * implementations should provide their own version of this function * to ensure proper functionality of internal toolkit systems. * + * @SINCE_1_0.0 * @param[in] itemID id of the item to bring within the viewable screen area * @param[in] currentLayoutPosition the current layout position of the item view instance * @param[in] layoutSize the current size of the item view instance * @return The layout position */ - DALI_IMPORT_API virtual float GetClosestOnScreenLayoutPosition(int itemID, float currentLayoutPosition, const Vector3& layoutSize); + virtual float GetClosestOnScreenLayoutPosition(int itemID, float currentLayoutPosition, const Vector3& layoutSize); /** * @brief Query the number of items that should be reserved, for scrolling purposes. * + * @SINCE_1_0.0 * @param[in] layoutSize The size of the layout area. * @return The number of extra items. ItemView will populate itself with actors within the layout-area * (see GetItemsWithinArea), plus this number of additional items on either-side. @@ -230,83 +274,23 @@ public: virtual unsigned int GetReserveItemCount(Vector3 layoutSize) const = 0; /** - * @brief Retrieve the target size of an item in the layout. + * @brief Retrieve the default size of an item in the layout. * - * @note layout-position is not provided as a parameter, since applying size constraints is not recommended. - * Animating to target-sizes is preferable, since this allows controls to perform layouting without constraints. + * @SINCE_1_0.0 * @param[in] itemId The ID of an item in the layout. * @param[in] layoutSize The layout size - * @param[out] itemSize The target size of an item, or an uninitialized value. - * @return Whether the item size is available or not - */ - virtual bool GetItemSize(unsigned int itemId, Vector3 layoutSize, Vector3& itemSize) const = 0; - - /** - * @brief Retrieve the resize animation in the layout. - * - * @note This allows the layout to provide its own resize animation. - * @param[in] animation The resize animation, not owned by the layout - * @param[in] actor The actor to animate - * @param [in] size The target size. - * @param [in] durationSeconds The duration of the resizing. - */ - virtual void GetResizeAnimation(Animation& animation, Actor actor, Vector3 size, float durationSeconds) const = 0; - - /** - * @brief Retrieve the position constraint function of an item in the layout. - * - * The constraint will be applied when the item is created or the layout is activated. - * @param[in] itemId The ID of an item in the layout. - * @param[out] constraint The position constraint function of an item, or an uninitialized function pointer. - * @return Whether the position constraint function of an item is available or not - */ - virtual bool GetPositionConstraint(unsigned int itemId, Vector3Function& constraint) const = 0; - - /** - * @brief Retrieve the rotation constraint function of an item in the layout. - * - * The constraint will be applied when the item is created or the layout is activated. - * @param[in] itemId The ID of an item in the layout. - * @param[out] constraint The rotation constraint function of an item, or an uninitialized function pointer. - * @return Whether the rotation constraint function of an item is available or not - */ - virtual bool GetRotationConstraint(unsigned int itemId, QuaternionFunction& constraint) const = 0; - - /** - * @brief Retrieve the scale constraint function of an item in the layout. - * - * The constraint will be applied when the item is created or the layout is activated. - * @param[in] itemId The ID of an item in the layout. - * @param[out] constraint The scale constraint function of an item, or an uninitialized function pointer. - * @return Whether the scale constraint function of an item is available or not - */ - virtual bool GetScaleConstraint(unsigned int itemId, Vector3Function& constraint) const = 0; - - /** - * @brief Retrieve the color constraint function of an item in the layout. - * - * The constraint will be applied when the item is created or the layout is activated. - * @param[in] itemId The ID of an item in the layout. - * @param[out] constraint The color constraint function of an item, or an uninitialized function pointer. - * @return Whether the color constraint function of an item is available or not - */ - virtual bool GetColorConstraint(unsigned int itemId, Vector4Function& constraint) const = 0; - - /** - * @brief Retrieve the visibility constraint function of an item in the layout. - * - * The constraint will be applied when the item is created or the layout is activated. - * @param[in] itemId The ID of an item in the layout. - * @param[out] constraint The visibility constraint function of an item, or an uninitialized function pointer. - * @return Whether the visibility constraint function of an item is available or not + * @param[out] itemSize The target size of an item. + * @note layout-position is not provided as a parameter, since applying size constraints is not recommended. + * Animating to target-sizes is preferable, since this allows controls to perform layouting without constraints. */ - virtual bool GetVisibilityConstraint(unsigned int itemId, BoolFunction& constraint) const = 0; + virtual void GetDefaultItemSize( unsigned int itemId, const Vector3& layoutSize, Vector3& itemSize ) const = 0; /** * @brief Query the scroll direction of the layout. * * When an input gesture follows this direction, the layout-position of items will be increased. * If the input gesture points in the opposite direction, then the layout-positions will decrease. + * @SINCE_1_0.0 * @return The scroll direction in degrees. */ virtual Degree GetScrollDirection() const = 0; @@ -321,6 +305,7 @@ public: * position of actors will be moved by 1. * Therefore, the bigger the factor is, the faster the scroll speed will be. * + * @SINCE_1_0.0 * @return The scroll speed factor of the layout. */ virtual float GetScrollSpeedFactor() const = 0; @@ -329,6 +314,7 @@ public: * @brief Query the maximum swipe speed in pixels per second. * * Swipe gestures will be clamped when exceeding this speed limit. + * @SINCE_1_0.0 * @return speed The maximum swipe speed. */ virtual float GetMaximumSwipeSpeed() const = 0; @@ -339,6 +325,7 @@ public: * This is the time taken to animate each * item to its next layout position (e.g. from 1.0 to 2.0) when a flick animation is triggered * by a swipe gesture. + * @SINCE_1_0.0 * @return The duration of the flick animation. */ virtual float GetItemFlickAnimationDuration() const = 0; @@ -346,13 +333,14 @@ public: /** * @brief Gets the id of the next item for KeyboardFocusManager to focus on depending on the inputted item ID. * + * @SINCE_1_0.0 * @param[in] itemID The current focused item * @param[in] maxItems The maximum number of items in the list * @param[in] direction The directional key pressed on the keyboard * @param[in] loopEnabled Whether the KeyboardFocusManager is set to wrap around between first and last item * @return The next item ID. */ - DALI_IMPORT_API virtual int GetNextFocusItemID(int itemID, int maxItems, Dali::Toolkit::Control::KeyboardFocusNavigationDirection direction, bool loopEnabled); + virtual int GetNextFocusItemID(int itemID, int maxItems, Dali::Toolkit::Control::KeyboardFocus::Direction direction, bool loopEnabled); /** * @brief Query the flick speed factor of the layout while swipping. @@ -364,61 +352,76 @@ public: * position of actors will be moved by 1. * Therefore, the bigger the factor is, the faster the flick speed will be. * + * @SINCE_1_0.0 * @return The scroll speed factor of the layout. */ - DALI_IMPORT_API virtual float GetFlickSpeedFactor() const; + virtual float GetFlickSpeedFactor() const; - /* + /** * @brief Applies constraints defined by the layout to an actor. * * @param[in] actor The actor to constrain. * @param[in] itemId The ID of the item represented by the actor. - * @param[in] durationSeconds The time taken to fully constrain the actors. - * @param[in] scrollPositionObject The object which provides the layout position property. + * @param[in] layoutSize The current size of the item view instance. * @param[in] itemViewActor The item view instance which requests the application of constraints. */ - DALI_IMPORT_API virtual void ApplyConstraints( Actor& actor, const int itemId, const float durationSeconds, Handle scrollPositionObject, const Actor& itemViewActor ); + virtual void ApplyConstraints( Actor& actor, const int itemId, const Vector3& layoutSize, const Actor& itemViewActor ) = 0; /** * @brief Gets the position of a given item * - * @param[in] itemID id of the item we want to get its position - * @param[in] currentLayoutPosition the current layout position of the item view instance - * @param[in] layoutSize the current size of the item view instance + * @SINCE_1_0.0 + * @param[in] itemID The id of the item we want to get its position + * @param[in] currentLayoutPosition The current layout position of the item view instance + * @param[in] layoutSize The current size of the item view instance * @return The item position (x,y,z) */ - DALI_IMPORT_API virtual Vector3 GetItemPosition(int itemID, float currentLayoutPosition, const Vector3& layoutSize) const; + virtual Vector3 GetItemPosition(int itemID, float currentLayoutPosition, const Vector3& layoutSize) const = 0; /** - * @brief Set the alpha function used when applying constraints + * @brief Retrieve the extension for this layout. * - * @param[in] func The alpha function to use. + * @SINCE_1_0.0 + * @return The extension if available, NULL otherwise */ - DALI_IMPORT_API void SetAlphaFunction(AlphaFunction func); + virtual Extension* GetExtension() + { + return NULL; + } + +protected: /** - * @brief Retrieve the alpha function used when applying constraints - * - * @return The alpha function. + * @brief Create a new ItemLayout; Only derived versions are instantiatable. + * @SINCE_1_0.0 */ - DALI_IMPORT_API AlphaFunction GetAlphaFunction() const; + ItemLayout(); -protected: +private: /** - * @brief Create a new ItemLayout; Only derived versions are instantiatable. + * @brief Don't allow copy constructor + * @SINCE_1_0.0 */ - DALI_IMPORT_API ItemLayout(); + ItemLayout( const ItemLayout& handle ); + + /** + * @brief Don't allow copy operator + * @SINCE_1_0.0 + */ + ItemLayout& operator=( const ItemLayout& handle ); protected: - ControlOrientation::Type mOrientation; ///< the orientation of the layout. - AlphaFunction mAlphaFunction; ///< Alpha function to be applied when removing/adding constraints - Handle mWeightObject; ///< Weight object gets created to apply the constraints over a certain time + struct Impl; + Impl* mImpl; }; +/** + * @} + */ } // namespace Toolkit } // namespace Dali -#endif // __DALI_TOOLKIT_ITEM_LAYOUT_H__ +#endif // DALI_TOOLKIT_ITEM_LAYOUT_H