87cf36d3504ca482045cb14ff78bbf2cc5d8ad44
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / controls / visual-factory / visual.h
1 #ifndef __DALI_TOOLKIT_CONTROL_RENDERER_H__
2 #define __DALI_TOOLKIT_CONTROL_RENDERER_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/actors/actor.h>
23
24 namespace Dali
25 {
26
27 namespace Toolkit
28 {
29
30 namespace Internal DALI_INTERNAL
31 {
32 class Visual;
33 }
34
35 /**
36  * @brief Visual provides renderer for rendering the controls. A control may have multiple ControlRenders.
37  *
38  * Visuals reuses geometry, shader etc. across controls and manages the renderer and texture sets to exist only when control is on-stage.
39  * It also responds to actor size and color change, and provides the clipping at the renderer level.
40  * Note: The control renderer responds to the the Actor::COLOR by blending it with the 'Multiply' operator.
41  */
42 class DALI_IMPORT_API Visual : public BaseHandle
43 {
44 public:
45
46   /**
47    * @brief Create an empty Visual Handle
48    */
49   Visual();
50
51   /**
52    * @brief Destructor
53    *
54    * This is non-virtual since derived Handle types must not contain data or virtual methods.
55    */
56   ~Visual();
57
58   /**
59    * @brief This copy constructor is required for (smart) pointer semantics.
60    *
61    * @param[in] handle A reference to the copied handle.
62    */
63   Visual( const Visual& handle );
64
65   /**
66    * @brief This assignment operator is required for (smart) pointer semantics.
67    *
68    * @param [in] handle  A reference to the copied handle.
69    * @return A reference to this.
70    */
71   Visual& operator=( const Visual& handle );
72
73   /**
74    * @brief Set the size of the painting area.
75    *
76    * @param[in] size The size of the painting area.
77    */
78   void SetSize( const Vector2& size );
79
80   /**
81    * @brief Get the size of the painting area.
82    *
83    * @return The size of the renderer's painting area.
84    */
85   const Vector2& GetSize() const;
86
87   /**
88    * @brief Return the natural size of the renderer.
89    *
90    * Deriving classes stipulate the natural size and by default a renderer has a ZERO natural size.
91    *
92    * @param[out] naturalSize The renderer's natural size
93    */
94   void GetNaturalSize( Vector2& naturalSize ) const;
95
96   /**
97    * @brief Set the depth index of this renderer.
98    *
99    * Depth-index controls draw-order for overlapping renderers.
100    * Renderer with higher depth indices are rendered in front of other renderer with smaller values
101    *
102    * @param[in] index The depth index of this renderer.
103    */
104   void SetDepthIndex( float index );
105
106   /**
107    * @brief Get the depth index of this renderer
108    *
109    * @return The depth index of this renderer.
110    */
111   float GetDepthIndex() const;
112
113   /**
114    * @brief Renderer only exists when control is on stage.
115    *
116    * This function should be called when the control put on stage.
117    *
118    * @param[in] actor The actor applying this renderer.
119    * @post SetOffStage should be called with the same actor when the control is put off stage otherwise memory will be leaked
120    */
121   void SetOnStage( Actor& actor );
122
123   /**
124    * @brief Renderer is destroyed when control is off stage.
125    *
126    * This function should be called when the control removes from stage
127    *
128    * @param[in] actor The actor applying this renderer.
129    */
130   void SetOffStage( Actor& actor );
131
132   /**
133    * @brief Remove the renderer from actor and reset the control renderer self.
134    *
135    * This function can be called with an empty handle. If the control renderer is empty, do nothing.
136    *
137    * @param[in] actor The actor to be set off stage.
138    */
139   void RemoveAndReset( Actor& actor );
140
141   /**
142    * @brief Create the property map representing this renderer.
143    *
144    * @param[out] map The renderer property map.
145    */
146   void CreatePropertyMap( Property::Map& map ) const;
147
148 public: // Not intended for application developers
149
150   explicit DALI_INTERNAL Visual(Internal::Visual *impl);
151
152 };
153
154 } // namespace Toolkit
155
156 } // namespace Dali
157
158 #endif /*__DALI_TOOLKIT_CONTROL_RENDERER_H__*/