1 #ifndef __DALI_TOOLKIT_CLUSTER_H__
2 #define __DALI_TOOLKIT_CLUSTER_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 #include <dali-toolkit/public-api/controls/control.h>
30 namespace Internal DALI_INTERNAL
38 * @brief Cluster is a container of grouped actors positioned in different cluster styles.
41 * | %Action Name | Method |
42 * |---------------------------|---------------------------|
43 * | expand | DoExpandAction() |
44 * | collapse | DoCollapseAction() |
45 * | transform | DoTransformAction() |
47 class DALI_IMPORT_API Cluster : public Control
53 static const std::string CLUSTER_ACTOR_DEPTH; ///< Property, name "cluster-actor-depth", type FLOAT
58 * Create a Cluster handle; this can be initialised with Cluster::New()
59 * Calling member functions with an uninitialised handle is not allowed.
66 Cluster( const Cluster& cluster );
69 * Assignment Operator.
71 Cluster& operator=( const Cluster& cluster );
76 * This is non-virtual since derived Handle types must not contain data or virtual methods.
81 * Create the Cluster control with the given style.
82 * @param[in] style The style of the cluster
83 * @return A handle to the Cluster control.
85 static Cluster New( ClusterStyle& style );
88 * Downcast an Object handle to Cluster. If handle points to a Cluster the
89 * downcast produces valid handle. If not the returned handle is left uninitialized.
90 * @param[in] handle Handle to an object
91 * @return handle to a Cluster or an uninitialized handle
93 static Cluster DownCast( BaseHandle handle );
96 * Adds a child to the Cluster
97 * Will automatically choose a position for the child.
98 * @pre The child actor has been initialized.
99 * @param[in] child The child to add
101 void AddChild( Actor child );
104 * Adds a child to the Cluster
105 * User specifies the position for the child.
106 * @pre The child actor has been initialized.
107 * @param[in] child The child to add
108 * @param[in] positionIndex The position for this child
110 void AddChild( Actor child, unsigned int positionIndex );
113 * Adds a child to the Cluster to be inserted at a specified
115 * Will automatically choose a position for the child.
116 * @pre The child actor has been initialized.
117 * @param[in] child The child to add
118 * @param[in] index The depth position for this child
120 void AddChildAt( Actor child, unsigned int index );
123 * Adds a child to the Cluster to be inserted at a specified
125 * User specifies the position for the child.
126 * @pre The child actor has been initialized.
127 * @param[in] child The child to add
128 * @param[in] positionIndex The position for this child
129 * @param[in] index The depth position for this child
131 void AddChildAt( Actor child, unsigned int positionIndex, unsigned int index );
134 * Returns a child from the given layout position
135 * Note! if there is no child in this layout position this method returns an uninitialized
137 * @param[in] index The child index in the cluster
138 * @return The child that was in the layout position or an uninitialized handle
140 Actor GetChildAt( unsigned int index );
143 * Removes a child from the given layout position
144 * Note! if there is no child in this layout position this method does nothing
145 * @param[in] index The index of the child to remove
146 * @return The child that was removed or an uninitialized handle
148 Actor RemoveChildAt( unsigned int index );
152 * A child will move away from the cluster.
153 * @param[in] index The child position index to expand
155 void ExpandChild( unsigned int index );
158 * Expands all children
159 * All children that have been collapsed will
160 * move away from the cluster
162 void ExpandAllChildren();
166 * A child that has been expanded will move
167 * back to its original positions.
168 * @param[in] index The child index to collapse
169 * @param[in] front Whether to move child to the front or
170 * back of cluster (depth).
172 void CollapseChild( unsigned int index, bool front = false );
175 * Collapses all children.
176 * All children that have been expanded will move
177 * back to their original positions.
178 * @param[in] front Whether to move child to the front or
179 * back of cluster (depth).
181 void CollapseAllChildren( bool front = false );
184 * Transforms Actor from default transform to new transform
185 * @param[in] index The child index to move
186 * @param[in] position The position to move to
187 * @param[in] scale The scale to change to
188 * @param[in] rotation The rotation to change to
189 * @param[in] alpha The alpha function to use to tween to this transform
190 * @param[in] period The duration for this transformation to take
192 void TransformChild( unsigned int index, const Vector3& position, const Vector3& scale, const Quaternion& rotation, AlphaFunction alpha, const TimePeriod& period );
195 * Restores Actor to the default transform (based on current style)
196 * @param[in] index The child index to move back
197 * @param[in] alpha The alpha function to use to tween to this transform
198 * @param[in] period The duration for this transformation to take
199 * @param[in] front Whether to move child to the front or
200 * back of cluster (depth).
202 void RestoreChild( unsigned int index, AlphaFunction alpha, const TimePeriod& period, bool front = false );
205 * Sets the background image.
206 * @param[in] image The background image.
208 void SetBackgroundImage( Actor image );
213 * @param[in] text Title text.
215 void SetTitle( Actor text );
218 * Sets the style of the cluster
219 * @param[in] style The style of the cluster
221 void SetStyle(ClusterStyle style);
224 * Gets the style of the cluster
225 * @return style of the cluster
227 ClusterStyle GetStyle() const;
230 * Gets the number of children that have been expanded in this cluster.
231 * @return the number of children expanded.
233 unsigned int GetExpandedCount() const;
236 * Gets the number of children that have been added to this cluster.
237 * @return the total number of children.
239 unsigned int GetTotalCount() const;
241 public: // Not intended for application developers
244 * Creates a handle using the Toolkit::Internal implementation.
245 * @param[in] implementation The Control implementation.
247 DALI_INTERNAL Cluster( Internal::Cluster& implementation );
250 * Allows the creation of this Control from an Internal::CustomActor pointer.
251 * @param[in] internal A pointer to the internal CustomActor.
253 explicit DALI_INTERNAL Cluster( Dali::Internal::CustomActor* internal );
256 } // namespace Toolkit
260 #endif // __DALI_TOOLKIT_CLUSTER_H__