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 Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
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.
22 Note:This layout is customized for music player application, so there are some limitations:
23 1.This layout can only be used with 1280x720 mode (not 720x1280);
24 2.Need promram in application layer to support it(EX.SetNum).
28 #include <boost/function.hpp>
31 #include <dali/dali.h>
32 #include <dali-toolkit/public-api/controls/scrollable/item-view/item-layout.h>
34 namespace Dali DALI_IMPORT_API
42 typedef IntrusivePtr<AlbumLayout> AlbumLayoutPtr;
45 * An ItemView layout which arranges items in a album.
47 class AlbumLayout : public ItemLayout
51 typedef boost::function<Vector3 (const Vector3& layoutSize)> ItemSizeFunction;
52 typedef boost::function<float (const Vector3& layoutSize)> AlbumRadiusFunction;
55 * Create a new album layout
57 static AlbumLayoutPtr New();
62 virtual ~AlbumLayout();
65 * Set the function used to calculate the item-size, for a given layout-size.
66 * @param[in] function The item-size function.
68 void SetItemSizeFunction(ItemSizeFunction function);
71 * Get the function used to calculate the item-size
72 * @return The item-size function.
74 ItemSizeFunction GetItemSizeFunction() const;
77 * Set the function used to calculate the album radius, for a given layout-size.
78 * @param[in] function The spiral-radius function.
80 void SetAlbumRadiusFunction(AlbumRadiusFunction function);
83 * Get the function used to calculate the album radius.
84 * @return The album-radius function.
86 AlbumRadiusFunction GetAlbumRadiusFunction() const;
89 * Set the factor used to customise the scroll speed while dragging and swiping the layout.
90 * @param[in] scrollSpeed The scroll speed factor.
92 void SetScrollSpeedFactor(float scrollSpeed);
95 * Set the maximum swipe speed in pixels per second.
96 * @param[in] speed The maximum swipe speed.
98 void SetMaximumSwipeSpeed(float speed);
101 * Set the duration of the flick animation in second. This is the time taken to animate each
102 * item to its next layout position (e.g. from 1.0 to 2.0) when a flick animation is triggered
103 * by a swipe gesture.
104 * @pre durationSeconds must be greater than zero.
105 * @param[in] durationSeconds The duration of flick animation in seconds.
107 void SetItemFlickAnimationDuration(float durationSeconds);
110 * @copydoc ItemLayout::GetScrollSpeedFactor()
112 virtual float GetScrollSpeedFactor() const;
115 * @copydoc ItemLayout::GetMaximumSwipeSpeed()
117 virtual float GetMaximumSwipeSpeed() const;
120 * @copydoc ItemLayout::GetItemFlickAnimationDuration()
122 virtual float GetItemFlickAnimationDuration() const;
125 * Set the num of items.
126 * @param[in] num The number of items.
128 void SetNumOfItems(int num);
131 * Get the num of items.
133 int GetNumOfItems() const;
136 * Set the items num of stack.
137 * @param[in] num The number of items on the stack.
139 void SetStackNum(int num);
142 * Get the items num of stack.
144 int GetStackNum() const;
147 * Set the position of each item.
148 * @param[in] positionList The vector which contains the position for each item.
150 void SetPosition(std::vector<Vector3> positionList);
153 * Get the position of each item.
155 std::vector<Vector3> GetPosition() const;
158 * Set the rotation of each item.
159 * @param[in] rotation around X, the vector which contains the rotation for each item.
161 void SetRotationX(float rotation);
164 * Set the rotation of each item.
166 float GetRotationX() const;
169 * Set the rotation of each item.
170 * @param[in] rotationList around Z, the vector which contains the rotation for each item.
172 void SetRotationZ(std::vector<float> rotationList);
175 * Get the rotation of each item.
177 std::vector<float> GetRotationZ() const;
180 * Set the scale of each item.
181 * @param[in] scaleList The vector which contains the scale for each item.
183 void SetScale(std::vector<float> scaleList);
186 * Get the scale of each item.
188 std::vector<float> GetScale() const;
191 * Set the color of each item.
192 * @param[in] colorList The vector which contains the color for each item.
194 void SetColor(std::vector<Vector2> colorList);
197 * Get the color of each item.
199 std::vector<Vector2> GetColor() const;
202 * Set the position of center(selected) item.
203 * @param[in] pos The positon to set.
205 void SetCenterPosition(Vector3 pos);
209 * Get the position of center(selected) item.
211 Vector3 GetCenterPosition() const;
214 * Set the scale of center(selected) item.
215 * @param[in] scale The scale to set.
217 void SetCenterScale(float scale);
220 * Get the scale of center(selected) item.
222 float GetCenterScale() const;
225 * Set the color of center(selected) item.
226 * @param[in] color The color to set.
228 void SetCenterColor(Vector2 color);
231 * Get the color of center(selected) item.
233 Vector2 GetCenterColor() const;
236 * Set the postion of stack item(right stack and left stack).
237 * @param[in] rightPos The position of right stack.
238 * @param[in] leftPos The position of left stack,.
240 void SetStackPosition(Vector3 rightPos, Vector3 leftPos);
243 * Get the postion of right stack .
245 Vector3 GetRightStackPosition() const;
248 * Get the postion of left stack .
250 Vector3 GetLeftStackPosition() const;
253 * Set the scale of stack item(right stack and left stack).
254 * @param[in] rightScale The scale of right stack.
255 * @param[in] leftScale The scale of left stack,.
257 void SetStackScale(float rightScale, float leftScale);
260 * Get the scale of right stack.
262 float GetRightStackScale() const;
265 * Get the scale of left stack.
267 float GetLeftStackScale() const;
270 * Set the color of stack item(right stack and left stack).
271 * @param[in] rightColor The color of right stack.
272 * @param[in] leftColor The color of left stack.
274 void SetStackColor(Vector2 rightColor, Vector2 leftColor);
277 * Get the color of right stack.
279 Vector2 GetRightStackColor() const;
282 * Get the color of left stack.
284 Vector2 GetLeftStackColor() const;
289 * @copydoc ItemLayout::GetMinimumLayoutPosition()
291 virtual float GetMinimumLayoutPosition(unsigned int numberOfItems, Vector3 layoutSize) const;
294 * @copydoc ItemLayout::GetClosestAnchorPosition()
296 virtual float GetClosestAnchorPosition(float layoutPosition) const;
299 * @copydoc ItemLayout::GetItemScrollToPosition()
301 virtual float GetItemScrollToPosition(unsigned int itemId) const;
304 * @copydoc ItemLayout::GetItemsWithinArea()
306 virtual ItemRange GetItemsWithinArea(float firstItemPosition, Vector3 layoutSize) const;
309 * @copydoc ItemLayout::GetReserveItemCount()
311 virtual unsigned int GetReserveItemCount(Vector3 layoutSize) const;
314 * @copydoc ItemLayout::GetItemSize()
316 virtual bool GetItemSize(unsigned int itemId, Vector3 layoutSize, Vector3& itemSize) const;
319 * @copydoc ItemLayout::GetResizeAnimation()
321 virtual void GetResizeAnimation(Animation& animation, Actor actor, Vector3 size, float durationSeconds) const;
324 * @copydoc ItemLayout::GetPositionConstraint()
326 virtual bool GetPositionConstraint(unsigned int itemId, ItemLayout::Vector3Function& constraint) const;
329 * @copydoc ItemLayout::GetRotationConstraint()
331 virtual bool GetRotationConstraint(unsigned int itemId, ItemLayout::QuaternionFunction& constraint) const;
334 * @copydoc ItemLayout::GetScaleConstraint()
336 virtual bool GetScaleConstraint(unsigned int itemId, ItemLayout::Vector3Function& constraint) const;
339 * @copydoc ItemLayout::GetColorConstraint()
341 virtual bool GetColorConstraint(unsigned int itemId, ItemLayout::Vector4Function& constraint) const;
344 * @copydoc ItemLayout::GetVisibilityConstraint()
346 virtual bool GetVisibilityConstraint(unsigned int itemId, ItemLayout::BoolFunction& constraint) const;
349 * @copydoc ItemLayout::GetScrollDirection()
351 virtual Degree GetScrollDirection() const;
356 * Protected constructor; see also AlbumLayout::New()
366 } // namespace Toolkit
370 #endif // __DALI_TOOLKIT_ALBUM_LAYOUT_H__