Merge "Refactored ControlRenderer so that derived classes are responsible for the...
[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
23 // INTERNAK INCLUDES
24 #include <dali-toolkit/devel-api/controls/renderer-factory/control-renderer.h>
25
26 namespace Dali
27 {
28 class Image;
29 class Vector4;
30
31 namespace Toolkit
32 {
33
34 namespace Internal DALI_INTERNAL
35 {
36 class RendererFactory;
37 }
38
39 /**
40  * @brief RendererFactory is a singleton object that provides and shares renderers for controls
41  *
42  * The renderer type is required in the property map for requesting a control renderer.
43  *
44  * | %Property Name            | Type             |
45  * |---------------------------|------------------|
46  * | renderer-type             | STRING           |
47  */
48 class DALI_IMPORT_API RendererFactory : public BaseHandle
49 {
50 public:
51
52   /**
53    * @brief Create or retrieve RendererFactory singleton.
54    *
55    * @return A handle to the RendererFactory control.
56    */
57   static RendererFactory Get();
58
59   /**
60    * @brief Create a RendererFactory handle.
61    *
62    * Calling member functions with an uninitialised handle is not allowed.
63    */
64   RendererFactory();
65
66   /**
67    * @brief Destructor
68    *
69    * This is non-virtual since derived Handle types must not contain data or virtual methods.
70    */
71   ~RendererFactory();
72
73   /**
74    * @brief This copy constructor is required for (smart) pointer semantics.
75    *
76    * @param[in] handle A reference to the copied handle.
77    */
78   RendererFactory( const RendererFactory& handle );
79
80   /**
81    * @brief This assignment operator is required for (smart) pointer semantics.
82    *
83    * @param [in] handle  A reference to the copied handle.
84    * @return A reference to this.
85    */
86   RendererFactory& operator=( const RendererFactory& handle );
87
88   /**
89    * @brief Request the control renderer
90    *
91    * @param[in] propertyMap The map contains the properties required by the control renderer
92    *            Depends on the content of the map, different kind of renderer would be returned.
93    * @return The pointer pointing to control renderer
94    */
95   ControlRenderer GetControlRenderer( const Property::Map& propertyMap  );
96
97   /**
98    * @brief Request the control renderer to render the given color
99    *
100    * @param[in] color The color to be rendered
101    * @return The pointer pointing to the control renderer
102    */
103   ControlRenderer GetControlRenderer( const Vector4& color );
104
105   /**
106    * @brief Request the current control renderer to render the given color
107    *
108    * if the current renderer is a handle to an internal color renderer, set this color to it,
109    * else the renderer would be a handle to a newly created internal color renderer.
110    *
111    * @param[in] renderer The ControlRenderer to reset
112    * @param[in] actor The Actor the renderer is applied to if, empty if the renderer has not been applied to any Actor
113    * @param[in] color The color to be rendered.
114    */
115   void ResetRenderer( ControlRenderer& renderer, Actor& actor, const Vector4& color );
116
117   /**
118    * @brief Request the control renderer to renderer the border with the given size and color.
119    *
120    * @param[in] borderSize The size of the border. Border size is the same along all edges.
121    * @param[in] borderColor The color of the border.
122    * @return The pointer pointing to the control renderer
123    */
124   ControlRenderer GetControlRenderer( float borderSize, const Vector4& borderColor );
125
126   /**
127    * @brief Request the control renderer to render the image.
128    *
129    * @param[in] image The image to be rendered.
130    * @return The pointer pointing to the control renderer
131    */
132   ControlRenderer GetControlRenderer( const Image& image );
133
134   /**
135    * @brief Request the current control renderer to render the given image
136    *
137    * if the current renderer is a handle to an internal image renderer, set this image to it,
138    * else the renderer would be a handle to a newly created internal image renderer.
139    *
140    * @param[in] renderer The ControlRenderer to reset
141    * @param[in] actor The Actor the renderer is applied to if, empty if the renderer has not been applied to any Actor
142    * @param[in] image The Image to be rendered.
143    */
144   void ResetRenderer( ControlRenderer& renderer, Actor& actor, const Image& image );
145
146   /**
147    * @brief Request the control renderer to render the given resource at the url.
148    *
149    * @param[in] url The URL to the resource to be rendered.
150    * @return The pointer pointing to the control renderer
151    */
152   ControlRenderer GetControlRenderer( const std::string& url );
153
154   /**
155    * @brief Request the current control renderer to render the given resource at the url
156    *
157    * if the current renderer is a handle to an internal image renderer, set this image to it,
158    * else the renderer would be a handle to a newly created internal image renderer.
159    *
160    * @param[in] renderer The ControlRenderer to reset
161    * @param[in] actor The Actor the renderer is applied to if, empty if the renderer has not been applied to any Actor
162    * @param[in] url The URL to the resource to be rendered.
163    */
164   void ResetRenderer( ControlRenderer& renderer, Actor& actor, const std::string& url );
165
166
167   /**
168    * @brief Request the current control renderer from the property map, merging the property map with the renderer
169    *
170    * if the current renderer is capable of merging with the property map the reset the renderer with the merged properties
171    * else the renderer would be a handle to a newly created internal renderer.
172    *
173    * @param[in] renderer The ControlRenderer to reset
174    * @param[in] actor The Actor the renderer is applied to if, empty if the renderer has not been applied to any Actor
175    * @param[in] propertyMap The map contains the properties required by the control renderer
176    *            Depends on the content of the map, different kind of renderer would be returned.
177    */
178   void ResetRenderer( ControlRenderer& renderer, Actor& actor, const Property::Map& propertyMap );
179
180 private:
181
182   explicit DALI_INTERNAL RendererFactory(Internal::RendererFactory *impl);
183
184 };
185
186 } // namespace Toolkit
187
188 } // namespace Dali
189
190 #endif /* __DALI_TOOLKIT_RENDERER_FACTORY_H__ */