Removed SetOnStage/SetOffStage from visual-base.h
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / visual-factory / visual-base.h
1 #ifndef DALI_TOOLKIT_VISUAL_BASE_H
2 #define DALI_TOOLKIT_VISUAL_BASE_H
3 /*
4  * Copyright (c) 2016 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 namespace Visual
33 {
34 class Base;
35 }
36 }
37
38 namespace Visual
39 {
40 /**
41  * @brief A Visual provides a renderer for drawing a control component. A control may have multiple visuals.
42  *
43  * Visuals reuse geometry, shader etc. across controls. They ensure that the renderer and texture sets exist only when control is on-stage.
44  * Each visual also responds to actor size and color change, and provides clipping at the renderer level.
45  * Note: The visual responds to the the Actor::COLOR by blending it with the 'Multiply' operator.
46  *
47  * The following properties are optional, but can be supplied in the property map to Dali::Toolkit::VisualFactory::CreateVisual().
48  *
49  * | %Property Name          | Type             |
50  * |-------------------------|------------------|
51  * | customShader            | MAP              |
52  * | transform               | MAP              |
53  *
54  * where \b customShader is a map with at least one of the following properties:
55  * | %Property Name          | Type             | Required | Default | Description |
56  * |-------------------------|------------------|----------|---------|-------------|
57  * | vertexShader            | STRING           | No | "" | Vertex shader code|
58  * | fragmentShader          | STRING           | No | "" | Fragment shader code|
59  * | subdivideGridX          | INTEGER          | No | 1 | How to subdivide the grid along X |
60  * | subdivideGridY          | INTEGER          | No | 1 | How to subdivide the grid along Y |
61  * | shaderHints             | INTEGER or ARRAY of STRING | No | NONE | Bitmask of hints @sa Dali::Shader::Hint |
62  *
63  * and \b transform is a map with the following properties:
64  * | %Property Name          | Type             | Required | Default |Description |
65  * |-------------------------|------------------|----------|---------|------------|
66  * | offset                  | VECTOR2          | No | (0,0) | Offset of visual from origin |
67  * | size                    | VECTOR2          | No | (1,1) | size of visual |
68  * | origin                  | INTEGER or STRING | No | CENTER | origin of the visual @sa Dali::Toolkit::Align |
69  * | anchorPoint             | INTEGER or STRING | No | CENTER | anchor point of the visual @sa Dali::Toolkit::Align |
70  * | offsetSizeMode          | VECTOR4          | No | (0,0,0,0) | See below |
71  *
72  *
73  * offsetSizeMode describes whether the offset and the size are
74  * relative or absolute by using 0 or 1 respectively in the corresponding
75  * components (offsetSizeMode.xy for offset.xy; offsetSizeMode.zw for size.xy).
76  *
77  * Relative means that the component describes a factor of the parent control size;
78  * size.x = 1 means full width; size.y = 0.5 means half height.
79  *
80  * Absolute means that the component describes world units (equivalent to pixels)
81  *
82  */
83 class DALI_IMPORT_API Base : public BaseHandle
84 {
85 public:
86
87   /**
88    * @brief Create an empty Visual Handle
89    */
90   Base();
91
92   /**
93    * @brief Destructor
94    *
95    * This is non-virtual since derived Handle types must not contain data or virtual methods.
96    */
97   ~Base();
98
99   /**
100    * @brief This copy constructor is required for (smart) pointer semantics.
101    *
102    * @param[in] handle A reference to the copied handle.
103    */
104   Base( const Base& handle );
105
106   /**
107    * @brief This assignment operator is required for (smart) pointer semantics.
108    *
109    * @param [in] handle  A reference to the copied handle.
110    * @return A reference to this.
111    */
112   Base& operator=( const Base& handle );
113
114   /**
115    * @brief Set the name of the visual
116    *
117    * Used by the styling system to animate properties
118    * @param[in] name The name to give the visual
119    */
120   void SetName( const std::string& name );
121
122   /**
123    * @brief Get the name of the visual
124    *
125    * Used by the styling system to animate properties
126    * @return The name of the visual
127    */
128   const std::string& GetName();
129
130   /**
131    * @brief Set the size of the painting area.
132    *
133    * @param[in] size The size of the painting area.
134    */
135   void SetSize( const Vector2& size );
136
137   /**
138    * @brief Get the size of the painting area.
139    *
140    * @return The size of the visual's painting area.
141    */
142   const Vector2& GetSize() const;
143
144   /**
145    * @brief Returns the height for a given width.
146    *
147    * @param[in] width Width to use.
148    *
149    * @return The height based on the width.
150    */
151   float GetHeightForWidth( float width ) const;
152
153   /**
154    * @brief Return the natural size of the visual.
155    *
156    * Deriving classes stipulate the natural size and by default a visual has a ZERO natural size.
157    *
158    * @param[out] naturalSize The visual's natural size
159    */
160   void GetNaturalSize( Vector2& naturalSize );
161
162   /**
163    * @brief Set the depth index of this visual.
164    *
165    * Depth-index controls draw-order for overlapping visuals.
166    * Visuals with higher depth indices are rendered in front of other visual with smaller values
167    *
168    * @param[in] index The depth index of this visual.
169    */
170   void SetDepthIndex( float index );
171
172   /**
173    * @brief Get the depth index of this visual
174    *
175    * @return The depth index of this visual.
176    */
177   float GetDepthIndex() const;
178
179   /**
180    * @brief Remove the renderer from the actor and reset the visual self.
181    *
182    * This function can be called with an empty handle. If the visual is empty, this is a no-op.
183    *
184    * @param[in] actor The actor to be set off stage.
185    */
186   void RemoveAndReset( Actor& actor );
187
188   /**
189    * @brief Create the property map representing this visual.
190    *
191    * @param[out] map The visual property map.
192    */
193   void CreatePropertyMap( Dali::Property::Map& map ) const;
194
195   /**
196    * @brief Sets the value of an existing property.
197    *
198    * @param [in] index The index of the property.
199    * @param [in] propertyValue The new value of the property.
200    */
201   void SetProperty( Dali::Property::Index index, const Dali::Property::Value& propertyValue );
202
203   /**
204    * @brief Retrieves a property value.
205    *
206    * @param [in] index The index of the property.
207    *
208    * @return The property value.
209    */
210   Dali::Property::Value GetProperty( Dali::Property::Index index );
211
212 public: // Not intended for application developers
213
214   explicit DALI_INTERNAL Base(Internal::Visual::Base *impl);
215
216 };
217
218 } // namespace Visual
219
220 } // namespace Toolkit
221
222 } // namespace Dali
223
224 #endif /*DALI_TOOLKIT_VISUAL_BASE_H*/