Apply the new doxygen tagging rule for @DEPRECATED
[platform/core/uifw/dali-core.git] / dali / public-api / images / nine-patch-image.h
1 #ifndef __DALI_NINE_PATCH_IMAGE_H__
2 #define __DALI_NINE_PATCH_IMAGE_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/public-api/images/resource-image.h>
23 #include <dali/public-api/images/buffer-image.h>
24 #include <dali/public-api/math/rect.h>
25
26 namespace Dali
27 {
28 /**
29  * @addtogroup dali_core_images
30  * @{
31  */
32
33 namespace Internal DALI_INTERNAL
34 {
35 class NinePatchImage;
36 }
37
38 /**
39  * @brief NinePatchImage represents a stretchable image resource
40  *
41  * It contains a bitmap that is synchronously loaded from the file system that contains
42  * a 9 patch border - a 1 pixel border that describes the stretch borders and the child
43  * area.
44  *
45  * The class offers an API to read the stretch area and child area, but it does not
46  * remove the border from it's bitmap. An API can be used to obtain a BufferImage with
47  * the border removed.
48  *
49  * Adding this image to an ImageActor using an Image handle will automatically convert
50  * to use the cropped BufferImage - if you don't retain a handle to this object, it will
51  * be automatically destroyed.
52  * @SINCE_1_0.0
53  */
54 class DALI_IMPORT_API NinePatchImage : public ResourceImage
55 {
56 public:
57   typedef Vector< Uint16Pair > StretchRanges;
58
59 public:
60   /**
61    * @brief Constructor which creates an uninitialized NinePatchImage object.
62    *
63    * Use Image::New(...) to create an initialised object.
64    * @SINCE_1_0.0
65    */
66   NinePatchImage();
67
68   /**
69    * @brief Create a new NinePatchImage.
70    *
71    * A pixel buffer for image data is allocated and loaded from the filesystem.
72    * Dali has ownership of the buffer.
73    * @note: default resource management policies are Immediate and Never
74    *
75    * @SINCE_1_0.0
76    * @param [in] filename    File to load synchronously into buffer
77    * @return a handle to a new instance of NinePatchImage
78    */
79   static NinePatchImage New( const std::string& filename );
80
81   /**
82    * @brief Downcast an Object handle to NinePatchImage.
83    *
84    * If handle points to a NinePatchImage the downcast produces valid
85    * handle. If not the returned handle is left uninitialized.
86    *
87    * @SINCE_1_0.0
88    * @param[in] handle to An object
89    * @return handle to a NinePatchImage or an uninitialized handle
90    */
91   static NinePatchImage DownCast( BaseHandle handle );
92
93   /**
94    * @brief Destructor
95    *
96    * This is non-virtual since derived Handle types must not contain data or virtual methods.
97    * @SINCE_1_0.0
98    */
99   ~NinePatchImage();
100
101   /**
102    * @brief This copy constructor is required for (smart) pointer semantics.
103    *
104    * @SINCE_1_0.0
105    * @param [in] handle A reference to the copied handle
106    */
107   NinePatchImage(const NinePatchImage& handle);
108
109   /**
110    * @brief This assignment operator is required for (smart) pointer semantics.
111    *
112    * @SINCE_1_0.0
113    * @param [in] rhs  A reference to the copied handle
114    * @return A reference to this
115    */
116   NinePatchImage& operator=(const NinePatchImage& rhs);
117
118   /**
119    * @DEPRECATED_1_1.4. Use GetStretchPixelsX and GetStretchPixelsY instead.
120    *
121    * @brief Get the stretch borders
122    *
123    * @SINCE_1_0.0
124    * @return The border in pixels from the left, top, right, and bottom of the image respectively.
125    */
126   Vector4 GetStretchBorders();
127
128   /**
129    * @brief Retrieves the horizontal stretch pixel ranges in the cropped image space
130    *
131    * @SINCE_1_1.4
132    * @return the horizontal stretch pixel ranges in the cropped image space
133    */
134   const StretchRanges& GetStretchPixelsX();
135
136   /**
137    * @brief Retrieves the vertical stretch pixel ranges in the cropped image space
138    *
139    * @SINCE_1_1.4
140    * @return the vertical stretch pixel ranges in the cropped image space
141    */
142   const StretchRanges& GetStretchPixelsY();
143
144   /**
145    * @brief Get the child rectangle
146    *
147    * @SINCE_1_0.0
148    * @return the position and size of the child rectangle
149    */
150   Rect<int> GetChildRectangle();
151
152   /**
153    * @brief Creates a buffer image from the bitmap with the 1 pixel border cropped off.
154    *
155    * This does not change the internal bitmap.
156    *
157    * @SINCE_1_0.0
158    * @return The cropped BufferImage
159    */
160   BufferImage CreateCroppedBufferImage();
161
162   /**
163    * @brief Helper method to determine if the filename indicates that the image has a 9 patch or n patch border.
164    *
165    * @SINCE_1_1.4
166    * @param [in] url The URL of the image file.
167    * @return true if it is a 9 patch or n patch image
168    */
169   static bool IsNinePatchUrl( const std::string& url );
170
171 public: // Not intended for application developers
172
173   explicit DALI_INTERNAL NinePatchImage(Internal::NinePatchImage*);
174 };
175
176 /**
177  * @}
178  */
179 } // namespace Dali
180
181 #endif // __DALI_NINE_PATCH_IMAGE_H__