2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 #include <dali/public-api/object/ref-object.h>
19 #include <dali/public-api/common/dali-common.h>
20 #include <dali/public-api/math/vector3.h>
21 #include <dali/public-api/object/base-object.h>
22 #include <dali-toolkit/public-api/controls/cluster/cluster-style.h>
37 typedef IntrusivePtr<ClusterStyle> ClusterStylePtr;
40 * ClusterStyle internal implementation
42 class ClusterStyle : public Dali::BaseObject
47 * @copydoc Toolkit::ClusterStyle::GetMaximumNumberOfChildren
49 unsigned int GetMaximumNumberOfChildren() const;
52 * @copydoc Toolkit::ClusterStyle::ApplyStyle
54 virtual void ApplyStyle(Actor child, unsigned int index, AlphaFunction alpha, const TimePeriod& durationSeconds) = 0;
57 * @copydoc Toolkit::ClusterStyle::ApplyStyleToBackground
59 virtual void ApplyStyleToBackground(Actor background, AlphaFunction alpha, const TimePeriod& durationSeconds) = 0;
62 * @copydoc Toolkit::ClusterStyle::ApplyStyleToTitle
64 virtual void ApplyStyleToTitle(Actor title, AlphaFunction alpha, const TimePeriod& durationSeconds) = 0;
69 * Set the maximum number of children this Style can handle.
70 * @param[in] The maximum number of children.
72 void SetMaximumNumberOfChildren(unsigned int children);
75 * Set the title properties
76 * @param[in] relativePosition Relative position of the title
77 * @param[in] offsetPosition Offset position of the title
78 * @param[in] size The size of the title
80 void SetTitleProperties(const Vector3& relativePosition,
81 const Vector3& offsetPosition,
85 * Set the background properties
86 * @param[in] relativePosition Relative position of the background
87 * @param[in] offsetPosition Offset position of the background
88 * @param[in] size The size of the title
90 void SetBackgroundProperties(const Vector3& relativePosition,
91 const Vector3& offsetPosition,
97 * Protected constructor see ClusterStyle::New().
102 * A reference counted object may only be deleted by calling Unreference()
104 virtual ~ClusterStyle();
108 unsigned int mMaxChildren; ///< Maximum number of children that this style supports
109 Vector3 mTitlePositionRelative; ///< Title's position relative to size of cluster
110 Vector3 mTitlePositionOffset; ///< Title's position offset
111 Vector3 mTitleSize; ///< Title's size relative to size of cluster
112 Vector3 mBackgroundPositionRelative; ///< Background's position relative to size of cluster
113 Vector3 mBackgroundPositionOffset; ///< Background's position offset
114 Vector3 mBackgroundSize; ///< Background's size relative to size of cluster
119 * ClusterStyleStandard internal implementation
121 class ClusterStyleStandard : public ClusterStyle
125 typedef Toolkit::ClusterStyleStandard::StyleType StyleType;
130 * Create a new cluster style.
131 * @param[in] style The style type to create.
132 * @return A smart-pointer to the newly allocated ClusterStyle.
134 static ClusterStylePtr New(StyleType style);
139 * @copydoc Toolkit::ClusterStyle::ApplyStyle
141 void ApplyStyle(Actor child, unsigned int index, AlphaFunction alpha, const TimePeriod& durationSeconds);
144 * @copydoc Toolkit::ClusterStyle::ApplyStyleToBackground
146 void ApplyStyleToBackground(Actor background, AlphaFunction alpha, const TimePeriod& durationSeconds);
149 * @copydoc Toolkit::ClusterStyle::ApplyStyleToTitle
151 void ApplyStyleToTitle(Actor title, AlphaFunction alpha, const TimePeriod& durationSeconds);
156 * Set the relative sizes of the children
157 * @param[in] size The list of sizes for the children
159 void SetSizes(const float *sizes);
162 * Set the relative positions of the children
163 * @param[in] positions The list of positions for the children
165 void SetPositions(const Vector3 *positions);
170 * Protected constructor see ClusterStyleRandom::New().
172 ClusterStyleStandard(StyleType style);
176 const float *mSizes; ///< List of sizes
177 const Vector3 *mPositions; ///< List of positions
182 * ClusterStyleRandom internal implementation
184 class ClusterStyleRandom : public ClusterStyle
189 * Create a new cluster style.
190 * @return A smart-pointer to the newly allocated ClusterStyle.
192 static ClusterStylePtr New();
197 * @copydoc Toolkit::ClusterStyle::ApplyStyle
199 void ApplyStyle(Actor child, unsigned int index, AlphaFunction alpha, const TimePeriod& durationSeconds);
202 * @copydoc Toolkit::ClusterStyle::ApplyStyleToBackground
204 void ApplyStyleToBackground(Actor background, AlphaFunction alpha, const TimePeriod& durationSeconds);
207 * @copydoc Toolkit::ClusterStyle::ApplyStyleToTitle
209 void ApplyStyleToTitle(Actor title, AlphaFunction alpha, const TimePeriod& durationSeconds);
214 * Protected constructor see ClusterStyleRandom::New().
216 ClusterStyleRandom();
222 } // namespace Internal
224 // Helpers for public-api forwarding methods
226 inline Internal::ClusterStyle& GetImpl(Toolkit::ClusterStyle& pub)
228 DALI_ASSERT_ALWAYS(pub);
230 Dali::RefObject& handle = pub.GetBaseObject();
232 return static_cast<Internal::ClusterStyle&>(handle);
235 inline const Internal::ClusterStyle& GetImpl(const Toolkit::ClusterStyle& pub)
237 DALI_ASSERT_ALWAYS(pub);
239 const Dali::RefObject& handle = pub.GetBaseObject();
241 return static_cast<const Internal::ClusterStyle&>(handle);
244 } // namespace Toolkit