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