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.
47 class DALI_IMPORT_API ImageView : public Control
51 * @brief The start and end property ranges for this control.
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
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
64 * @brief An enumeration of properties belonging to the ImageView class.
71 // Event side properties
74 * @DEPRECATED_1_1.16. Use IMAGE instead.
75 * @brief name "resourceUrl", type string
78 RESOURCE_URL = PROPERTY_START_INDEX,
80 * @brief name "image", type string if it is a url, map otherwise
85 * @brief name "preMultipliedAlpha", type Boolean
87 * @pre image must be initialized.
91 // Animatable properties
95 * @brief name "pixelArea", type Vector4
96 * @details Pixel area is a relative value with the whole image area as [0.0, 0.0, 1.0, 1.0].
99 PIXEL_AREA = ANIMATABLE_PROPERTY_START_INDEX,
106 * @brief Create an uninitialized ImageView.
112 * @brief Create an initialized ImageView.
115 * @return A handle to a newly allocated Dali ImageView.
117 * @note ImageView will not display anything.
119 static ImageView New();
122 * @brief Create an initialized ImageView from an Image.
124 * If the handle is empty, ImageView will not display anything.
127 * @param[in] image The Image to display.
128 * @return A handle to a newly allocated ImageView.
130 static ImageView New( Image image );
133 * @brief Create an initialized ImageView from an Image resource URL
135 * If the string is empty, ImageView will not display anything.
138 * @param[in] url The url of the image resource to display.
139 * @return A handle to a newly allocated ImageView.
141 static ImageView New( const std::string& url );
144 * @brief Create an initialized ImageView from an Image resource URL
146 * If the string is empty, ImageView will not display anything.
149 * @param[in] url The url of the image resource to display.
150 * @param [in] size The width and height to fit the loaded image to.
151 * @return A handle to a newly allocated ImageView.
153 * @note A valid size is preferable for efficiency.
154 * However, do not set a size that is bigger than the actual image size, as up-scaling is not available.
155 * The content of the area not covered by the actual image is undefined and will not be cleared.
157 static ImageView New( const std::string& url, ImageDimensions size );
162 * This is non-virtual since derived Handle types must not contain data or virtual methods.
168 * @brief Copy constructor.
171 * @param[in] imageView ImageView to copy. The copied ImageView will point at the same implementation
173 ImageView( const ImageView& imageView );
176 * @brief Assignment operator.
179 * @param[in] imageView The ImageView to assign from.
180 * @return The updated ImageView.
182 ImageView& operator=( const ImageView& imageView );
185 * @brief Downcast a handle to ImageView handle.
187 * If handle points to a ImageView the downcast produces valid
188 * handle. If not the returned handle is left uninitialized.
191 * @param[in] handle Handle to an object
192 * @return handle to a ImageView or an uninitialized handle
194 static ImageView DownCast( BaseHandle handle );
197 * @brief Sets this ImageView from an Image
199 * If the handle is empty, ImageView will display nothing
201 * @param[in] image The Image to display.
203 void SetImage( Image image );
206 * @brief Sets this ImageView from an Image URL
208 * If the URL is empty, ImageView will not display anything.
211 * @param[in] url The Image resource to display.
213 void SetImage( const std::string& url );
216 * @brief Sets this ImageView from an Image URL
218 * If the URL is empty, ImageView will not display anything.
221 * @param[in] url A URL to the image resource to display.
222 * @param [in] size The width and height to fit the loaded image to.
224 void SetImage( const std::string& url, ImageDimensions size );
228 * @brief Gets the Image
231 * @remarks Calls to this method should be avoided as this may return an empty handle if the image has not been created yet.
232 * @return The Image currently set to this ImageView
234 Image GetImage() const;
236 public: // Not intended for application developers
239 * @brief Creates a handle using the Toolkit::Internal implementation.
242 * @param[in] implementation The ImageView implementation.
244 DALI_INTERNAL ImageView( Internal::ImageView& implementation );
247 * @brief Allows the creation of this ImageView from an Internal::CustomActor pointer.
250 * @param[in] internal A pointer to the internal CustomActor.
252 DALI_INTERNAL ImageView( Dali::Internal::CustomActor* internal );
259 } // namespace Toolkit
263 #endif // __DALI_TOOLKIT_IMAGE_VIEW_H__