f3b5416b8997ca5332d05bbaffbd8c3216a1cca1
[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
58   /**
59    * @brief An enumeration of properties belonging to the ImageView class.
60    */
61   struct Property
62   {
63     enum
64     {
65       IMAGE = PROPERTY_START_INDEX, ///< name "image", @see SetImage(), type string if it is a url, map otherwise
66     };
67   };
68
69 public:
70
71   /**
72    * @brief Create an uninitialized ImageView.
73    */
74   ImageView();
75
76   /**
77    * @brief Create an initialized ImageView.
78    *
79    * @return A handle to a newly allocated Dali ImageView.
80    *
81    * @note ImageView will not display anything.
82    */
83   static ImageView New();
84
85   /**
86    * @brief Create an initialized ImageView from an Image.
87    *
88    * If the handle is empty, ImageView will not display anything.
89    *
90    * @param[in] image The Image to display.
91    * @return A handle to a newly allocated ImageView.
92    */
93   static ImageView New( Image image );
94
95   /**
96    * @brief Create an initialized ImageView from an Image resource URL
97    *
98    * If the string is empty, ImageView will not display anything.
99    *
100    * @param[in] url The url of the image resource to display.
101    * @return A handle to a newly allocated ImageView.
102    */
103   static ImageView New( const std::string& url );
104
105   /**
106    * @brief Create an initialized ImageView from an Image resource URL
107    *
108    * If the string is empty, ImageView will not display anything.
109    *
110    * @since DALi 1.1.10
111    *
112    * @param[in] url The url of the image resource to display.
113    * @param [in] size The width and height to fit the loaded image to.
114    * @return A handle to a newly allocated ImageView.
115    *
116    * @note A valid size is preferable for efficiency.
117    *       However, do not set a size that is bigger than the actual image size, as up-scaling is not available.
118    *       The content of the area not covered by the actual image is undefined and will not be cleared.
119    */
120   static ImageView New( const std::string& url, ImageDimensions size );
121
122   /**
123    * @brief Destructor
124    *
125    * This is non-virtual since derived Handle types must not contain data or virtual methods.
126    */
127   ~ImageView();
128
129   /**
130    * @brief Copy constructor.
131    *
132    * @param[in] imageView ImageView to copy. The copied ImageView will point at the same implementation
133    */
134   ImageView( const ImageView& imageView );
135
136   /**
137    * @brief Assignment operator.
138    *
139    * @param[in] imageView The ImageView to assign from.
140    * @return The updated ImageView.
141    */
142   ImageView& operator=( const ImageView& imageView );
143
144   /**
145    * @brief Downcast an Object handle to ImageView.
146    *
147    * If handle points to a ImageView the downcast produces valid
148    * handle. If not the returned handle is left uninitialized.
149    *
150    * @param[in] handle Handle to an object
151    * @return handle to a ImageView or an uninitialized handle
152    */
153   static ImageView DownCast( BaseHandle handle );
154
155   /**
156    * @brief Sets this ImageView from an Image
157    *
158    * If the handle is empty, ImageView will display nothing
159    * @param[in] image The Image to display.
160    */
161   void SetImage( Image image );
162
163   /**
164    * @brief Sets this ImageView from an Image URL
165    *
166    * If the URL is empty, ImageView will not display anything.
167    *
168    * @since DALi 1.1.4
169    *
170    * @param[in] url The Image resource to display.
171    */
172   void SetImage( const std::string& url );
173
174   /**
175    * @brief Sets this ImageView from an Image URL
176    *
177    * If the URL is empty, ImageView will not display anything.
178    *
179    * @since DALi 1.1.10
180    *
181    * @param[in] url A URL to the image resource to display.
182    * @param [in] size The width and height to fit the loaded image to.
183    */
184   void SetImage( const std::string& url, ImageDimensions size );
185
186   /**
187    * @deprecated Gets the Image
188    *
189    * @return The Image currently set to this ImageView
190    */
191   Image GetImage() const;
192
193 public: // Not intended for application developers
194
195   /**
196    * @brief Creates a handle using the Toolkit::Internal implementation.
197    *
198    * @param[in]  implementation  The ImageView implementation.
199    */
200   DALI_INTERNAL ImageView( Internal::ImageView& implementation );
201
202   /**
203    * @brief Allows the creation of this ImageView from an Internal::CustomActor pointer.
204    *
205    * @param[in]  internal  A pointer to the internal CustomActor.
206    */
207   DALI_INTERNAL ImageView( Dali::Internal::CustomActor* internal );
208
209 };
210
211 /**
212  * @}
213  */
214 } // namespace Toolkit
215
216 } // namespace Dali
217
218 #endif // __DALI_TOOLKIT_IMAGE_VIEW_H__