5d4052bdb2a9af5d19035040334e29645da5d9a3
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / controls / renderer-factory / renderer-factory.h
1 #ifndef __DALI_TOOLKIT_RENDERER_FACTORY_H__
2 #define __DALI_TOOLKIT_RENDERER_FACTORY_H__
3 /*
4  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20 // EXTERNAL INCLUDES
21 #include <dali/public-api/object/base-handle.h>
22 #include <dali/public-api/images/image-operations.h>
23
24 // INTERNAK INCLUDES
25 #include <dali-toolkit/devel-api/controls/renderer-factory/control-renderer.h>
26
27 namespace Dali
28 {
29 class Image;
30 class Vector4;
31
32 namespace Toolkit
33 {
34
35 namespace Internal DALI_INTERNAL
36 {
37 class RendererFactory;
38 }
39
40 /**
41  * @brief RendererFactory is a singleton object that provides and shares renderers for controls
42  *
43  * The renderer type is required in the property map for requesting a control renderer.
44  *
45  * | %Property Name           | Type             |
46  * |--------------------------|------------------|
47  * | rendererType             | STRING           |
48  */
49 class DALI_IMPORT_API RendererFactory : public BaseHandle
50 {
51 public:
52
53   /**
54    * @brief Create or retrieve RendererFactory singleton.
55    *
56    * @return A handle to the RendererFactory control.
57    */
58   static RendererFactory Get();
59
60   /**
61    * @brief Create a RendererFactory handle.
62    *
63    * Calling member functions with an uninitialised handle is not allowed.
64    */
65   RendererFactory();
66
67   /**
68    * @brief Destructor
69    *
70    * This is non-virtual since derived Handle types must not contain data or virtual methods.
71    */
72   ~RendererFactory();
73
74   /**
75    * @brief This copy constructor is required for (smart) pointer semantics.
76    *
77    * @param[in] handle A reference to the copied handle.
78    */
79   RendererFactory( const RendererFactory& handle );
80
81   /**
82    * @brief This assignment operator is required for (smart) pointer semantics.
83    *
84    * @param [in] handle  A reference to the copied handle.
85    * @return A reference to this.
86    */
87   RendererFactory& operator=( const RendererFactory& handle );
88
89   /**
90    * @brief Request the control renderer
91    *
92    * @param[in] propertyMap The map contains the properties required by the control renderer
93    *            Depends on the content of the map, different kind of renderer would be returned.
94    * @return The pointer pointing to control renderer
95    */
96   ControlRenderer GetControlRenderer( const Property::Map& propertyMap  );
97
98   /**
99    * @brief Request the control renderer to render the given color
100    *
101    * @param[in] color The color to be rendered
102    * @return The pointer pointing to the control renderer
103    */
104   ControlRenderer GetControlRenderer( const Vector4& color );
105
106   /**
107    * @brief Request the current control renderer to render the given color
108    *
109    * if the current renderer is a handle to an internal color renderer, set this color to it,
110    * else the renderer would be a handle to a newly created internal color renderer.
111    *
112    * @param[in] renderer The ControlRenderer to reset
113    * @param[in] actor The Actor the renderer is applied to if, empty if the renderer has not been applied to any Actor
114    * @param[in] color The color to be rendered.
115    */
116   void ResetRenderer( ControlRenderer& renderer, Actor& actor, const Vector4& color );
117
118   /**
119    * @brief Request the control renderer to renderer the border with the given size and color.
120    *
121    * @param[in] borderSize The size of the border. Border size is the same along all edges.
122    * @param[in] borderColor The color of the border.
123    * @return The pointer pointing to the control renderer
124    */
125   ControlRenderer GetControlRenderer( float borderSize, const Vector4& borderColor );
126
127   /**
128    * @brief Request the control renderer to render the image.
129    *
130    * @param[in] image The image to be rendered.
131    * @return The pointer pointing to the control renderer
132    */
133   ControlRenderer GetControlRenderer( const Image& image );
134
135   /**
136    * @brief Request the current control renderer to render the given image
137    *
138    * if the current renderer is a handle to an internal image renderer, set this image to it,
139    * else the renderer would be a handle to a newly created internal image renderer.
140    *
141    * @param[in] renderer The ControlRenderer to reset
142    * @param[in] actor The Actor the renderer is applied to if, empty if the renderer has not been applied to any Actor
143    * @param[in] image The Image to be rendered.
144    */
145   void ResetRenderer( ControlRenderer& renderer, Actor& actor, const Image& image );
146
147   /**
148    * @brief Request the control renderer to render the given resource at the url.
149    *
150    * @param[in] url The URL to the resource to be rendered.
151    * @param[in] size The width and height to fit the loaded image to.
152    * @return The pointer pointing to the control renderer
153    */
154   ControlRenderer GetControlRenderer( const std::string& url,
155                                       ImageDimensions size = ImageDimensions() );
156
157   /**
158    * @brief Request the current control renderer to render the given resource at the url
159    *
160    * if the current renderer is a handle to an internal image renderer, set this image to it,
161    * else the renderer would be a handle to a newly created internal image renderer.
162    *
163    * @param[in] renderer The ControlRenderer to reset
164    * @param[in] actor The Actor the renderer is applied to if, empty if the renderer has not been applied to any Actor
165    * @param[in] url The URL to the resource to be rendered.
166    * @param[in] size The width and height to fit the loaded image to.
167    */
168   void ResetRenderer( ControlRenderer& renderer, Actor& actor, const std::string& url,
169                       ImageDimensions size = ImageDimensions() );
170
171
172   /**
173    * @brief Request the current control renderer from the property map, merging the property map with the renderer
174    *
175    * if the current renderer is capable of merging with the property map the reset the renderer with the merged properties
176    * else the renderer would be a handle to a newly created internal renderer.
177    *
178    * @param[in] renderer The ControlRenderer to reset
179    * @param[in] actor The Actor the renderer is applied to if, empty if the renderer has not been applied to any Actor
180    * @param[in] propertyMap The map contains the properties required by the control renderer
181    *            Depends on the content of the map, different kind of renderer would be returned.
182    */
183   void ResetRenderer( ControlRenderer& renderer, Actor& actor, const Property::Map& propertyMap );
184
185 private:
186
187   explicit DALI_INTERNAL RendererFactory(Internal::RendererFactory *impl);
188
189 };
190
191 } // namespace Toolkit
192
193 } // namespace Dali
194
195 #endif /* __DALI_TOOLKIT_RENDERER_FACTORY_H__ */