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