1 #ifndef __DALI_TOOLKIT_ALBUM_LAYOUT_H__
2 #define __DALI_TOOLKIT_ALBUM_LAYOUT_H__
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 // Licensed under the Flora License, Version 1.0 (the License);
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://floralicense.org/license/
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an AS IS BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
21 Note:This layout is customized for music player application, so there are some limitations:
22 1.This layout can only be used with 1280x720 mode (not 720x1280);
23 2.Need promram in application layer to support it(EX.SetNum).
27 #include <boost/function.hpp>
30 #include <dali/dali.h>
31 #include <dali-toolkit/public-api/controls/scrollable/item-view/item-layout.h>
33 namespace Dali DALI_IMPORT_API
41 typedef IntrusivePtr<AlbumLayout> AlbumLayoutPtr;
44 * An ItemView layout which arranges items in a album.
46 class AlbumLayout : public ItemLayout
50 typedef boost::function<Vector3 (const Vector3& layoutSize)> ItemSizeFunction;
51 typedef boost::function<float (const Vector3& layoutSize)> AlbumRadiusFunction;
54 * Create a new album layout
56 static AlbumLayoutPtr New();
61 virtual ~AlbumLayout();
64 * Set the function used to calculate the item-size, for a given layout-size.
65 * @param[in] function The item-size function.
67 void SetItemSizeFunction(ItemSizeFunction function);
70 * Get the function used to calculate the item-size
71 * @return The item-size function.
73 ItemSizeFunction GetItemSizeFunction() const;
76 * Set the function used to calculate the album radius, for a given layout-size.
77 * @param[in] function The spiral-radius function.
79 void SetAlbumRadiusFunction(AlbumRadiusFunction function);
82 * Get the function used to calculate the album radius.
83 * @return The album-radius function.
85 AlbumRadiusFunction GetAlbumRadiusFunction() const;
88 * Set the factor used to customise the scroll speed while dragging and swiping the layout.
89 * @param[in] scrollSpeed The scroll speed factor.
91 void SetScrollSpeedFactor(float scrollSpeed);
94 * Set the maximum swipe speed in pixels per second.
95 * @param[in] speed The maximum swipe speed.
97 void SetMaximumSwipeSpeed(float speed);
100 * Set the duration of the flick animation in second. This is the time taken to animate each
101 * item to its next layout position (e.g. from 1.0 to 2.0) when a flick animation is triggered
102 * by a swipe gesture.
103 * @pre durationSeconds must be greater than zero.
104 * @param[in] durationSeconds The duration of flick animation in seconds.
106 void SetItemFlickAnimationDuration(float durationSeconds);
109 * @copydoc ItemLayout::GetScrollSpeedFactor()
111 virtual float GetScrollSpeedFactor() const;
114 * @copydoc ItemLayout::GetMaximumSwipeSpeed()
116 virtual float GetMaximumSwipeSpeed() const;
119 * @copydoc ItemLayout::GetItemFlickAnimationDuration()
121 virtual float GetItemFlickAnimationDuration() const;
124 * Set the num of items.
125 * @param[in] num The number of items.
127 void SetNumOfItems(int num);
130 * Get the num of items.
132 int GetNumOfItems() const;
135 * Set the items num of stack.
136 * @param[in] num The number of items on the stack.
138 void SetStackNum(int num);
141 * Get the items num of stack.
143 int GetStackNum() const;
146 * Set the position of each item.
147 * @param[in] positionList The vector which contains the position for each item.
149 void SetPosition(std::vector<Vector3> positionList);
152 * Get the position of each item.
154 std::vector<Vector3> GetPosition() const;
157 * Set the rotation of each item.
158 * @param[in] rotation around X, the vector which contains the rotation for each item.
160 void SetRotationX(float rotation);
163 * Set the rotation of each item.
165 float GetRotationX() const;
168 * Set the rotation of each item.
169 * @param[in] rotationList around Z, the vector which contains the rotation for each item.
171 void SetRotationZ(std::vector<float> rotationList);
174 * Get the rotation of each item.
176 std::vector<float> GetRotationZ() const;
179 * Set the scale of each item.
180 * @param[in] scaleList The vector which contains the scale for each item.
182 void SetScale(std::vector<float> scaleList);
185 * Get the scale of each item.
187 std::vector<float> GetScale() const;
190 * Set the color of each item.
191 * @param[in] colorList The vector which contains the color for each item.
193 void SetColor(std::vector<Vector2> colorList);
196 * Get the color of each item.
198 std::vector<Vector2> GetColor() const;
201 * Set the position of center(selected) item.
202 * @param[in] pos The positon to set.
204 void SetCenterPosition(Vector3 pos);
208 * Get the position of center(selected) item.
210 Vector3 GetCenterPosition() const;
213 * Set the scale of center(selected) item.
214 * @param[in] scale The scale to set.
216 void SetCenterScale(float scale);
219 * Get the scale of center(selected) item.
221 float GetCenterScale() const;
224 * Set the color of center(selected) item.
225 * @param[in] color The color to set.
227 void SetCenterColor(Vector2 color);
230 * Get the color of center(selected) item.
232 Vector2 GetCenterColor() const;
235 * Set the postion of stack item(right stack and left stack).
236 * @param[in] rightPos The position of right stack.
237 * @param[in] leftPos The position of left stack,.
239 void SetStackPosition(Vector3 rightPos, Vector3 leftPos);
242 * Get the postion of right stack .
244 Vector3 GetRightStackPosition() const;
247 * Get the postion of left stack .
249 Vector3 GetLeftStackPosition() const;
252 * Set the scale of stack item(right stack and left stack).
253 * @param[in] rightScale The scale of right stack.
254 * @param[in] leftScale The scale of left stack,.
256 void SetStackScale(float rightScale, float leftScale);
259 * Get the scale of right stack.
261 float GetRightStackScale() const;
264 * Get the scale of left stack.
266 float GetLeftStackScale() const;
269 * Set the color of stack item(right stack and left stack).
270 * @param[in] rightColor The color of right stack.
271 * @param[in] leftColor The color of left stack.
273 void SetStackColor(Vector2 rightColor, Vector2 leftColor);
276 * Get the color of right stack.
278 Vector2 GetRightStackColor() const;
281 * Get the color of left stack.
283 Vector2 GetLeftStackColor() const;
288 * @copydoc ItemLayout::GetMinimumLayoutPosition()
290 virtual float GetMinimumLayoutPosition(unsigned int numberOfItems, Vector3 layoutSize) const;
293 * @copydoc ItemLayout::GetClosestAnchorPosition()
295 virtual float GetClosestAnchorPosition(float layoutPosition) const;
298 * @copydoc ItemLayout::GetItemScrollToPosition()
300 virtual float GetItemScrollToPosition(unsigned int itemId) const;
303 * @copydoc ItemLayout::GetItemsWithinArea()
305 virtual ItemRange GetItemsWithinArea(float firstItemPosition, Vector3 layoutSize) const;
308 * @copydoc ItemLayout::GetReserveItemCount()
310 virtual unsigned int GetReserveItemCount(Vector3 layoutSize) const;
313 * @copydoc ItemLayout::GetItemSize()
315 virtual bool GetItemSize(unsigned int itemId, Vector3 layoutSize, Vector3& itemSize) const;
318 * @copydoc ItemLayout::GetResizeAnimation()
320 virtual void GetResizeAnimation(Animation& animation, Actor actor, Vector3 size, float durationSeconds) const;
323 * @copydoc ItemLayout::GetPositionConstraint()
325 virtual bool GetPositionConstraint(unsigned int itemId, ItemLayout::Vector3Function& constraint) const;
328 * @copydoc ItemLayout::GetRotationConstraint()
330 virtual bool GetRotationConstraint(unsigned int itemId, ItemLayout::QuaternionFunction& constraint) const;
333 * @copydoc ItemLayout::GetScaleConstraint()
335 virtual bool GetScaleConstraint(unsigned int itemId, ItemLayout::Vector3Function& constraint) const;
338 * @copydoc ItemLayout::GetColorConstraint()
340 virtual bool GetColorConstraint(unsigned int itemId, ItemLayout::Vector4Function& constraint) const;
343 * @copydoc ItemLayout::GetVisibilityConstraint()
345 virtual bool GetVisibilityConstraint(unsigned int itemId, ItemLayout::BoolFunction& constraint) const;
348 * @copydoc ItemLayout::GetScrollDirection()
350 virtual Degree GetScrollDirection() const;
355 * Protected constructor; see also AlbumLayout::New()
365 } // namespace Toolkit
369 #endif // __DALI_TOOLKIT_ALBUM_LAYOUT_H__