cfa2da7fd169f071e2433c318086dadf545561dd
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / renderers / control-renderer-impl.h
1 #ifndef __DALI_TOOLKIT_INTERNAL_CONTROL_RENDERER_H__
2 #define __DALI_TOOLKIT_INTERNAL_CONTROL_RENDERER_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
22 // EXTERNAL INCLUDES
23 #include <dali/public-api/object/base-object.h>
24
25 #include <dali-toolkit/devel-api/controls/renderer-factory/renderer-factory.h>
26 #include <dali-toolkit/devel-api/controls/renderer-factory/control-renderer.h>
27
28 namespace Dali
29 {
30
31 namespace Toolkit
32 {
33
34 namespace Internal
35 {
36
37 class RendererFactoryCache;
38
39 /**
40  * Base class for all Control rendering logic. A control may have multiple control renderers.
41  *
42  * Note: The control renderer responds to the the Actor::COLOR by blending it with the 'Multiply' operator.
43  */
44 class ControlRenderer : public BaseObject
45 {
46 public:
47
48   /**
49    * Initialisation of the renderer, this API should only called by the RendererFactory:
50    *  request the geometry and shader from the cache, if not available, create and save to the cache for sharing;
51    *  record the property values.
52    *
53    * @param[in] factoryCache A pointer pointing to the RendererFactoryCache object
54    * @param[in] propertyMap The properties for the requested ControlRenderer object.
55    */
56   virtual void Initialize( RendererFactoryCache& factoryCache, const Property::Map& propertyMap ) = 0;
57
58   /**
59    * @copydoc Toolkit::ControlRenderer::SetSize
60    */
61   virtual void SetSize( const Vector2& size );
62
63   /**
64    * @copydoc Toolkit::ControlRenderer::SetCipRect
65    */
66   virtual void SetClipRect( const Rect<int>& clipRect );
67
68   /**
69    * @copydoc Toolkit::ControlRenderer::SetOffset
70    */
71   virtual void SetOffset( const Vector2& offset );
72
73   /**
74    * @copydoc Toolkit::ControlRenderer::SetDepthIndex
75    */
76   void SetDepthIndex( float index );
77
78   /**
79    * @copydoc Toolkit::ControlRenderer::SetOnStage
80    */
81   virtual void SetOnStage( Actor& actor );
82
83   /**
84    * @copydoc Toolkit::ControlRenderer::SetOffStage
85    */
86   void SetOffStage( Actor& actor );
87
88 protected:
89
90   /**
91    * @brief Constructor.
92    */
93   ControlRenderer();
94
95   /**
96    * @brief A reference counted object may only be deleted by calling Unreference().
97    */
98   virtual ~ControlRenderer();
99
100 private:
101
102   // Undefined
103   ControlRenderer( const ControlRenderer& renderer );
104
105   // Undefined
106   ControlRenderer& operator=( const ControlRenderer& renderer );
107
108 protected:
109
110   struct Impl;
111   Impl* mImpl;
112 };
113
114 } // namespace Internal
115
116 inline const Internal::ControlRenderer& GetImplementation(const Toolkit::ControlRenderer& renderer)
117 {
118   DALI_ASSERT_ALWAYS( renderer && "ControlRenderer handle is empty" );
119
120   const BaseObject& handle = renderer.GetBaseObject();
121
122   return static_cast<const Internal::ControlRenderer&>(handle);
123 }
124
125 inline Internal::ControlRenderer& GetImplementation(Toolkit::ControlRenderer& renderer)
126 {
127   DALI_ASSERT_ALWAYS( renderer && "ControlRenderer handle is empty" );
128
129   BaseObject& handle = renderer.GetBaseObject();
130
131   return static_cast<Internal::ControlRenderer&>(handle);
132 }
133
134 } // namespace Toolkit
135
136 } // namespace Dali
137
138 #endif /* __DALI_TOOLKIT_INTERNAL_CONTROL_RENDERER_H___ */