1 #ifndef __DALI_ALIGNMENT_H__
2 #define __DALI_ALIGNMENT_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>
24 namespace Dali DALI_IMPORT_API
30 namespace Internal DALI_INTERNAL
36 * @brief Alignment is a container which provides an easy way to align other actors inside its boundary.
38 * Additionaly it provides a scaling property to resize the contained actors @see Scaling.
39 * @note The use of scaling property will override all constraints applied to actors.
41 * All actors added to an alignment are going to be set with the same anchor point and parent origin. And, if the scaling property is set to a value
42 * different than ScaleNone, constraints as well.
44 class Alignment : public Control
48 * @brief Different types of alignment.
61 * @brief Scaling determines how actors are scaled, to match the alignment's boundary.
65 ScaleNone, ///< The original size is kept.
66 ScaleToFill, ///< Scale added actors to fill alignment's boundary. Aspect ratio is not maintained.
67 ScaleToFitKeepAspect, ///< Scale added actors to fit within the alignment's boundary. Aspect ratio is maintained.
68 ScaleToFillKeepAspect, ///< Scale added actors to fill the alignment's boundary. Aspect ratio is maintained, and the actor may exceed the alignment's boundary.
69 ShrinkToFit, ///< If added actors are larger than the alignment's boundary it will be shrunk down to fit. Aspect ratio is not maintained
70 ShrinkToFitKeepAspect, ///< If added actors are larger than the alignment's boundary it will be shrunk down to fit. Aspect ratio is maintained
74 * @brief Structure describing the padding values.
92 * @param[in] l Left padding
93 * @param[in] r Right padding
94 * @param[in] t Top padding
95 * @param[in] b Bottom padding
97 Padding( float l, float r, float t, float b )
105 float left; ///< The left padding
106 float right; ///< The right padding
107 float top; ///< The top padding
108 float bottom; ///< The bottom padding
112 * @brief Create an Alignment handle; this can be initialised with Alignment::New().
114 * Calling member functions with an uninitialised handle is not allowed.
119 * @brief Creates an alignment control.
121 * @param [in] horizontal Specifies how to align actors horizontally. Could be HorizontalLeft, HorizontalCenter or HorizontalRight. By default HorizontalCenter.
122 * @param [in] vertical Specifies how to align actors vertically. Could be VerticalTop, VerticalCenter or VerticalBottom. By default VerticalCenter.
123 * @return A handle to the Alignment control.
125 static Alignment New( Type horizontal = HorizontalCenter, Type vertical = VerticalCenter );
128 * @brief Copy constructor. Creates another handle that points to the same real object.
130 * @param[in] alignment Object to copy.
132 Alignment(const Alignment& alignment);
137 * This is non-virtual since derived Handle types must not contain data or virtual methods.
142 * @brief Downcast an Object handle to Alignment.
144 * If handle points to a Alignment the downcast produces valid
145 * handle. If not the returned handle is left uninitialized.
147 * @param[in] handle Handle to an object
148 * @return handle to a Alignment or an uninitialized handle
150 static Alignment DownCast( BaseHandle handle );
153 * @brief Sets the new alignment. By default ( HorizontalCenter | VerticalCenter ).
154 * @param [in] type The new alignment option.
156 void SetAlignmentType( Type type );
159 * @brief Get the current alignment combined into a single value.
161 * The values can be tested by using the & operator and the desired
164 * if (GetAlignmentType() & HorizontalCentre)
170 * @return the alignment value.
172 Type GetAlignmentType() const;
175 * @brief Sets how added actors scale to fit the alignment's boundary.
178 * @param[in] scaling The scaling property.
180 void SetScaling( Scaling scaling );
183 * @brief Retrieves the scaling property.
186 * @return The scaling.
188 Scaling GetScaling() const;
191 * @brief Set a padding value.
193 * @param [in] padding The left, right, top, bottom padding values.
195 void SetPadding( const Padding& padding );
198 * @brief Get the padding values.
200 * @return The left, right, top, bottom padding values.
202 const Padding& GetPadding() const;
205 * @brief Assignment operator.
207 * Changes this handle to point to another real object.
208 * @param[in] alignment Object to copy
209 * @return A reference to this
211 Alignment& operator=(const Alignment& alignment);
213 public: // Not intended for application developers
216 * @brief Creates a handle using the Toolkit::Internal implementation.
218 * @param[in] implementation The Control implementation.
220 Alignment( Internal::Alignment& implementation );
223 * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
225 * @param[in] internal A pointer to the internal CustomActor.
227 Alignment( Dali::Internal::CustomActor* internal );
230 } // namespace Toolkit
234 #endif // __DALI_TOOLKIT_LAYOUT_H__