Apply the new doxygen tagging rule for @SINCE
[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.
44  * @SINCE_1_0.0
45  *
46  */
47 class DALI_IMPORT_API ImageView : public Control
48 {
49 public:
50   /**
51    * @brief The start and end property ranges for this control.
52    * @SINCE_1_0.0
53    */
54   enum PropertyRange
55   {
56     PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1,  ///< @SINCE_1_0.0
57     PROPERTY_END_INDEX =   PROPERTY_START_INDEX + 1000,              ///< Reserve property indices @SINCE_1_0.0
58
59     ANIMATABLE_PROPERTY_START_INDEX = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX,        ///< @SINCE_1_1.18
60     ANIMATABLE_PROPERTY_END_INDEX =   ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1000  ///< Reserve animatable property indices, @SINCE_1_1.18
61   };
62
63   /**
64    * @brief An enumeration of properties belonging to the ImageView class.
65    * @SINCE_1_0.0
66    */
67   struct Property
68   {
69     enum
70     {
71       // Event side properties
72       RESOURCE_URL = PROPERTY_START_INDEX, ///< name "resourceUrl",  @deprecated DALi 1.1.16 Use IMAGE instead.  type string @SINCE_1_0.0
73       IMAGE,                               ///< name "image",        @see SetImage(),                            type string if it is a url, map otherwise @SINCE_1_0.0
74       PRE_MULTIPLIED_ALPHA,                ///< name "preMultipliedAlpha",                                       type Boolean @pre image must be initialized. @SINCE_1_1.18
75
76       // Animatable properties
77       PIXEL_AREA = ANIMATABLE_PROPERTY_START_INDEX,  ///< name "pixelArea",                                      type Vector4, Pixel area is a relative value with the whole image area as [0.0, 0.0, 1.0, 1.0]. @SINCE_1_1.18
78     };
79   };
80
81 public:
82
83   /**
84    * @brief Create an uninitialized ImageView.
85    * @SINCE_1_0.0
86    */
87   ImageView();
88
89   /**
90    * @brief Create an initialized ImageView.
91    *
92    * @SINCE_1_0.0
93    * @return A handle to a newly allocated Dali ImageView.
94    *
95    * @note ImageView will not display anything.
96    */
97   static ImageView New();
98
99   /**
100    * @brief Create an initialized ImageView from an Image.
101    *
102    * If the handle is empty, ImageView will not display anything.
103    *
104    * @SINCE_1_0.0
105    * @param[in] image The Image to display.
106    * @return A handle to a newly allocated ImageView.
107    */
108   static ImageView New( Image image );
109
110   /**
111    * @brief Create an initialized ImageView from an Image resource URL
112    *
113    * If the string is empty, ImageView will not display anything.
114    *
115    * @SINCE_1_0.0
116    * @param[in] url The url of the image resource to display.
117    * @return A handle to a newly allocated ImageView.
118    */
119   static ImageView New( const std::string& url );
120
121   /**
122    * @brief Create an initialized ImageView from an Image resource URL
123    *
124    * If the string is empty, ImageView will not display anything.
125    *
126    * @SINCE_1_1.10
127    * @param[in] url The url of the image resource to display.
128    * @param [in] size The width and height to fit the loaded image to.
129    * @return A handle to a newly allocated ImageView.
130    *
131    * @note A valid size is preferable for efficiency.
132    *       However, do not set a size that is bigger than the actual image size, as up-scaling is not available.
133    *       The content of the area not covered by the actual image is undefined and will not be cleared.
134    */
135   static ImageView New( const std::string& url, ImageDimensions size );
136
137   /**
138    * @brief Destructor
139    *
140    * This is non-virtual since derived Handle types must not contain data or virtual methods.
141    * @SINCE_1_0.0
142    */
143   ~ImageView();
144
145   /**
146    * @brief Copy constructor.
147    *
148    * @SINCE_1_0.0
149    * @param[in] imageView ImageView to copy. The copied ImageView will point at the same implementation
150    */
151   ImageView( const ImageView& imageView );
152
153   /**
154    * @brief Assignment operator.
155    *
156    * @SINCE_1_0.0
157    * @param[in] imageView The ImageView to assign from.
158    * @return The updated ImageView.
159    */
160   ImageView& operator=( const ImageView& imageView );
161
162   /**
163    * @brief Downcast an Object handle to ImageView.
164    *
165    * If handle points to a ImageView the downcast produces valid
166    * handle. If not the returned handle is left uninitialized.
167    *
168    * @SINCE_1_0.0
169    * @param[in] handle Handle to an object
170    * @return handle to a ImageView or an uninitialized handle
171    */
172   static ImageView DownCast( BaseHandle handle );
173
174   /**
175    * @brief Sets this ImageView from an Image
176    *
177    * If the handle is empty, ImageView will display nothing
178    * @SINCE_1_0.0
179    * @param[in] image The Image to display.
180    */
181   void SetImage( Image image );
182
183   /**
184    * @brief Sets this ImageView from an Image URL
185    *
186    * If the URL is empty, ImageView will not display anything.
187    *
188    * @SINCE_1_1.4
189    * @param[in] url The Image resource to display.
190    */
191   void SetImage( const std::string& url );
192
193   /**
194    * @brief Sets this ImageView from an Image URL
195    *
196    * If the URL is empty, ImageView will not display anything.
197    *
198    * @SINCE_1_1.10
199    * @param[in] url A URL to the image resource to display.
200    * @param [in] size The width and height to fit the loaded image to.
201    */
202   void SetImage( const std::string& url, ImageDimensions size );
203
204   /**
205    * @deprecated Gets the Image
206    *
207    * @SINCE_1_0.0
208    * @return The Image currently set to this ImageView
209    */
210   Image GetImage() const;
211
212 public: // Not intended for application developers
213
214   /**
215    * @brief Creates a handle using the Toolkit::Internal implementation.
216    *
217    * @SINCE_1_0.0
218    * @param[in]  implementation  The ImageView implementation.
219    */
220   DALI_INTERNAL ImageView( Internal::ImageView& implementation );
221
222   /**
223    * @brief Allows the creation of this ImageView from an Internal::CustomActor pointer.
224    *
225    * @SINCE_1_0.0
226    * @param[in]  internal  A pointer to the internal CustomActor.
227    */
228   DALI_INTERNAL ImageView( Dali::Internal::CustomActor* internal );
229
230 };
231
232 /**
233  * @}
234  */
235 } // namespace Toolkit
236
237 } // namespace Dali
238
239 #endif // __DALI_TOOLKIT_IMAGE_VIEW_H__