Merge "Automatic image atlasing" into 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
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   static ImageView New();
82
83   /**
84    * @brief Create an initialized ImageView from an Image.
85    *
86    * If the handle is empty, ImageView will display nothing
87    * @param[in] image The Image to display.
88    * @return A handle to a newly allocated ImageView.
89    */
90   static ImageView New( Image image );
91
92   /**
93    * @brief Create an initialized ImageView from an Image resource url
94    *
95    * @note A valid size is preferable for efficiency.
96    *       However, do not set size that is bigger than the actual image size, as the up-scaling is not available,
97    *       the content of the area not covered by actual image is undefined, it will not be cleared.
98    *
99    * If the string is empty, ImageView will display nothing
100    * @param[in] url The url of the image resource to display.
101    * @param [in] size The width and height to fit the loaded image to.
102    * @return A handle to a newly allocated ImageView.
103    */
104   static ImageView New( const std::string& url,
105                         ImageDimensions size = ImageDimensions() );
106
107   /**
108    * @brief Destructor
109    *
110    * This is non-virtual since derived Handle types must not contain data or virtual methods.
111    */
112   ~ImageView();
113
114   /**
115    * @brief Copy constructor.
116    *
117    * @param[in] imageView ImageView to copy. The copied ImageView will point at the same implementation
118    */
119   ImageView( const ImageView& imageView );
120
121   /**
122    * @brief Assignment operator.
123    *
124    * @param[in] imageView The ImageView to assign from.
125    * @return The updated ImageView.
126    */
127   ImageView& operator=( const ImageView& imageView );
128
129   /**
130    * @brief Downcast an Object handle to ImageView.
131    *
132    * If handle points to a ImageView the downcast produces valid
133    * handle. If not the returned handle is left uninitialized.
134    *
135    * @param[in] handle Handle to an object
136    * @return handle to a ImageView or an uninitialized handle
137    */
138   static ImageView DownCast( BaseHandle handle );
139
140   /**
141    * @brief Sets this ImageView from an Image
142    *
143    * If the handle is empty, ImageView will display nothing
144    * @param[in] image The Image to display.
145    */
146   void SetImage( Image image );
147
148   /**
149    * @brief Sets this ImageView from an Image url
150    *
151    * If the handle is empty, ImageView will display nothing
152    *
153    * @since DALi 1.1.4
154    *
155    * @param[in] url The Image resource to display.
156    * @param [in] size The width and height to fit the loaded image to.
157    */
158   void SetImage( const std::string& url,
159                  ImageDimensions size = ImageDimensions() );
160
161   /**
162    * @deprecated Gets the Image
163    *
164    * @return The Image currently set to this ImageView
165    */
166   Image GetImage() const;
167
168 public: // Not intended for application developers
169
170   /**
171    * @brief Creates a handle using the Toolkit::Internal implementation.
172    *
173    * @param[in]  implementation  The ImageView implementation.
174    */
175   DALI_INTERNAL ImageView( Internal::ImageView& implementation );
176
177   /**
178    * @brief Allows the creation of this ImageView from an Internal::CustomActor pointer.
179    *
180    * @param[in]  internal  A pointer to the internal CustomActor.
181    */
182   DALI_INTERNAL ImageView( Dali::Internal::CustomActor* internal );
183
184 };
185
186 /**
187  * @}
188  */
189 } // namespace Toolkit
190
191 } // namespace Dali
192
193 #endif // __DALI_TOOLKIT_IMAGE_VIEW_H__