1 #ifndef __DALI_ALIGNMENT_H__
2 #define __DALI_ALIGNMENT_H__
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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.
21 * @addtogroup CAPI_DALI_FRAMEWORK
26 #include <dali-toolkit/public-api/controls/control.h>
28 namespace Dali DALI_IMPORT_API
34 namespace Internal DALI_INTERNAL
40 * 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 Alignment : public Control
52 * Different types of alignment.
65 * 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
87 Padding( float l, float r, float t, float b )
102 * Create an Alignment handle; this can be initialised with Alignment::New()
103 * Calling member functions with an uninitialised handle is not allowed.
108 * Creates an alignment control.
109 * @param [in] horizontal Specifies how to align actors horizontally. Could be HorizontalLeft, HorizontalCenter or HorizontalRight. By default HorizontalCenter.
110 * @param [in] vertical Specifies how to align actors vertically. Could be VerticalTop, VerticalCenter or VerticalBottom. By default VerticalCenter.
111 * @return A handle to the Alignment control.
113 static Alignment New( Type horizontal = HorizontalCenter, Type vertical = VerticalCenter );
116 * Copy constructor. Creates another handle that points to the same real object.
118 Alignment(const Alignment& alignment);
121 * Virtual destructor.
122 * Dali::Object derived classes typically do not contain member data.
124 virtual ~Alignment();
127 * Downcast an Object handle to Alignment. If handle points to a Alignment the
128 * downcast produces valid handle. If not the returned handle is left uninitialized.
129 * @param[in] handle Handle to an object
130 * @return handle to a Alignment or an uninitialized handle
132 static Alignment DownCast( BaseHandle handle );
135 * Sets the new alignment. By default ( HorizontalCenter | VerticalCenter ).
136 * @param [in] type The new alignment option.
138 void SetAlignmentType( Type type );
141 * Get the current alignment combined into a single value.
142 * The values can be tested by using the & operator
143 * and the desired flag. e.g. if (GetAlignmentType() & HorizontalCentre) ...
144 * @return the alignment value.
146 Type GetAlignmentType() const;
149 * Sets how added actors scale to fit the alignment's boundary.
151 * @param[in] scaling The scaling property.
153 void SetScaling( Scaling scaling );
156 * Retrieves the scaling property.
158 * @return The scaling.
160 Scaling GetScaling() const;
163 * Set a padding value.
165 * @param [in] padding The left, right, top, bottom padding values.
167 void SetPadding( const Padding& padding );
170 * @return The left, right, top, bottom padding values.
172 const Padding& GetPadding() const;
175 * Assignment operator. Changes this handle to point to another real object.
177 Alignment& operator=(const Alignment& alignment);
179 public: // Not intended for application developers
182 * Creates a handle using the Toolkit::Internal implementation.
183 * @param[in] implementation The Control implementation.
185 Alignment( Internal::Alignment& implementation );
188 * Allows the creation of this Control from an Internal::CustomActor pointer.
189 * @param[in] internal A pointer to the internal CustomActor.
191 Alignment( Dali::Internal::CustomActor* internal );
194 } // namespace Toolkit
201 #endif // __DALI_TOOLKIT_LAYOUT_H__