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);
61 * @copydoc Toolkit::ClusterStyle::ApplyStyleToTitle
63 virtual void ApplyStyleToTitle(Actor title, AlphaFunction alpha, const TimePeriod& durationSeconds);
66 * Set the size of cluster
68 void SetClusterSize( const Vector3& clusterSize );
73 * Set the maximum number of children this Style can handle.
74 * @param[in] The maximum number of children.
76 void SetMaximumNumberOfChildren(unsigned int children);
79 * Set the title properties
80 * @param[in] relativePosition Relative position of the title
81 * @param[in] offsetPosition Offset position of the title
82 * @param[in] size The size of the title
84 void SetTitleProperties(const Vector3& relativePosition,
85 const Vector3& offsetPosition,
89 * Set the background properties
90 * @param[in] relativePosition Relative position of the background
91 * @param[in] offsetPosition Offset position of the background
92 * @param[in] size The size of the title
94 void SetBackgroundProperties(const Vector3& relativePosition,
95 const Vector3& offsetPosition,
99 * Get the size of cluster.
100 * @return the cluster size
102 Vector3 GetClusterSize() const;
105 * Apply the given position & size to the actor
106 * @param[in] position The target position
107 * @param[in] size The target size
108 * @param[in] size The size to resize to
109 * @param[in] alpha The alpha function to use.
110 * @param[in] durationSeconds The time period to apply this style.
112 void Apply( Actor actor,
113 const Vector3& position,
116 const TimePeriod& durationSeconds);
118 * Apply the given position & size to the actor
119 * @param[in] actor The actor to apply the changes
120 * @param[in] position The target position
121 * @param[in] size The target size
122 * @param[in] rotation The target Quaternion value
123 * @param[in] scale The target scale
124 * @param[in] alpha The alpha function to use.
125 * @param[in] durationSeconds The time period to apply this style.
127 void Apply( Actor actor,
128 const Vector3& position,
130 const Quaternion& rotation,
131 const Vector3& scale,
133 const TimePeriod& durationSeconds);
138 * Protected constructor see ClusterStyle::New().
143 * A reference counted object may only be deleted by calling Unreference()
145 virtual ~ClusterStyle();
149 unsigned int mMaxChildren; ///< Maximum number of children that this style supports
150 Vector3 mTitlePositionRelative; ///< Title's position relative to size of cluster
151 Vector3 mTitlePositionOffset; ///< Title's position offset
152 Vector3 mTitleSize; ///< Title's size relative to size of cluster
153 Vector3 mBackgroundPositionRelative; ///< Background's position relative to size of cluster
154 Vector3 mBackgroundPositionOffset; ///< Background's position offset
155 Vector3 mBackgroundSize; ///< Background's size relative to size of cluster
156 Vector3 mClusterSize; ///< The size of cluster
160 * ClusterStyleStandard internal implementation
162 class ClusterStyleStandard : public ClusterStyle
166 typedef Toolkit::ClusterStyleStandard::StyleType StyleType;
171 * Create a new cluster style.
172 * @param[in] style The style type to create.
173 * @return A smart-pointer to the newly allocated ClusterStyle.
175 static ClusterStylePtr New(StyleType style);
180 * @copydoc Toolkit::ClusterStyle::ApplyStyle
182 void ApplyStyle(Actor child, unsigned int index, AlphaFunction alpha, const TimePeriod& durationSeconds);
187 * Set the relative sizes of the children
188 * @param[in] size The list of sizes for the children
190 void SetSizes(const float *sizes);
193 * Set the relative positions of the children
194 * @param[in] positions The list of positions for the children
196 void SetPositions(const Vector3 *positions);
201 * Protected constructor see ClusterStyleRandom::New().
203 ClusterStyleStandard(StyleType style);
207 const float *mSizes; ///< List of sizes
208 const Vector3 *mPositions; ///< List of positions
213 * ClusterStyleRandom internal implementation
215 class ClusterStyleRandom : public ClusterStyle
220 * Create a new cluster style.
221 * @return A smart-pointer to the newly allocated ClusterStyle.
223 static ClusterStylePtr New();
228 * @copydoc Toolkit::ClusterStyle::ApplyStyle
230 void ApplyStyle(Actor child, unsigned int index, AlphaFunction alpha, const TimePeriod& durationSeconds);
235 * Protected constructor see ClusterStyleRandom::New().
237 ClusterStyleRandom();
243 } // namespace Internal
245 // Helpers for public-api forwarding methods
247 inline Internal::ClusterStyle& GetImpl(Toolkit::ClusterStyle& pub)
249 DALI_ASSERT_ALWAYS(pub);
251 Dali::RefObject& handle = pub.GetBaseObject();
253 return static_cast<Internal::ClusterStyle&>(handle);
256 inline const Internal::ClusterStyle& GetImpl(const Toolkit::ClusterStyle& pub)
258 DALI_ASSERT_ALWAYS(pub);
260 const Dali::RefObject& handle = pub.GetBaseObject();
262 return static_cast<const Internal::ClusterStyle&>(handle);
265 } // namespace Toolkit