Remove obsolete and non functional SizeChanged signal from actor
[platform/core/uifw/dali-toolkit.git] / base / dali-toolkit / public-api / controls / alignment / alignment.h
1 #ifndef __DALI_ALIGNMENT_H__
2 #define __DALI_ALIGNMENT_H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali-toolkit/public-api/controls/control.h>
23
24 namespace Dali
25 {
26
27 namespace Toolkit
28 {
29
30 namespace Internal DALI_INTERNAL
31 {
32 class Alignment;
33 }
34
35 /**
36  * @brief Alignment is a container which provides an easy way to align other actors inside its boundary.
37  *
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.
40  *
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.
43  */
44 class DALI_IMPORT_API Alignment : public Control
45 {
46 public:
47   /**
48    * @brief Different types of alignment.
49    */
50   enum Type
51   {
52     HorizontalLeft   = 1,
53     HorizontalCenter = 2,
54     HorizontalRight  = 4,
55     VerticalTop      = 8,
56     VerticalCenter   = 16,
57     VerticalBottom   = 32
58   };
59
60   /**
61    * @brief Scaling determines how actors are scaled, to match the alignment's boundary.
62    */
63   enum Scaling
64   {
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
71   };
72
73   /**
74    * @brief Structure describing the padding values.
75    */
76   struct Padding
77   {
78     /**
79      * @brief Constructor
80      */
81     Padding()
82     : left( 0.f ),
83       right( 0.f ),
84       top( 0.f ),
85       bottom( 0.f )
86     {
87     }
88
89     /**
90      * @brief Constructor
91      *
92      * @param[in] l Left padding
93      * @param[in] r Right padding
94      * @param[in] t Top padding
95      * @param[in] b Bottom padding
96      */
97     Padding( float l, float r, float t, float b )
98     : left( l ),
99       right( r ),
100       top( t ),
101       bottom( b )
102     {
103     }
104
105     float left;  ///< The left padding
106     float right; ///< The right padding
107     float top;   ///< The top padding
108     float bottom; ///< The bottom padding
109   };
110
111   /**
112    * @brief Create an Alignment handle; this can be initialised with Alignment::New().
113    *
114    * Calling member functions with an uninitialised handle is not allowed.
115    */
116   Alignment();
117
118   /**
119    * @brief Creates an alignment control.
120    *
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.
124    */
125   static Alignment New( Type horizontal = HorizontalCenter, Type vertical = VerticalCenter );
126
127   /**
128    * @brief Copy constructor. Creates another handle that points to the same real object.
129    *
130    * @param[in] alignment Object to copy.
131    */
132   Alignment(const Alignment& alignment);
133
134   /**
135    * @brief Destructor
136    *
137    * This is non-virtual since derived Handle types must not contain data or virtual methods.
138    */
139   ~Alignment();
140
141   /**
142    * @brief Downcast an Object handle to Alignment.
143    *
144    * If handle points to a Alignment the downcast produces valid
145    * handle. If not the returned handle is left uninitialized.
146    *
147    * @param[in] handle Handle to an object
148    * @return handle to a Alignment or an uninitialized handle
149    */
150   static Alignment DownCast( BaseHandle handle );
151
152   /**
153    * @brief Sets the new alignment. By default ( HorizontalCenter | VerticalCenter ).
154    *
155    * @note there should only be one horizontal and one vertical policy
156    * @param [in] type The new alignment option.
157    */
158   void SetAlignmentType( Type type );
159
160   /**
161    * @brief Get the current alignment combined into a single value.
162    *
163    * The values can be tested by using the & operator and the desired
164    * flag. e.g.
165    * @code
166    *   if (GetAlignmentType() & HorizontalCentre)
167    *   {
168    *     ...
169    *   }
170    * @endcode
171    *
172    * @return the alignment value.
173    */
174   Type GetAlignmentType() const;
175
176   /**
177    * @brief Sets how added actors scale to fit the alignment's boundary.
178    *
179    * @see Scaling.
180    * @param[in] scaling The scaling property.
181    */
182   void SetScaling( Scaling scaling );
183
184   /**
185    * @brief Retrieves the scaling property.
186    *
187    * @see Scaling.
188    * @return The scaling.
189    */
190   Scaling GetScaling() const;
191
192   /**
193    * @brief Set a padding value.
194    *
195    * @param [in] padding The left, right, top, bottom padding values.
196    */
197   void SetPadding( const Padding& padding );
198
199   /**
200    * @brief Get the padding values.
201    *
202    * @return The left, right, top, bottom padding values.
203    */
204   const Padding& GetPadding() const;
205
206   /**
207    * @brief Assignment operator.
208    *
209    * Changes this handle to point to another real object.
210    * @param[in] alignment Object to copy
211    * @return A reference to this
212    */
213   Alignment& operator=(const Alignment& alignment);
214
215 public: // Not intended for application developers
216
217   /**
218    * @brief Creates a handle using the Toolkit::Internal implementation.
219    *
220    * @param[in]  implementation  The Control implementation.
221    */
222   DALI_INTERNAL Alignment( Internal::Alignment& implementation );
223
224   /**
225    * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
226    *
227    * @param[in]  internal  A pointer to the internal CustomActor.
228    */
229   explicit DALI_INTERNAL Alignment( Dali::Internal::CustomActor* internal );
230 };
231
232 } // namespace Toolkit
233
234 } // namespace Dali
235
236 #endif // __DALI_TOOLKIT_LAYOUT_H__