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>
25 #include <dali-toolkit/public-api/controls/cluster/cluster-style.h>
38 typedef IntrusivePtr<ClusterStyle> ClusterStylePtr;
41 * ClusterStyle internal implementation
43 class ClusterStyle : public Dali::BaseObject
48 * @copydoc Toolkit::ClusterStyle::GetMaximumNumberOfChildren
50 unsigned int GetMaximumNumberOfChildren() const;
53 * @copydoc Toolkit::ClusterStyle::ApplyStyle
55 virtual void ApplyStyle(Actor child, unsigned int index, AlphaFunction alpha, const TimePeriod& durationSeconds) = 0;
58 * @copydoc Toolkit::ClusterStyle::ApplyStyleToBackground
60 virtual void ApplyStyleToBackground(Actor background, AlphaFunction alpha, const TimePeriod& durationSeconds);
63 * @copydoc Toolkit::ClusterStyle::ApplyStyleToTitle
65 virtual void ApplyStyleToTitle(Actor title, AlphaFunction alpha, const TimePeriod& durationSeconds);
68 * Set the size of cluster
70 void SetClusterSize( const Vector3& clusterSize );
75 * Set the maximum number of children this Style can handle.
76 * @param[in] The maximum number of children.
78 void SetMaximumNumberOfChildren(unsigned int children);
81 * Set the title properties
82 * @param[in] relativePosition Relative position of the title
83 * @param[in] offsetPosition Offset position of the title
84 * @param[in] size The size of the title
86 void SetTitleProperties(const Vector3& relativePosition,
87 const Vector3& offsetPosition,
91 * Set the background properties
92 * @param[in] relativePosition Relative position of the background
93 * @param[in] offsetPosition Offset position of the background
94 * @param[in] size The size of the title
96 void SetBackgroundProperties(const Vector3& relativePosition,
97 const Vector3& offsetPosition,
101 * Get the size of cluster.
102 * @return the cluster size
104 Vector3 GetClusterSize() const;
107 * Apply the given position & size to the actor
108 * @param[in] position The target position
109 * @param[in] size The target size
110 * @param[in] size The size to resize to
111 * @param[in] alpha The alpha function to use.
112 * @param[in] durationSeconds The time period to apply this style.
114 void Apply( Actor actor,
115 const Vector3& position,
118 const TimePeriod& durationSeconds);
120 * Apply the given position & size to the actor
121 * @param[in] actor The actor to apply the changes
122 * @param[in] position The target position
123 * @param[in] size The target size
124 * @param[in] rotation The target Quaternion value
125 * @param[in] scale The target scale
126 * @param[in] alpha The alpha function to use.
127 * @param[in] durationSeconds The time period to apply this style.
129 void Apply( Actor actor,
130 const Vector3& position,
132 const Quaternion& rotation,
133 const Vector3& scale,
135 const TimePeriod& durationSeconds);
140 * Protected constructor see ClusterStyle::New().
145 * A reference counted object may only be deleted by calling Unreference()
147 virtual ~ClusterStyle();
151 unsigned int mMaxChildren; ///< Maximum number of children that this style supports
152 Vector3 mTitlePositionRelative; ///< Title's position relative to size of cluster
153 Vector3 mTitlePositionOffset; ///< Title's position offset
154 Vector3 mTitleSize; ///< Title's size relative to size of cluster
155 Vector3 mBackgroundPositionRelative; ///< Background's position relative to size of cluster
156 Vector3 mBackgroundPositionOffset; ///< Background's position offset
157 Vector3 mBackgroundSize; ///< Background's size relative to size of cluster
158 Vector3 mClusterSize; ///< The size of cluster
162 * ClusterStyleStandard internal implementation
164 class ClusterStyleStandard : public ClusterStyle
168 typedef Toolkit::ClusterStyleStandard::StyleType StyleType;
173 * Create a new cluster style.
174 * @param[in] style The style type to create.
175 * @return A smart-pointer to the newly allocated ClusterStyle.
177 static ClusterStylePtr New(StyleType style);
182 * @copydoc Toolkit::ClusterStyle::ApplyStyle
184 void ApplyStyle(Actor child, unsigned int index, AlphaFunction alpha, const TimePeriod& durationSeconds);
189 * Set the relative sizes of the children
190 * @param[in] size The list of sizes for the children
192 void SetSizes(const float *sizes);
195 * Set the relative positions of the children
196 * @param[in] positions The list of positions for the children
198 void SetPositions(const Vector3 *positions);
203 * Protected constructor see ClusterStyleRandom::New().
205 ClusterStyleStandard(StyleType style);
209 const float *mSizes; ///< List of sizes
210 const Vector3 *mPositions; ///< List of positions
215 * ClusterStyleRandom internal implementation
217 class ClusterStyleRandom : public ClusterStyle
222 * Create a new cluster style.
223 * @return A smart-pointer to the newly allocated ClusterStyle.
225 static ClusterStylePtr New();
230 * @copydoc Toolkit::ClusterStyle::ApplyStyle
232 void ApplyStyle(Actor child, unsigned int index, AlphaFunction alpha, const TimePeriod& durationSeconds);
237 * Protected constructor see ClusterStyleRandom::New().
239 ClusterStyleRandom();
245 } // namespace Internal
247 // Helpers for public-api forwarding methods
249 inline Internal::ClusterStyle& GetImpl(Toolkit::ClusterStyle& pub)
251 DALI_ASSERT_ALWAYS(pub);
253 Dali::RefObject& handle = pub.GetBaseObject();
255 return static_cast<Internal::ClusterStyle&>(handle);
258 inline const Internal::ClusterStyle& GetImpl(const Toolkit::ClusterStyle& pub)
260 DALI_ASSERT_ALWAYS(pub);
262 const Dali::RefObject& handle = pub.GetBaseObject();
264 return static_cast<const Internal::ClusterStyle&>(handle);
267 } // namespace Toolkit