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
71 PRE_MULTIPLIED_ALPHA, ///< name "preMultipliedAlpha", @since DALi 1.1.18 type Boolean @pre image must be initialized.
73 // Animatable properties
74 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].
81 * @brief Create an uninitialized ImageView.
86 * @brief Create an initialized ImageView.
88 * @return A handle to a newly allocated Dali ImageView.
90 * @note ImageView will not display anything.
92 static ImageView New();
95 * @brief Create an initialized ImageView from an Image.
97 * If the handle is empty, ImageView will not display anything.
99 * @param[in] image The Image to display.
100 * @return A handle to a newly allocated ImageView.
102 static ImageView New( Image image );
105 * @brief Create an initialized ImageView from an Image resource URL
107 * If the string is empty, ImageView will not display anything.
109 * @param[in] url The url of the image resource to display.
110 * @return A handle to a newly allocated ImageView.
112 static ImageView New( const std::string& url );
115 * @brief Create an initialized ImageView from an Image resource URL
117 * If the string is empty, ImageView will not display anything.
121 * @param[in] url The url of the image resource to display.
122 * @param [in] size The width and height to fit the loaded image to.
123 * @return A handle to a newly allocated ImageView.
125 * @note A valid size is preferable for efficiency.
126 * However, do not set a size that is bigger than the actual image size, as up-scaling is not available.
127 * The content of the area not covered by the actual image is undefined and will not be cleared.
129 static ImageView New( const std::string& url, ImageDimensions size );
134 * This is non-virtual since derived Handle types must not contain data or virtual methods.
139 * @brief Copy constructor.
141 * @param[in] imageView ImageView to copy. The copied ImageView will point at the same implementation
143 ImageView( const ImageView& imageView );
146 * @brief Assignment operator.
148 * @param[in] imageView The ImageView to assign from.
149 * @return The updated ImageView.
151 ImageView& operator=( const ImageView& imageView );
154 * @brief Downcast an Object handle to ImageView.
156 * If handle points to a ImageView the downcast produces valid
157 * handle. If not the returned handle is left uninitialized.
159 * @param[in] handle Handle to an object
160 * @return handle to a ImageView or an uninitialized handle
162 static ImageView DownCast( BaseHandle handle );
165 * @brief Sets this ImageView from an Image
167 * If the handle is empty, ImageView will display nothing
168 * @param[in] image The Image to display.
170 void SetImage( Image image );
173 * @brief Sets this ImageView from an Image URL
175 * If the URL is empty, ImageView will not display anything.
179 * @param[in] url The Image resource to display.
181 void SetImage( const std::string& url );
184 * @brief Sets this ImageView from an Image URL
186 * If the URL is empty, ImageView will not display anything.
190 * @param[in] url A URL to the image resource to display.
191 * @param [in] size The width and height to fit the loaded image to.
193 void SetImage( const std::string& url, ImageDimensions size );
196 * @deprecated Gets the Image
198 * @return The Image currently set to this ImageView
200 Image GetImage() const;
202 public: // Not intended for application developers
205 * @brief Creates a handle using the Toolkit::Internal implementation.
207 * @param[in] implementation The ImageView implementation.
209 DALI_INTERNAL ImageView( Internal::ImageView& implementation );
212 * @brief Allows the creation of this ImageView from an Internal::CustomActor pointer.
214 * @param[in] internal A pointer to the internal CustomActor.
216 DALI_INTERNAL ImageView( Dali::Internal::CustomActor* internal );
223 } // namespace Toolkit
227 #endif // __DALI_TOOLKIT_IMAGE_VIEW_H__