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