Added devel api header for text direction in Makefile
[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) 2017 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 enum class ResourceStatus
42 {
43   PREPARING,
44   READY,
45   FAILED
46 };
47
48 /**
49  * @brief A Visual provides a renderer for drawing a control component. A control may have multiple visuals.
50  *
51  * Visuals reuse geometry, shader etc. across controls. They ensure that the renderer and texture sets exist only when control is on-stage.
52  * Each visual also responds to actor size and color change, and provides clipping at the renderer level.
53  * Note: The visual responds to the the Actor::COLOR by blending it with the 'Multiply' operator.
54  *
55  * The following properties are optional, but can be supplied in the property map to Dali::Toolkit::VisualFactory::CreateVisual().
56  *
57  * | %Property Name          | Type             |
58  * |-------------------------|------------------|
59  * | customShader            | MAP              |
60  * | transform               | MAP              |
61  *
62  * where \b customShader is a map with at least one of the following properties:
63  * | %Property Name          | Type                       | Required | Default | Description                             |
64  * |-------------------------|----------------------------|----------|---------|-----------------------------------------|
65  * | vertexShader            | STRING                     | No       | ""      | Vertex shader code                      |
66  * | fragmentShader          | STRING                     | No       | ""      | Fragment shader code                    |
67  * | subdivideGridX          | INTEGER                    | No       | 1       | How to subdivide the grid along X       |
68  * | subdivideGridY          | INTEGER                    | No       | 1       | How to subdivide the grid along Y       |
69  * | shaderHints             | INTEGER or ARRAY of STRING | No       | NONE    | Bitmask of hints @sa Dali::Shader::Hint |
70  *
71  * and \b transform is a map with the following properties:
72  * | %Property Name          | Type              | Required | Default                | Description                                         |
73  * |-------------------------|-------------------|----------|------------------------|-----------------------------------------------------|
74  * | offset                  | VECTOR2           | No       | (0,0)                  | Offset of visual from origin                        |
75  * | size                    | VECTOR2           | No       | (1,1)                  | size of visual                                      |
76  * | origin                  | INTEGER or STRING | No       | CENTER                 | origin of the visual @sa Dali::Toolkit::Align       |
77  * | anchorPoint             | INTEGER or STRING | No       | CENTER                 | anchor point of the visual @sa Dali::Toolkit::Align |
78  * | offsetPolicy            | VECTOR2           | No       | ( RELATIVE, RELATIVE ) | @sa Dali::Toolkit::Visual::Transform::Policy   |
79  * | sizePolicy              | VECTOR2           | No       | ( RELATIVE, RELATIVE ) | @sa Dali::Toolkit::Visual::Transform::Policy   |
80  *
81  * Relative means that the component describes a factor of the parent control size;
82  * size.x = 1 means full width; size.y = 0.5 means half height.
83  *
84  * Absolute means that the component describes world units (equivalent to pixels)
85  *
86  */
87 class DALI_IMPORT_API Base : public BaseHandle
88 {
89 public:
90
91   /**
92    * @brief Create an empty Visual Handle
93    */
94   Base();
95
96   /**
97    * @brief Destructor
98    *
99    * This is non-virtual since derived Handle types must not contain data or virtual methods.
100    */
101   ~Base();
102
103   /**
104    * @brief This copy constructor is required for (smart) pointer semantics.
105    *
106    * @param[in] handle A reference to the copied handle.
107    */
108   Base( const Base& handle );
109
110   /**
111    * @brief This assignment operator is required for (smart) pointer semantics.
112    *
113    * @param [in] handle  A reference to the copied handle.
114    * @return A reference to this.
115    */
116   Base& operator=( const Base& handle );
117
118   /**
119    * @brief Set the name of the visual
120    *
121    * Used by the styling system to animate properties
122    * @param[in] name The name to give the visual
123    */
124   void SetName( const std::string& name );
125
126   /**
127    * @brief Get the name of the visual
128    *
129    * Used by the styling system to animate properties
130    * @return The name of the visual
131    */
132   const std::string& GetName();
133
134   /**
135    * @brief Sets the transform and the control size
136    *
137    * @param[in] transform A property map describing the transform
138    * @param[in] controlSize The size of the parent control for visuals that need to scale internally.
139    */
140   void SetTransformAndSize( const Dali::Property::Map& transform, Size controlSize );
141
142   /**
143    * @brief Returns the height for a given width.
144    *
145    * @param[in] width Width to use.
146    *
147    * @return The height based on the width.
148    */
149   float GetHeightForWidth( float width );
150
151   /**
152    * @brief Returns the width for a given height.
153    *
154    * @param[in] height Height to use.
155    *
156    * @return The width based on the height.
157    */
158   float GetWidthForHeight( float height );
159
160   /**
161    * @brief Return the natural size of the visual.
162    *
163    * Deriving classes stipulate the natural size and by default a
164    * visual has a ZERO natural size.
165    *
166    * @note A visual may not actually have a natural size until it has
167    * been placed on stage and acquired all it's resources.
168    *
169    * @param[out] naturalSize The visual's natural size
170    */
171   void GetNaturalSize( Vector2& naturalSize );
172
173   /**
174    * @brief Set the depth index of this visual.
175    *
176    * Depth-index controls draw-order for overlapping visuals.
177    * Visuals with higher depth indices are rendered in front of other visual with smaller values
178    *
179    * @param[in] index The depth index of this visual.
180    */
181   void SetDepthIndex( int index );
182
183   /**
184    * @brief Get the depth index of this visual
185    *
186    * @return The depth index of this visual.
187    */
188   int GetDepthIndex() const;
189
190   /**
191    * @brief Create the property map representing this visual.
192    *
193    * @param[out] map The visual property map.
194    */
195   void CreatePropertyMap( Dali::Property::Map& map ) const;
196
197 public: // Not intended for application developers
198
199   explicit DALI_INTERNAL Base(Internal::Visual::Base *impl);
200
201 };
202
203 } // namespace Visual
204
205 } // namespace Toolkit
206
207 } // namespace Dali
208
209 #endif /*DALI_TOOLKIT_VISUAL_BASE_H*/