Retrieve the input font's style.
[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 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 An enumeration of properties belonging to the ImageView class.
69    * @SINCE_1_0.0
70    */
71   struct Property
72   {
73     enum
74     {
75       // Event side properties
76
77       /**
78        * @DEPRECATED_1_1.16. Use IMAGE instead.
79        * @brief name "resourceUrl", type string
80        * @SINCE_1_0.0
81        */
82       RESOURCE_URL = PROPERTY_START_INDEX,
83
84       /**
85        * @brief name "image", type string if it is a url, map otherwise
86        * @SINCE_1_0.0
87        */
88       IMAGE,
89
90       /**
91        * @brief name "preMultipliedAlpha", type Boolean
92        * @SINCE_1_1.18
93        * @pre image must be initialized.
94        */
95       PRE_MULTIPLIED_ALPHA,
96
97
98       // Animatable properties
99
100       /**
101        * @brief name "pixelArea", type Vector4
102        * @details Pixel area is a relative value with the whole image area as [0.0, 0.0, 1.0, 1.0].
103        * @SINCE_1_1.18
104        */
105       PIXEL_AREA = ANIMATABLE_PROPERTY_START_INDEX,
106     };
107   };
108
109 public:
110
111   /**
112    * @brief Create an uninitialized ImageView.
113    * @SINCE_1_0.0
114    */
115   ImageView();
116
117   /**
118    * @brief Create an initialized ImageView.
119    *
120    * @SINCE_1_0.0
121    * @return A handle to a newly allocated Dali ImageView.
122    *
123    * @note ImageView will not display anything.
124    */
125   static ImageView New();
126
127   /**
128    * @brief Create an initialized ImageView from an Image instance.
129    *
130    * If the handle is empty, ImageView will not display anything.
131    *
132    * @SINCE_1_0.0
133    * @param[in] image The Image instance to display.
134    * @return A handle to a newly allocated ImageView.
135    */
136   static ImageView New( Image image );
137
138   /**
139    * @brief Create an initialized ImageView from an URL to an image resource.
140    *
141    * If the string is empty, ImageView will not display anything.
142    *
143    * @SINCE_1_0.0
144    * @param[in] url The url of the image resource to display.
145    * @return A handle to a newly allocated ImageView.
146    */
147   static ImageView New( const std::string& url );
148
149   /**
150    * @brief Create an initialized ImageView from a URL to an image resource.
151    *
152    * If the string is empty, ImageView will not display anything.
153    *
154    * @SINCE_1_1.10
155    * @param[in] url The url of the image resource to display.
156    * @param [in] size The width and height to which to fit the loaded image.
157    * @return A handle to a newly allocated ImageView.
158    *
159    * @note A valid size is preferable for efficiency.
160    *       However, do not set a size that is bigger than the actual image size, as up-scaling is not available.
161    *       The content of the area not covered by the actual image is undefined and will not be cleared.
162    */
163   static ImageView New( const std::string& url, ImageDimensions size );
164
165   /**
166    * @brief Destructor
167    *
168    * This is non-virtual since derived Handle types must not contain data or virtual methods.
169    * @SINCE_1_0.0
170    */
171   ~ImageView();
172
173   /**
174    * @brief Copy constructor.
175    *
176    * @SINCE_1_0.0
177    * @param[in] imageView ImageView to copy. The copied ImageView will point at the same implementation
178    */
179   ImageView( const ImageView& imageView );
180
181   /**
182    * @brief Assignment operator.
183    *
184    * @SINCE_1_0.0
185    * @param[in] imageView The ImageView to assign from.
186    * @return The updated ImageView.
187    */
188   ImageView& operator=( const ImageView& imageView );
189
190   /**
191    * @brief Downcast a handle to ImageView handle.
192    *
193    * If handle points to a ImageView the downcast produces valid
194    * handle. If not the returned handle is left uninitialized.
195    *
196    * @SINCE_1_0.0
197    * @param[in] handle Handle to an object
198    * @return handle to a ImageView or an uninitialized handle
199    */
200   static ImageView DownCast( BaseHandle handle );
201
202   /**
203    * @brief Sets this ImageView from an Image instance.
204    *
205    * If the handle is empty, ImageView will display nothing
206    * @SINCE_1_0.0
207    * @param[in] image The Image instance to display.
208    */
209   void SetImage( Image image );
210
211   /**
212    * @brief Sets this ImageView from the given URL.
213    *
214    * If the URL is empty, ImageView will not display anything.
215    *
216    * @SINCE_1_1.4
217    * @param[in] url The URL to the image resource to display.
218    */
219   void SetImage( const std::string& url );
220
221   /**
222    * @brief Sets this ImageView from the given URL.
223    *
224    * If the URL is empty, ImageView will not display anything.
225    *
226    * @SINCE_1_1.10
227    * @param[in] url The URL to the image resource to display.
228    * @param [in] size The width and height to fit the loaded image to.
229    */
230   void SetImage( const std::string& url, ImageDimensions size );
231
232   /**
233    * @DEPRECATED_1_1.4
234    * @brief Gets the Image instance handle used by the ImageView.
235    *
236    * A valid handle will be returned only if this instance was created with New(Image) or SetImage(Image) was called.
237    *
238    * @SINCE_1_0.0
239    * @return The Image instance currently used by the ImageView.
240    */
241   Image GetImage() const;
242
243 public: // Not intended for application developers
244
245   /**
246    * @brief Creates a handle using the Toolkit::Internal implementation.
247    *
248    * @SINCE_1_0.0
249    * @param[in]  implementation  The ImageView implementation.
250    */
251   DALI_INTERNAL ImageView( Internal::ImageView& implementation );
252
253   /**
254    * @brief Allows the creation of this ImageView from an Internal::CustomActor pointer.
255    *
256    * @SINCE_1_0.0
257    * @param[in]  internal  A pointer to the internal CustomActor.
258    */
259   DALI_INTERNAL ImageView( Dali::Internal::CustomActor* internal );
260
261 };
262
263 /**
264  * @}
265  */
266 } // namespace Toolkit
267
268 } // namespace Dali
269
270 #endif // __DALI_TOOLKIT_IMAGE_VIEW_H__