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
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 DALI_IMPORT_API 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 ).
155 * @note there should only be one horizontal and one vertical policy
156 * @param [in] type The new alignment option.
158 void SetAlignmentType( Type type );
161 * @brief Get the current alignment combined into a single value.
163 * The values can be tested by using the & operator and the desired
166 * if (GetAlignmentType() & HorizontalCentre)
172 * @return the alignment value.
174 Type GetAlignmentType() const;
177 * @brief Sets how added actors scale to fit the alignment's boundary.
180 * @param[in] scaling The scaling property.
182 void SetScaling( Scaling scaling );
185 * @brief Retrieves the scaling property.
188 * @return The scaling.
190 Scaling GetScaling() const;
193 * @brief Set a padding value.
195 * @param [in] padding The left, right, top, bottom padding values.
197 void SetPadding( const Padding& padding );
200 * @brief Get the padding values.
202 * @return The left, right, top, bottom padding values.
204 const Padding& GetPadding() const;
207 * @brief Assignment operator.
209 * Changes this handle to point to another real object.
210 * @param[in] alignment Object to copy
211 * @return A reference to this
213 Alignment& operator=(const Alignment& alignment);
215 public: // Not intended for application developers
218 * @brief Creates a handle using the Toolkit::Internal implementation.
220 * @param[in] implementation The Control implementation.
222 DALI_INTERNAL Alignment( Internal::Alignment& implementation );
225 * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
227 * @param[in] internal A pointer to the internal CustomActor.
229 explicit DALI_INTERNAL Alignment( Dali::Internal::CustomActor* internal );
232 } // namespace Toolkit
236 #endif // __DALI_TOOLKIT_LAYOUT_H__