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