[dali_1.1.18] Merge branch 'devel/master'
[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  *
44  * @brief ImageView is a class for displaying an Image.
45  */
46 class DALI_IMPORT_API ImageView : public Control
47 {
48 public:
49   /**
50    * @brief The start and end property ranges for this control.
51    */
52   enum PropertyRange
53   {
54     PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1,
55     PROPERTY_END_INDEX =   PROPERTY_START_INDEX + 1000,              ///< Reserve property indices
56
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
59   };
60
61   /**
62    * @brief An enumeration of properties belonging to the ImageView class.
63    */
64   struct Property
65   {
66     enum
67     {
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.
72
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].
75     };
76   };
77
78 public:
79
80   /**
81    * @brief Create an uninitialized ImageView.
82    */
83   ImageView();
84
85   /**
86    * @brief Create an initialized ImageView.
87    *
88    * @return A handle to a newly allocated Dali ImageView.
89    *
90    * @note ImageView will not display anything.
91    */
92   static ImageView New();
93
94   /**
95    * @brief Create an initialized ImageView from an Image.
96    *
97    * If the handle is empty, ImageView will not display anything.
98    *
99    * @param[in] image The Image to display.
100    * @return A handle to a newly allocated ImageView.
101    */
102   static ImageView New( Image image );
103
104   /**
105    * @brief Create an initialized ImageView from an Image resource URL
106    *
107    * If the string is empty, ImageView will not display anything.
108    *
109    * @param[in] url The url of the image resource to display.
110    * @return A handle to a newly allocated ImageView.
111    */
112   static ImageView New( const std::string& url );
113
114   /**
115    * @brief Create an initialized ImageView from an Image resource URL
116    *
117    * If the string is empty, ImageView will not display anything.
118    *
119    * @since DALi 1.1.10
120    *
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.
124    *
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.
128    */
129   static ImageView New( const std::string& url, ImageDimensions size );
130
131   /**
132    * @brief Destructor
133    *
134    * This is non-virtual since derived Handle types must not contain data or virtual methods.
135    */
136   ~ImageView();
137
138   /**
139    * @brief Copy constructor.
140    *
141    * @param[in] imageView ImageView to copy. The copied ImageView will point at the same implementation
142    */
143   ImageView( const ImageView& imageView );
144
145   /**
146    * @brief Assignment operator.
147    *
148    * @param[in] imageView The ImageView to assign from.
149    * @return The updated ImageView.
150    */
151   ImageView& operator=( const ImageView& imageView );
152
153   /**
154    * @brief Downcast an Object handle to ImageView.
155    *
156    * If handle points to a ImageView the downcast produces valid
157    * handle. If not the returned handle is left uninitialized.
158    *
159    * @param[in] handle Handle to an object
160    * @return handle to a ImageView or an uninitialized handle
161    */
162   static ImageView DownCast( BaseHandle handle );
163
164   /**
165    * @brief Sets this ImageView from an Image
166    *
167    * If the handle is empty, ImageView will display nothing
168    * @param[in] image The Image to display.
169    */
170   void SetImage( Image image );
171
172   /**
173    * @brief Sets this ImageView from an Image URL
174    *
175    * If the URL is empty, ImageView will not display anything.
176    *
177    * @since DALi 1.1.4
178    *
179    * @param[in] url The Image resource to display.
180    */
181   void SetImage( const std::string& url );
182
183   /**
184    * @brief Sets this ImageView from an Image URL
185    *
186    * If the URL is empty, ImageView will not display anything.
187    *
188    * @since DALi 1.1.10
189    *
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.
192    */
193   void SetImage( const std::string& url, ImageDimensions size );
194
195   /**
196    * @deprecated Gets the Image
197    *
198    * @return The Image currently set to this ImageView
199    */
200   Image GetImage() const;
201
202 public: // Not intended for application developers
203
204   /**
205    * @brief Creates a handle using the Toolkit::Internal implementation.
206    *
207    * @param[in]  implementation  The ImageView implementation.
208    */
209   DALI_INTERNAL ImageView( Internal::ImageView& implementation );
210
211   /**
212    * @brief Allows the creation of this ImageView from an Internal::CustomActor pointer.
213    *
214    * @param[in]  internal  A pointer to the internal CustomActor.
215    */
216   DALI_INTERNAL ImageView( Dali::Internal::CustomActor* internal );
217
218 };
219
220 /**
221  * @}
222  */
223 } // namespace Toolkit
224
225 } // namespace Dali
226
227 #endif // __DALI_TOOLKIT_IMAGE_VIEW_H__