Merge "Add Visual descriptions to generate doxygen page" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / public-api / controls / image-view / image-view.h
1 #ifndef __DALI_TOOLKIT_IMAGE_VIEW_H__
2 #define __DALI_TOOLKIT_IMAGE_VIEW_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 // EXTERNAL INCLUDES
25 #include <dali/public-api/images/image-operations.h>
26
27 namespace Dali
28 {
29
30 namespace Toolkit
31 {
32
33 namespace Internal DALI_INTERNAL
34 {
35 class ImageView;
36 }
37 /**
38  * @addtogroup dali_toolkit_controls_image_view
39  * @{
40  */
41
42 /**
43  * @brief ImageView is a class for displaying an image resource.
44  *
45  * An instance of ImageView can be created using a URL or an Image instance.
46  *
47  * @SINCE_1_0.0
48  *
49  */
50 class DALI_IMPORT_API ImageView : public Control
51 {
52 public:
53
54   /**
55    * @brief Enumeration for the start and end property ranges for this control.
56    * @SINCE_1_0.0
57    */
58   enum PropertyRange
59   {
60     PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1,  ///< @SINCE_1_0.0
61     PROPERTY_END_INDEX =   PROPERTY_START_INDEX + 1000,              ///< Reserve property indices @SINCE_1_0.0
62
63     ANIMATABLE_PROPERTY_START_INDEX = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX,        ///< @SINCE_1_1.18
64     ANIMATABLE_PROPERTY_END_INDEX =   ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1000  ///< Reserve animatable property indices, @SINCE_1_1.18
65   };
66
67   /**
68    * @brief Enumeration for the instance of properties belonging to the ImageView class.
69    * @SINCE_1_0.0
70    */
71   struct Property
72   {
73     /**
74      * @brief Enumeration for the instance of properties belonging to the ImageView class.
75      * @SINCE_1_0.0
76      */
77     enum
78     {
79       // Event side properties
80
81       /**
82        * @DEPRECATED_1_1.16. Use IMAGE instead.
83        * @brief name "resourceUrl", type string.
84        * @SINCE_1_0.0
85        */
86       RESOURCE_URL = PROPERTY_START_INDEX,
87
88       /**
89        * @brief name "image", type string if it is a url, map otherwise.
90        * @SINCE_1_0.0
91        */
92       IMAGE,
93
94       /**
95        * @brief name "preMultipliedAlpha", type Boolean.
96        * @SINCE_1_1.18
97        * @pre image must be initialized.
98        */
99       PRE_MULTIPLIED_ALPHA,
100
101
102       // Animatable properties
103
104       /**
105        * @brief name "pixelArea", type Vector4.
106        * @details Pixel area is a relative value with the whole image area as [0.0, 0.0, 1.0, 1.0].
107        * @SINCE_1_1.18
108        */
109       PIXEL_AREA = ANIMATABLE_PROPERTY_START_INDEX,
110     };
111   };
112
113 public:
114
115   /**
116    * @brief Creates an uninitialized ImageView.
117    * @SINCE_1_0.0
118    */
119   ImageView();
120
121   /**
122    * @brief Create an initialized ImageView.
123    *
124    * @SINCE_1_0.0
125    * @return A handle to a newly allocated Dali ImageView
126    *
127    * @note ImageView will not display anything.
128    */
129   static ImageView New();
130
131   /**
132    * @DEPRECATED_1_2_8, use New( const std::string& ) instead.
133    *
134    * @brief Creates an initialized ImageView from an Image instance.
135    *
136    * If the handle is empty, ImageView will not display anything.
137    *
138    * @SINCE_1_0.0
139    * @param[in] image The Image instance to display
140    * @return A handle to a newly allocated ImageView
141    */
142   static ImageView New( Image image ) DALI_DEPRECATED_API;
143
144   /**
145    * @brief Creates an initialized ImageView from an URL to an image resource.
146    *
147    * If the string is empty, ImageView will not display anything.
148    *
149    * @SINCE_1_0.0
150    * @REMARK_INTERNET
151    * @REMARK_STORAGE
152    * @param[in] url The url of the image resource to display
153    * @return A handle to a newly allocated ImageView
154    */
155   static ImageView New( const std::string& url );
156
157   /**
158    * @brief Creates an initialized ImageView from a URL to an image resource.
159    *
160    * If the string is empty, ImageView will not display anything.
161    *
162    * @SINCE_1_1.10
163    * @REMARK_INTERNET
164    * @REMARK_STORAGE
165    * @param[in] url The url of the image resource to display
166    * @param [in] size The width and height to which to fit the loaded image
167    * @return A handle to a newly allocated ImageView
168    * @note A valid size is preferable for efficiency.
169    *       However, do not set a size that is bigger than the actual image size, as up-scaling is not available.
170    *       The content of the area not covered by the actual image is undefined and will not be cleared.
171    */
172   static ImageView New( const std::string& url, ImageDimensions size );
173
174   /**
175    * @brief Destructor.
176    *
177    * This is non-virtual since derived Handle types must not contain data or virtual methods.
178    * @SINCE_1_0.0
179    */
180   ~ImageView();
181
182   /**
183    * @brief Copy constructor.
184    *
185    * @SINCE_1_0.0
186    * @param[in] imageView ImageView to copy. The copied ImageView will point at the same implementation
187    */
188   ImageView( const ImageView& imageView );
189
190   /**
191    * @brief Assignment operator.
192    *
193    * @SINCE_1_0.0
194    * @param[in] imageView The ImageView to assign from
195    * @return The updated ImageView
196    */
197   ImageView& operator=( const ImageView& imageView );
198
199   /**
200    * @brief Downcasts a handle to ImageView handle.
201    *
202    * If handle points to a ImageView, the downcast produces valid handle.
203    * If not, the returned handle is left uninitialized.
204    *
205    * @SINCE_1_0.0
206    * @param[in] handle Handle to an object
207    * @return Handle to a ImageView or an uninitialized handle
208    */
209   static ImageView DownCast( BaseHandle handle );
210
211   /**
212    * @DEPRECATED_1_2_8, use SetImage( const std::string& ) instead.
213    *
214    * @brief Sets this ImageView from an Image instance.
215    *
216    * If the handle is empty, ImageView will display nothing
217    * @SINCE_1_0.0
218    * @param[in] image The Image instance to display.
219    */
220   void SetImage( Image image ) DALI_DEPRECATED_API;
221
222   /**
223    * @brief Sets this ImageView from the given URL.
224    *
225    * If the URL is empty, ImageView will not display anything.
226    *
227    * @SINCE_1_1.4
228    * @REMARK_INTERNET
229    * @REMARK_STORAGE
230    * @param[in] url The URL to the image resource to display
231    */
232   void SetImage( const std::string& url );
233
234   /**
235    * @brief Sets this ImageView from the given URL.
236    *
237    * If the URL is empty, ImageView will not display anything.
238    *
239    * @SINCE_1_1.10
240    * @REMARK_INTERNET
241    * @REMARK_STORAGE
242    * @param[in] url The URL to the image resource to display
243    * @param [in] size The width and height to fit the loaded image to
244    */
245   void SetImage( const std::string& url, ImageDimensions size );
246
247   /**
248    * @DEPRECATED_1_1.4
249    * @brief Gets the Image instance handle used by the ImageView.
250    *
251    * A valid handle will be returned only if this instance was created with New(Image) or SetImage(Image) was called.
252    *
253    * @SINCE_1_0.0
254    * @return The Image instance currently used by the ImageView
255    */
256   Image GetImage() const DALI_DEPRECATED_API;
257
258 public: // Not intended for application developers
259
260   /// @cond internal
261   /**
262    * @brief Creates a handle using the Toolkit::Internal implementation.
263    *
264    * @SINCE_1_0.0
265    * @param[in] implementation The ImageView implementation
266    */
267   DALI_INTERNAL ImageView( Internal::ImageView& implementation );
268
269   /**
270    * @brief Allows the creation of this ImageView from an Internal::CustomActor pointer.
271    *
272    * @SINCE_1_0.0
273    * @param[in] internal A pointer to the internal CustomActor
274    */
275   DALI_INTERNAL ImageView( Dali::Internal::CustomActor* internal );
276   /// @endcond
277
278 };
279
280 /**
281  * @}
282  */
283 } // namespace Toolkit
284
285 } // namespace Dali
286
287 #endif // __DALI_TOOLKIT_IMAGE_VIEW_H__