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
44 * @brief ImageView is a class for displaying an Image.
46 class DALI_IMPORT_API ImageView : public Control
50 * @brief The start and end property ranges for this control.
54 PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1,
55 PROPERTY_END_INDEX = PROPERTY_START_INDEX + 1000, ///< Reserve property indices
57 ANIMATABLE_PROPERTY_START_INDEX = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX, ///< @since DALi 1.1.18
58 ANIMATABLE_PROPERTY_END_INDEX = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1000 ///< Reserve animatable property indices, @since DALi 1.1.18
62 * @brief An enumeration of properties belonging to the ImageView class.
68 // Event side properties
69 RESOURCE_URL = PROPERTY_START_INDEX, ///< name "resourceUrl", @deprecated DALi 1.1.16 Use IMAGE instead. type string
70 IMAGE, ///< name "image", @see SetImage(), type string if it is a url, map otherwise
72 // Animatable properties
73 PIXEL_AREA = ANIMATABLE_PROPERTY_START_INDEX, ///< name "pixelArea", @since DALi 1.1.18 type Vector4, Pixel area is a relative value with the whole image area as [0.0, 0.0, 1.0, 1.0].
80 * @brief Create an uninitialized ImageView.
85 * @brief Create an initialized ImageView.
87 * @return A handle to a newly allocated Dali ImageView.
89 * @note ImageView will not display anything.
91 static ImageView New();
94 * @brief Create an initialized ImageView from an Image.
96 * If the handle is empty, ImageView will not display anything.
98 * @param[in] image The Image to display.
99 * @return A handle to a newly allocated ImageView.
101 static ImageView New( Image image );
104 * @brief Create an initialized ImageView from an Image resource URL
106 * If the string is empty, ImageView will not display anything.
108 * @param[in] url The url of the image resource to display.
109 * @return A handle to a newly allocated ImageView.
111 static ImageView New( const std::string& url );
114 * @brief Create an initialized ImageView from an Image resource URL
116 * If the string is empty, ImageView will not display anything.
120 * @param[in] url The url of the image resource to display.
121 * @param [in] size The width and height to fit the loaded image to.
122 * @return A handle to a newly allocated ImageView.
124 * @note A valid size is preferable for efficiency.
125 * However, do not set a size that is bigger than the actual image size, as up-scaling is not available.
126 * The content of the area not covered by the actual image is undefined and will not be cleared.
128 static ImageView New( const std::string& url, ImageDimensions size );
133 * This is non-virtual since derived Handle types must not contain data or virtual methods.
138 * @brief Copy constructor.
140 * @param[in] imageView ImageView to copy. The copied ImageView will point at the same implementation
142 ImageView( const ImageView& imageView );
145 * @brief Assignment operator.
147 * @param[in] imageView The ImageView to assign from.
148 * @return The updated ImageView.
150 ImageView& operator=( const ImageView& imageView );
153 * @brief Downcast an Object handle to ImageView.
155 * If handle points to a ImageView the downcast produces valid
156 * handle. If not the returned handle is left uninitialized.
158 * @param[in] handle Handle to an object
159 * @return handle to a ImageView or an uninitialized handle
161 static ImageView DownCast( BaseHandle handle );
164 * @brief Sets this ImageView from an Image
166 * If the handle is empty, ImageView will display nothing
167 * @param[in] image The Image to display.
169 void SetImage( Image image );
172 * @brief Sets this ImageView from an Image URL
174 * If the URL is empty, ImageView will not display anything.
178 * @param[in] url The Image resource to display.
180 void SetImage( const std::string& url );
183 * @brief Sets this ImageView from an Image URL
185 * If the URL is empty, ImageView will not display anything.
189 * @param[in] url A URL to the image resource to display.
190 * @param [in] size The width and height to fit the loaded image to.
192 void SetImage( const std::string& url, ImageDimensions size );
195 * @deprecated Gets the Image
197 * @return The Image currently set to this ImageView
199 Image GetImage() const;
201 public: // Not intended for application developers
204 * @brief Creates a handle using the Toolkit::Internal implementation.
206 * @param[in] implementation The ImageView implementation.
208 DALI_INTERNAL ImageView( Internal::ImageView& implementation );
211 * @brief Allows the creation of this ImageView from an Internal::CustomActor pointer.
213 * @param[in] internal A pointer to the internal CustomActor.
215 DALI_INTERNAL ImageView( Dali::Internal::CustomActor* internal );
222 } // namespace Toolkit
226 #endif // __DALI_TOOLKIT_IMAGE_VIEW_H__