Merge "Changed ImageView to utilise ImageRenderer." into devel/master
[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  * 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] color The color to be rendered.
113    * @return Whether a new internal control renderer is created.
114    */
115   bool ResetRenderer( ControlRenderer& renderer, const Vector4& color );
116
117   /**
118    * @brief Request the control renderer to render the image.
119    *
120    * @param[in] image The image to be rendered.
121    * @return The pointer pointing to the control renderer
122    */
123   ControlRenderer GetControlRenderer( const Image& image );
124
125   /**
126    * @brief Request the current control renderer to render the given image
127    *
128    * if the current renderer is a handle to an internal image renderer, set this image to it,
129    * else the renderer would be a handle to a newly created internal image renderer.
130    *
131    * @param[in] renderer The ControlRenderer to reset
132    * @param[in] image The Image to be rendered.
133    * @return Whether a new internal control renderer is created.
134    */
135   bool ResetRenderer( ControlRenderer& renderer, const Image& image );
136
137   /**
138    * @brief Request the control renderer to render the given resource at the url.
139    *
140    * @param[in] url The URL to the resource to be rendered.
141    * @return The pointer pointing to the control renderer
142    */
143   ControlRenderer GetControlRenderer( const std::string& url );
144
145   /**
146    * @brief Request the current control renderer to render the given resource at the url
147    *
148    * if the current renderer is a handle to an internal image renderer, set this image to it,
149    * else the renderer would be a handle to a newly created internal image renderer.
150    *
151    * @param[in] renderer The ControlRenderer to reset
152    * @param[in] url The URL to the resource to be rendered.
153    * @return Whether a new internal control renderer is created.
154    */
155   bool ResetRenderer( ControlRenderer& renderer, const std::string& url );
156
157 private:
158
159   explicit DALI_INTERNAL RendererFactory(Internal::RendererFactory *impl);
160
161 };
162
163 } // namespace Toolkit
164
165 } // namespace Dali
166
167 #endif /* __DALI_TOOLKIT_RENDERER_FACTORY_H__ */