1 #ifndef DALI_ALIGNMENT_H
2 #define DALI_ALIGNMENT_H
5 * Copyright (c) 2019 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 * Additionally, it provides a scaling property to resize the contained actors @see Scaling.
44 * @note The use of scaling property will override all constraints applied to actors.
46 * 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
47 * different than ScaleNone, constraints as well.
49 class DALI_TOOLKIT_API Alignment : public Control
53 * @brief Enumeration for different types of alignment.
58 HorizontalLeft = 1, ///< Horizontal left alignment @SINCE_1_0.0
59 HorizontalCenter = 2, ///< Horizontal center alignment @SINCE_1_0.0
60 HorizontalRight = 4, ///< Horizontal right alignment @SINCE_1_0.0
61 VerticalTop = 8, ///< Vertical top alignment @SINCE_1_0.0
62 VerticalCenter = 16, ///< Vertical center alignment @SINCE_1_0.0
63 VerticalBottom = 32 ///< Vertical bottom alignment @SINCE_1_0.0
67 * @brief Scaling determines how actors are scaled to match the alignment's boundary.
72 ScaleNone, ///< The original size is kept. @SINCE_1_0.0
73 ScaleToFill, ///< Scale added actors to fill alignment's boundary. Aspect ratio is not maintained. @SINCE_1_0.0
74 ScaleToFitKeepAspect, ///< Scale added actors to fit within the alignment's boundary. Aspect ratio is maintained. @SINCE_1_0.0
75 ScaleToFillKeepAspect, ///< Scale added actors to fill the alignment's boundary. Aspect ratio is maintained, and the actor may exceed the alignment's boundary. @SINCE_1_0.0
76 ShrinkToFit, ///< If added actors are larger than the alignment's boundary it will be shrunk down to fit. Aspect ratio is not maintained @SINCE_1_0.0
77 ShrinkToFitKeepAspect, ///< If added actors are larger than the alignment's boundary it will be shrunk down to fit. Aspect ratio is maintained @SINCE_1_0.0
81 * @brief Structure describing the padding values.
102 * @param[in] l Left padding
103 * @param[in] r Right padding
104 * @param[in] t Top padding
105 * @param[in] b Bottom padding
107 Padding( float l, float r, float t, float b )
115 float left; ///< The left padding
116 float right; ///< The right padding
117 float top; ///< The top padding
118 float bottom; ///< The bottom padding
122 * @brief Creates an Alignment handle; this can be initialized with Alignment::New().
124 * Calling member functions with an uninitialized handle is not allowed.
130 * @brief Creates an alignment control.
133 * @param[in] horizontal Specifies how to align actors horizontally. Could be HorizontalLeft, HorizontalCenter or HorizontalRight. By default, HorizontalCenter
134 * @param[in] vertical Specifies how to align actors vertically. Could be VerticalTop, VerticalCenter or VerticalBottom. By default, VerticalCenter
135 * @return A handle to the Alignment control
137 static Alignment New( Type horizontal = HorizontalCenter, Type vertical = VerticalCenter );
140 * @brief Copy constructor. Creates another handle that points to the same real object.
143 * @param[in] alignment Object to copy
145 Alignment(const Alignment& alignment);
150 * This is non-virtual since derived Handle types must not contain data or virtual methods.
156 * @brief Downcasts a handle to Alignment handle.
158 * If handle points to an Alignment, the downcast produces valid handle.
159 * If not, the returned handle is left uninitialized.
162 * @param[in] handle Handle to an object
163 * @return A handle to a Alignment or an uninitialized handle
165 static Alignment DownCast( BaseHandle handle );
168 * @brief Sets the new alignment. By default, ( HorizontalCenter | VerticalCenter ).
171 * @param[in] type The new alignment option
172 * @note There should only be one horizontal and one vertical policy.
174 void SetAlignmentType( Type type );
177 * @brief Gets the current alignment combined into a single value.
179 * The values can be tested by using the & operator and the desired
182 * if (GetAlignmentType() & HorizontalCentre)
189 * @return the alignment value
191 Type GetAlignmentType() const;
194 * @brief Sets how added actors scale to fit the alignment's boundary.
197 * @param[in] scaling The scaling property
200 void SetScaling( Scaling scaling );
203 * @brief Retrieves the scaling property.
206 * @return The scaling
209 Scaling GetScaling() const;
212 * @brief Sets a padding value.
215 * @param[in] padding The left, right, top, bottom padding values
217 void SetPadding( const Padding& padding );
220 * @brief Gets the padding values.
223 * @return The left, right, top, bottom padding values
225 const Padding& GetPadding() const;
228 * @brief Assignment operator.
230 * Changes this handle to point to another real object.
232 * @param[in] alignment Object to copy
233 * @return A reference to this
235 Alignment& operator=(const Alignment& alignment);
237 public: // Not intended for application developers
241 * @brief Creates a handle using the Toolkit::Internal implementation.
244 * @param[in] implementation The Control implementation
246 DALI_INTERNAL Alignment( Internal::Alignment& implementation );
249 * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
252 * @param[in] internal A pointer to the internal CustomActor
254 explicit DALI_INTERNAL Alignment( Dali::Internal::CustomActor* internal );
262 } // namespace Toolkit
266 #endif // DALI_ALIGNMENT_H