1 #ifndef __DALI_TOOLKIT_IMAGE_VIEW_H__
2 #define __DALI_TOOLKIT_IMAGE_VIEW_H__
5 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali-toolkit/public-api/controls/control.h>
25 #include <dali/public-api/images/image-operations.h>
33 namespace Internal DALI_INTERNAL
38 * @addtogroup dali_toolkit_controls_image_view
43 * @brief ImageView is a class for displaying an image resource.
45 * An instance of ImageView can be created using a URL or an Image instance.
50 class DALI_IMPORT_API ImageView : public Control
55 * @brief The start and end property ranges for this control.
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
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
68 * @brief An enumeration of properties belonging to the ImageView class.
74 * @brief An enumeration of properties belonging to the ImageView class.
79 // Event side properties
82 * @DEPRECATED_1_1.16. Use IMAGE instead.
83 * @brief name "resourceUrl", type string
86 RESOURCE_URL = PROPERTY_START_INDEX,
89 * @brief name "image", type string if it is a url, map otherwise
95 * @brief name "preMultipliedAlpha", type Boolean
97 * @pre image must be initialized.
102 // Animatable properties
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].
109 PIXEL_AREA = ANIMATABLE_PROPERTY_START_INDEX,
116 * @brief Create an uninitialized ImageView.
122 * @brief Create an initialized ImageView.
125 * @return A handle to a newly allocated Dali ImageView.
127 * @note ImageView will not display anything.
129 static ImageView New();
132 * @DEPRECATED_1_2_8, use New( const std::string& ) instead.
134 * @brief Create an initialized ImageView from an Image instance.
136 * If the handle is empty, ImageView will not display anything.
139 * @param[in] image The Image instance to display.
140 * @return A handle to a newly allocated ImageView.
142 static ImageView New( Image image ) DALI_DEPRECATED_API;
145 * @brief Create an initialized ImageView from an URL to an image resource.
147 * If the string is empty, ImageView will not display anything.
152 * @param[in] url The url of the image resource to display.
153 * @return A handle to a newly allocated ImageView.
155 static ImageView New( const std::string& url );
158 * @brief Create an initialized ImageView from a URL to an image resource.
160 * If the string is empty, ImageView will not display anything.
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.
169 * @note A valid size is preferable for efficiency.
170 * However, do not set a size that is bigger than the actual image size, as up-scaling is not available.
171 * The content of the area not covered by the actual image is undefined and will not be cleared.
173 static ImageView New( const std::string& url, ImageDimensions size );
178 * This is non-virtual since derived Handle types must not contain data or virtual methods.
184 * @brief Copy constructor.
187 * @param[in] imageView ImageView to copy. The copied ImageView will point at the same implementation
189 ImageView( const ImageView& imageView );
192 * @brief Assignment operator.
195 * @param[in] imageView The ImageView to assign from.
196 * @return The updated ImageView.
198 ImageView& operator=( const ImageView& imageView );
201 * @brief Downcast a handle to ImageView handle.
203 * If handle points to a ImageView the downcast produces valid
204 * handle. If not the returned handle is left uninitialized.
207 * @param[in] handle Handle to an object
208 * @return handle to a ImageView or an uninitialized handle
210 static ImageView DownCast( BaseHandle handle );
213 * @DEPRECATED_1_2_8, use SetImage( const std::string& ) instead.
215 * @brief Sets this ImageView from an Image instance.
217 * If the handle is empty, ImageView will display nothing
219 * @param[in] image The Image instance to display.
221 void SetImage( Image image ) DALI_DEPRECATED_API;
224 * @brief Sets this ImageView from the given URL.
226 * If the URL is empty, ImageView will not display anything.
231 * @param[in] url The URL to the image resource to display.
233 void SetImage( const std::string& url );
236 * @brief Sets this ImageView from the given URL.
238 * If the URL is empty, ImageView will not display anything.
243 * @param[in] url The URL to the image resource to display.
244 * @param [in] size The width and height to fit the loaded image to.
246 void SetImage( const std::string& url, ImageDimensions size );
250 * @brief Gets the Image instance handle used by the ImageView.
252 * A valid handle will be returned only if this instance was created with New(Image) or SetImage(Image) was called.
255 * @return The Image instance currently used by the ImageView.
257 Image GetImage() const DALI_DEPRECATED_API;
259 public: // Not intended for application developers
263 * @brief Creates a handle using the Toolkit::Internal implementation.
266 * @param[in] implementation The ImageView implementation.
268 DALI_INTERNAL ImageView( Internal::ImageView& implementation );
272 * @brief Allows the creation of this ImageView from an Internal::CustomActor pointer.
275 * @param[in] internal A pointer to the internal CustomActor.
277 DALI_INTERNAL ImageView( Dali::Internal::CustomActor* internal );
284 } // namespace Toolkit
288 #endif // __DALI_TOOLKIT_IMAGE_VIEW_H__