Renaming of enum values for coding standards compliance.
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / controls / alignment / alignment.h
1 #ifndef DALI_ALIGNMENT_H
2 #define DALI_ALIGNMENT_H
3
4 /*
5  * Copyright (c) 2019 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  * Additionally, 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 SCALE_NONE, constraints as well.
48  */
49 class DALI_TOOLKIT_API Alignment : public Control
50 {
51 public:
52   /**
53    * @brief Enumeration for different types of alignment.
54    * @SINCE_1_0.0
55    */
56   enum Type
57   {
58     HORIZONTAL_LEFT   = 1, ///< HORIZONTAL left alignment @SINCE_1_9.28
59     HORIZONTAL_CENTER = 2, ///< HORIZONTAL center alignment @SINCE_1_9.28
60     HORIZONTAL_RIGHT  = 4, ///< HORIZONTAL right alignment @SINCE_1_9.28
61     VERTICAL_TOP      = 8, ///< VERTICAL top alignment @SINCE_1_9.28
62     VERTICAL_CENTER   = 16, ///< VERTICAL center alignment @SINCE_1_9.28
63     VERTICAL_BOTTOM   = 32 ///< VERTICAL bottom alignment @SINCE_1_9.28
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     SCALE_NONE,             ///< The original size is kept. @SINCE_1_9.28
73     SCALE_TO_FILL,           ///< Scale added actors to fill alignment's boundary. Aspect ratio is not maintained. @SINCE_1_9.28
74     SCALE_TO_FIT_KEEP_ASPECT,  ///< Scale added actors to fit within the alignment's boundary. Aspect ratio is maintained. @SINCE_1_9.28
75     SCALE_TO_FILL_KEEP_ASPECT, ///< Scale added actors to fill the alignment's boundary. Aspect ratio is maintained, and the actor may exceed the alignment's boundary. @SINCE_1_9.28
76     SHRINK_TO_FIT,           ///< If added actors are larger than the alignment's boundary it will be shrunk down to fit. Aspect ratio is not maintained @SINCE_1_9.28
77     SHRINK_TO_FIT_KEEP_ASPECT, ///< If added actors are larger than the alignment's boundary it will be shrunk down to fit. Aspect ratio is maintained @SINCE_1_9.28
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 Creates an Alignment handle; this can be initialized with Alignment::New().
123    *
124    * Calling member functions with an uninitialized 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 HORIZONTAL_LEFT, HORIZONTAL_CENTER or HORIZONTAL_RIGHT. By default, HORIZONTAL_CENTER
134    * @param[in] vertical Specifies how to align actors vertically. Could be VERTICAL_TOP, VERTICAL_CENTER or VERTICAL_BOTTOM. By default, VERTICAL_CENTER
135    * @return A handle to the Alignment control
136    */
137   static Alignment New( Type horizontal = HORIZONTAL_CENTER, Type vertical = VERTICAL_CENTER );
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 Downcasts a handle to Alignment handle.
157    *
158    * If handle points to an Alignment, the downcast produces valid handle.
159    * If not, the returned handle is left uninitialized.
160    *
161    * @SINCE_1_0.0
162    * @param[in] handle Handle to an object
163    * @return A 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, ( HORIZONTAL_CENTER | VERTICAL_CENTER ).
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 Gets 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 Sets 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 Gets 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   /// @cond internal
240   /**
241    * @brief Creates a handle using the Toolkit::Internal implementation.
242    *
243    * @SINCE_1_0.0
244    * @param[in] implementation The Control implementation
245    */
246   DALI_INTERNAL Alignment( Internal::Alignment& implementation );
247
248   /**
249    * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
250    *
251    * @SINCE_1_0.0
252    * @param[in] internal A pointer to the internal CustomActor
253    */
254   explicit DALI_INTERNAL Alignment( Dali::Internal::CustomActor* internal );
255   /// @endcond
256 };
257
258 /**
259  * @}
260  */
261
262 } // namespace Toolkit
263
264 } // namespace Dali
265
266 #endif // DALI_ALIGNMENT_H