CanvasRenderer:: Add Picture class
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / adaptor-framework / canvas-renderer-picture.h
1 #ifndef DALI_CANVAS_RENDERER_PICTURE_H
2 #define DALI_CANVAS_RENDERER_PICTURE_H
3
4 /*
5  * Copyright (c) 2021 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 // EXTERNAL INCLUDES
22 #include <dali/public-api/object/base-handle.h>
23
24 // INTERNAL INCLUDES
25 #include <dali/devel-api/adaptor-framework/canvas-renderer-drawable.h>
26 #include <dali/devel-api/adaptor-framework/canvas-renderer.h>
27 #include <dali/public-api/dali-adaptor-common.h>
28
29 namespace Dali
30 {
31 /**
32  * @addtogroup dali_adaptor_framework
33  * @{
34  */
35
36 namespace Internal DALI_INTERNAL
37 {
38 namespace Adaptor
39 {
40 class CanvasRenderer;
41 class Picture;
42 } // namespace Adaptor
43 } // namespace DALI_INTERNAL
44
45 /**
46  * @brief A class representing an image read in one of the supported formats: raw, svg, png and etc.
47  * Besides the methods inherited from the Drawable, it provides methods to load & draw images on the canvas.
48  */
49 class DALI_ADAPTOR_API CanvasRenderer::Picture : public CanvasRenderer::Drawable
50 {
51 public:
52   /**
53    * @brief Creates an initialized handle to a new CanvasRenderer::Picture.
54    *
55    * @return A handle to a newly allocated Picture
56    */
57   static Picture New();
58
59 public:
60   /**
61    * @brief Creates an empty handle.
62    * Use CanvasRenderer::Picture::New() to create an initialized object.
63    */
64   Picture();
65
66   /**
67    * @brief Destructor.
68    */
69   ~Picture();
70
71   /**
72    * @brief This copy constructor is required for (smart) pointer semantics.
73    *
74    * @param[in] handle A reference to the copied handle
75    */
76   Picture(const Picture& handle) = default;
77
78 public:
79   /**
80    * @brief Loads a picture data directly from a file.
81    * @param[in] url A path to the picture file.
82    * @return Returns True when it's successful. False otherwise.
83    */
84   bool Load(const std::string& url);
85
86   /**
87    * @brief Resize the picture content with the given size.
88    *
89    * Resize the picture content while keeping the default size aspect ratio.
90    * The scaling factor is established for each of dimensions and the smaller value is applied to both of them.
91    * @param[in] size A new size of the image in pixels.
92    * @return Returns True when it's successful. False otherwise.
93    */
94   bool SetSize(Vector2 size);
95
96   /**
97    * @brief Gets the size of the image.
98    * @return Returns The size of the image in pixels.
99    */
100   Vector2 GetSize() const;
101
102 public: // Not intended for application developers
103   /// @cond internal
104   /**
105    * @brief The constructor.
106    * @note  Not intended for application developers.
107    *
108    * @param[in] pointer A pointer to a newly allocated CanvasRenderer::Picture
109    */
110   explicit DALI_INTERNAL Picture(Internal::Adaptor::Picture* impl);
111   /// @endcond
112 };
113
114 /**
115  * @}
116  */
117 } // namespace Dali
118
119 #endif // DALI_CANVAS_RENDERER_PICTURE_H