1 #ifndef __DALI_ALIGNMENT_H__
2 #define __DALI_ALIGNMENT_H__
5 * Copyright (c) 2015 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
35 * @addtogroup dali-toolkit-controls-alignment
40 * @brief Alignment is a container which provides an easy way to align other actors inside its boundary.
42 * Additionaly it provides a scaling property to resize the contained actors @see Scaling.
43 * @note The use of scaling property will override all constraints applied to actors.
45 * 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
46 * different than ScaleNone, constraints as well.
48 class DALI_IMPORT_API Alignment : public Control
52 * @brief Different types of alignment.
65 * @brief Scaling determines how actors are scaled, to match the alignment's boundary.
69 ScaleNone, ///< The original size is kept.
70 ScaleToFill, ///< Scale added actors to fill alignment's boundary. Aspect ratio is not maintained.
71 ScaleToFitKeepAspect, ///< Scale added actors to fit within the alignment's boundary. Aspect ratio is maintained.
72 ScaleToFillKeepAspect, ///< Scale added actors to fill the alignment's boundary. Aspect ratio is maintained, and the actor may exceed the alignment's boundary.
73 ShrinkToFit, ///< If added actors are larger than the alignment's boundary it will be shrunk down to fit. Aspect ratio is not maintained
74 ShrinkToFitKeepAspect, ///< If added actors are larger than the alignment's boundary it will be shrunk down to fit. Aspect ratio is maintained
78 * @brief Structure describing the padding values.
96 * @param[in] l Left padding
97 * @param[in] r Right padding
98 * @param[in] t Top padding
99 * @param[in] b Bottom padding
101 Padding( float l, float r, float t, float b )
109 float left; ///< The left padding
110 float right; ///< The right padding
111 float top; ///< The top padding
112 float bottom; ///< The bottom padding
116 * @brief Create an Alignment handle; this can be initialised with Alignment::New().
118 * Calling member functions with an uninitialised handle is not allowed.
123 * @brief Creates an alignment control.
125 * @param [in] horizontal Specifies how to align actors horizontally. Could be HorizontalLeft, HorizontalCenter or HorizontalRight. By default HorizontalCenter.
126 * @param [in] vertical Specifies how to align actors vertically. Could be VerticalTop, VerticalCenter or VerticalBottom. By default VerticalCenter.
127 * @return A handle to the Alignment control.
129 static Alignment New( Type horizontal = HorizontalCenter, Type vertical = VerticalCenter );
132 * @brief Copy constructor. Creates another handle that points to the same real object.
134 * @param[in] alignment Object to copy.
136 Alignment(const Alignment& alignment);
141 * This is non-virtual since derived Handle types must not contain data or virtual methods.
146 * @brief Downcast an Object handle to Alignment.
148 * If handle points to a Alignment the downcast produces valid
149 * handle. If not the returned handle is left uninitialized.
151 * @param[in] handle Handle to an object
152 * @return handle to a Alignment or an uninitialized handle
154 static Alignment DownCast( BaseHandle handle );
157 * @brief Sets the new alignment. By default ( HorizontalCenter | VerticalCenter ).
159 * @note there should only be one horizontal and one vertical policy
160 * @param [in] type The new alignment option.
162 void SetAlignmentType( Type type );
165 * @brief Get the current alignment combined into a single value.
167 * The values can be tested by using the & operator and the desired
170 * if (GetAlignmentType() & HorizontalCentre)
176 * @return the alignment value.
178 Type GetAlignmentType() const;
181 * @brief Sets how added actors scale to fit the alignment's boundary.
184 * @param[in] scaling The scaling property.
186 void SetScaling( Scaling scaling );
189 * @brief Retrieves the scaling property.
192 * @return The scaling.
194 Scaling GetScaling() const;
197 * @brief Set a padding value.
199 * @param [in] padding The left, right, top, bottom padding values.
201 void SetPadding( const Padding& padding );
204 * @brief Get the padding values.
206 * @return The left, right, top, bottom padding values.
208 const Padding& GetPadding() const;
211 * @brief Assignment operator.
213 * Changes this handle to point to another real object.
214 * @param[in] alignment Object to copy
215 * @return A reference to this
217 Alignment& operator=(const Alignment& alignment);
219 public: // Not intended for application developers
222 * @brief Creates a handle using the Toolkit::Internal implementation.
224 * @param[in] implementation The Control implementation.
226 DALI_INTERNAL Alignment( Internal::Alignment& implementation );
229 * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
231 * @param[in] internal A pointer to the internal CustomActor.
233 explicit DALI_INTERNAL Alignment( Dali::Internal::CustomActor* internal );
239 } // namespace Toolkit
243 #endif // __DALI_TOOLKIT_LAYOUT_H__