2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <dali/public-api/object/ref-object.h>
20 #include <dali/public-api/common/dali-common.h>
21 #include <dali/public-api/math/vector3.h>
22 #include <dali/public-api/object/base-object.h>
23 #include <dali-toolkit/public-api/controls/cluster/cluster-style.h>
36 typedef IntrusivePtr<ClusterStyle> ClusterStylePtr;
39 * ClusterStyle internal implementation
41 class ClusterStyle : public Dali::BaseObject
46 * @copydoc Toolkit::ClusterStyle::GetMaximumNumberOfChildren
48 unsigned int GetMaximumNumberOfChildren() const;
51 * @copydoc Toolkit::ClusterStyle::ApplyStyle
53 virtual void ApplyStyle(Actor child, unsigned int index, AlphaFunction alpha, const TimePeriod& durationSeconds) = 0;
56 * @copydoc Toolkit::ClusterStyle::ApplyStyleToBackground
58 virtual void ApplyStyleToBackground(Actor background, AlphaFunction alpha, const TimePeriod& durationSeconds) = 0;
61 * @copydoc Toolkit::ClusterStyle::ApplyStyleToTitle
63 virtual void ApplyStyleToTitle(Actor title, AlphaFunction alpha, const TimePeriod& durationSeconds) = 0;
68 * Set the maximum number of children this Style can handle.
69 * @param[in] The maximum number of children.
71 void SetMaximumNumberOfChildren(unsigned int children);
74 * Set the title properties
75 * @param[in] relativePosition Relative position of the title
76 * @param[in] offsetPosition Offset position of the title
77 * @param[in] size The size of the title
79 void SetTitleProperties(const Vector3& relativePosition,
80 const Vector3& offsetPosition,
84 * Set the background properties
85 * @param[in] relativePosition Relative position of the background
86 * @param[in] offsetPosition Offset position of the background
87 * @param[in] size The size of the title
89 void SetBackgroundProperties(const Vector3& relativePosition,
90 const Vector3& offsetPosition,
96 * Protected constructor see ClusterStyle::New().
101 * A reference counted object may only be deleted by calling Unreference()
103 virtual ~ClusterStyle();
107 unsigned int mMaxChildren; ///< Maximum number of children that this style supports
108 Vector3 mTitlePositionRelative; ///< Title's position relative to size of cluster
109 Vector3 mTitlePositionOffset; ///< Title's position offset
110 Vector3 mTitleSize; ///< Title's size relative to size of cluster
111 Vector3 mBackgroundPositionRelative; ///< Background's position relative to size of cluster
112 Vector3 mBackgroundPositionOffset; ///< Background's position offset
113 Vector3 mBackgroundSize; ///< Background's size relative to size of cluster
118 * ClusterStyleStandard internal implementation
120 class ClusterStyleStandard : public ClusterStyle
124 typedef Toolkit::ClusterStyleStandard::StyleType StyleType;
129 * Create a new cluster style.
130 * @param[in] style The style type to create.
131 * @return A smart-pointer to the newly allocated ClusterStyle.
133 static ClusterStylePtr New(StyleType style);
138 * @copydoc Toolkit::ClusterStyle::ApplyStyle
140 void ApplyStyle(Actor child, unsigned int index, AlphaFunction alpha, const TimePeriod& durationSeconds);
143 * @copydoc Toolkit::ClusterStyle::ApplyStyleToBackground
145 void ApplyStyleToBackground(Actor background, AlphaFunction alpha, const TimePeriod& durationSeconds);
148 * @copydoc Toolkit::ClusterStyle::ApplyStyleToTitle
150 void ApplyStyleToTitle(Actor title, AlphaFunction alpha, const TimePeriod& durationSeconds);
155 * Set the relative sizes of the children
156 * @param[in] size The list of sizes for the children
158 void SetSizes(const float *sizes);
161 * Set the relative positions of the children
162 * @param[in] positions The list of positions for the children
164 void SetPositions(const Vector3 *positions);
169 * Protected constructor see ClusterStyleRandom::New().
171 ClusterStyleStandard(StyleType style);
175 const float *mSizes; ///< List of sizes
176 const Vector3 *mPositions; ///< List of positions
181 * ClusterStyleRandom internal implementation
183 class ClusterStyleRandom : public ClusterStyle
188 * Create a new cluster style.
189 * @return A smart-pointer to the newly allocated ClusterStyle.
191 static ClusterStylePtr New();
196 * @copydoc Toolkit::ClusterStyle::ApplyStyle
198 void ApplyStyle(Actor child, unsigned int index, AlphaFunction alpha, const TimePeriod& durationSeconds);
201 * @copydoc Toolkit::ClusterStyle::ApplyStyleToBackground
203 void ApplyStyleToBackground(Actor background, AlphaFunction alpha, const TimePeriod& durationSeconds);
206 * @copydoc Toolkit::ClusterStyle::ApplyStyleToTitle
208 void ApplyStyleToTitle(Actor title, AlphaFunction alpha, const TimePeriod& durationSeconds);
213 * Protected constructor see ClusterStyleRandom::New().
215 ClusterStyleRandom();
221 } // namespace Internal
223 // Helpers for public-api forwarding methods
225 inline Internal::ClusterStyle& GetImpl(Toolkit::ClusterStyle& pub)
227 DALI_ASSERT_ALWAYS(pub);
229 Dali::RefObject& handle = pub.GetBaseObject();
231 return static_cast<Internal::ClusterStyle&>(handle);
234 inline const Internal::ClusterStyle& GetImpl(const Toolkit::ClusterStyle& pub)
236 DALI_ASSERT_ALWAYS(pub);
238 const Dali::RefObject& handle = pub.GetBaseObject();
240 return static_cast<const Internal::ClusterStyle&>(handle);
243 } // namespace Toolkit