Send the empty string to IME when PlaceholderText shows
[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  * Some resources can be loaded before the ImageView is staged ( already cached ), in these cases if the connection to
48  * ResouceReadySignal is done after the resource is set then signal will be missed.
49  *
50  * To protect against this, IsResourceReady() can be checked before connecting to ResourceReadySignal,
51  * or the signal connection can be done before setting the resource"
52  *
53  * @code
54  *    auto myImageView = ImageView::New( resourceUrl );
55  *    if ( myImageView.IsResourceReady() )
56  *    {
57  *       // do something
58  *    }
59  *    else
60  *    {
61  *      myImageView.ResourceReadySignal.Connect( .... )
62  *    }
63  * @endcode
64  *
65  * OR Connect to signal before setting resource
66  *
67  * @code
68  *    auto myImageView = ImageView::New();
69  *    myImageView.ResourceReadySignal.Connect( .... )
70  *    myImageView.SetProperty( ImageView::Property::IMAGE, resourceUrl );
71  * @endcode
72  *
73  * @SINCE_1_0.0
74  *
75  */
76 class DALI_IMPORT_API ImageView : public Control
77 {
78 public:
79
80   /**
81    * @brief Enumeration for the start and end property ranges for this control.
82    * @SINCE_1_0.0
83    */
84   enum PropertyRange
85   {
86     PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1,  ///< @SINCE_1_0.0
87     PROPERTY_END_INDEX =   PROPERTY_START_INDEX + 1000,              ///< Reserve property indices @SINCE_1_0.0
88
89     ANIMATABLE_PROPERTY_START_INDEX = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX,        ///< @SINCE_1_1.18
90     ANIMATABLE_PROPERTY_END_INDEX =   ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1000  ///< Reserve animatable property indices, @SINCE_1_1.18
91   };
92
93   /**
94    * @brief Enumeration for the instance of properties belonging to the ImageView class.
95    * @SINCE_1_0.0
96    */
97   struct Property
98   {
99     /**
100      * @brief Enumeration for the instance of properties belonging to the ImageView class.
101      * @SINCE_1_0.0
102      */
103     enum
104     {
105       // Event side properties
106
107       /**
108        * @DEPRECATED_1_1.16. Use IMAGE instead.
109        * @brief name "resourceUrl", type string.
110        * @SINCE_1_0.0
111        */
112       RESOURCE_URL = PROPERTY_START_INDEX,
113
114       /**
115        * @brief name "image", type string if it is a url, map otherwise.
116        * @SINCE_1_0.0
117        */
118       IMAGE,
119
120       /**
121        * @brief name "preMultipliedAlpha", type Boolean.
122        * @SINCE_1_1.18
123        * @pre image must be initialized.
124        */
125       PRE_MULTIPLIED_ALPHA,
126
127
128       // Animatable properties
129
130       /**
131        * @brief name "pixelArea", type Vector4.
132        * @details Pixel area is a relative value with the whole image area as [0.0, 0.0, 1.0, 1.0].
133        * @SINCE_1_1.18
134        */
135       PIXEL_AREA = ANIMATABLE_PROPERTY_START_INDEX,
136     };
137   };
138
139 public:
140
141   /**
142    * @brief Creates an uninitialized ImageView.
143    * @SINCE_1_0.0
144    */
145   ImageView();
146
147   /**
148    * @brief Create an initialized ImageView.
149    *
150    * @SINCE_1_0.0
151    * @return A handle to a newly allocated Dali ImageView
152    *
153    * @note ImageView will not display anything.
154    */
155   static ImageView New();
156
157   /**
158    * @DEPRECATED_1_2_8, use New( const std::string& ) instead.
159    *
160    * @brief Creates an initialized ImageView from an Image instance.
161    *
162    * If the handle is empty, ImageView will not display anything.
163    *
164    * @SINCE_1_0.0
165    * @param[in] image The Image instance to display
166    * @return A handle to a newly allocated ImageView
167    */
168   static ImageView New( Image image ) DALI_DEPRECATED_API;
169
170   /**
171    * @brief Creates an initialized ImageView from an URL to an image resource.
172    *
173    * If the string is empty, ImageView will not display anything.
174    *
175    * @SINCE_1_0.0
176    * @REMARK_INTERNET
177    * @REMARK_STORAGE
178    * @param[in] url The url of the image resource to display
179    * @return A handle to a newly allocated ImageView
180    */
181   static ImageView New( const std::string& url );
182
183   /**
184    * @brief Creates an initialized ImageView from a URL to an image resource.
185    *
186    * If the string is empty, ImageView will not display anything.
187    *
188    * @SINCE_1_1.10
189    * @REMARK_INTERNET
190    * @REMARK_STORAGE
191    * @param[in] url The url of the image resource to display
192    * @param [in] size The width and height to which to fit the loaded image
193    * @return A handle to a newly allocated ImageView
194    * @note A valid size is preferable for efficiency.
195    *       However, do not set a size that is bigger than the actual image size, as up-scaling is not available.
196    *       The content of the area not covered by the actual image is undefined and will not be cleared.
197    */
198   static ImageView New( const std::string& url, ImageDimensions size );
199
200   /**
201    * @brief Destructor.
202    *
203    * This is non-virtual since derived Handle types must not contain data or virtual methods.
204    * @SINCE_1_0.0
205    */
206   ~ImageView();
207
208   /**
209    * @brief Copy constructor.
210    *
211    * @SINCE_1_0.0
212    * @param[in] imageView ImageView to copy. The copied ImageView will point at the same implementation
213    */
214   ImageView( const ImageView& imageView );
215
216   /**
217    * @brief Assignment operator.
218    *
219    * @SINCE_1_0.0
220    * @param[in] imageView The ImageView to assign from
221    * @return The updated ImageView
222    */
223   ImageView& operator=( const ImageView& imageView );
224
225   /**
226    * @brief Downcasts a handle to ImageView handle.
227    *
228    * If handle points to a ImageView, the downcast produces valid handle.
229    * If not, the returned handle is left uninitialized.
230    *
231    * @SINCE_1_0.0
232    * @param[in] handle Handle to an object
233    * @return Handle to a ImageView or an uninitialized handle
234    */
235   static ImageView DownCast( BaseHandle handle );
236
237   /**
238    * @DEPRECATED_1_2_8, use SetImage( const std::string& ) instead.
239    *
240    * @brief Sets this ImageView from an Image instance.
241    *
242    * If the handle is empty, ImageView will display nothing
243    * @SINCE_1_0.0
244    * @param[in] image The Image instance to display.
245    */
246   void SetImage( Image image ) DALI_DEPRECATED_API;
247
248   /**
249    * @brief Sets this ImageView from the given URL.
250    *
251    * If the URL is empty, ImageView will not display anything.
252    *
253    * @SINCE_1_1.4
254    * @REMARK_INTERNET
255    * @REMARK_STORAGE
256    * @param[in] url The URL to the image resource to display
257    */
258   void SetImage( const std::string& url );
259
260   /**
261    * @brief Sets this ImageView from the given URL.
262    *
263    * If the URL is empty, ImageView will not display anything.
264    *
265    * @SINCE_1_1.10
266    * @REMARK_INTERNET
267    * @REMARK_STORAGE
268    * @param[in] url The URL to the image resource to display
269    * @param [in] size The width and height to fit the loaded image to
270    */
271   void SetImage( const std::string& url, ImageDimensions size );
272
273   /**
274    * @DEPRECATED_1_1.4
275    * @brief Gets the Image instance handle used by the ImageView.
276    *
277    * A valid handle will be returned only if this instance was created with New(Image) or SetImage(Image) was called.
278    *
279    * @SINCE_1_0.0
280    * @return The Image instance currently used by the ImageView
281    */
282   Image GetImage() const DALI_DEPRECATED_API;
283
284 public: // Not intended for application developers
285
286   /// @cond internal
287   /**
288    * @brief Creates a handle using the Toolkit::Internal implementation.
289    *
290    * @SINCE_1_0.0
291    * @param[in] implementation The ImageView implementation
292    */
293   DALI_INTERNAL ImageView( Internal::ImageView& implementation );
294
295   /**
296    * @brief Allows the creation of this ImageView from an Internal::CustomActor pointer.
297    *
298    * @SINCE_1_0.0
299    * @param[in] internal A pointer to the internal CustomActor
300    */
301   DALI_INTERNAL ImageView( Dali::Internal::CustomActor* internal );
302   /// @endcond
303
304 };
305
306 /**
307  * @}
308  */
309 } // namespace Toolkit
310
311 } // namespace Dali
312
313 #endif // __DALI_TOOLKIT_IMAGE_VIEW_H__