Updated all header files to new format
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / bubble-effect / bubble-renderer.h
1 #ifndef DALI_TOOLKIT_INTERNAL_BUBBLE_RENDERER_H
2 #define DALI_TOOLKIT_INTERNAL_BUBBLE_RENDERER_H
3
4 /*
5  * Copyright (c) 2021 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 // EXTERNAL INCLUDES
22 #include <dali/public-api/actors/actor.h>
23 #include <dali/public-api/common/vector-wrapper.h>
24 #include <dali/public-api/object/property-map.h>
25 #include <dali/public-api/rendering/renderer.h>
26
27 namespace Dali
28 {
29 namespace Toolkit
30 {
31 namespace Internal
32 {
33 /**
34  * BubbleRenderer renders a group of bubbles.Each bubble can be moved separately.
35  * Its custom shader achieves similar effect of particle system by applying on a specially created mesh
36  * Each bubble is rendered on a patch with two triangles; and each mesh can contain multiple such patches, thus a group.
37  */
38 class BubbleRenderer
39 {
40 public:
41   /**
42    * Constructor   *
43    * @return A newly allocated object.
44    */
45   BubbleRenderer();
46
47   /**
48    * @brief Destructor
49    */
50   ~BubbleRenderer()
51   {
52   }
53
54   /**
55    * Prepare for the rendering: create the renderer, and register properties
56    * @param[in] numberOfBubble How many groups of uniforms are used to control the bubble movement.
57    * Note: Limited by the maximum available uniforms, this parameter cannot be bigger than 100.
58    * Ideally use one group of uniform to control one bubble.
59    * If the num of patches in the MeshActor is more than groups of uniforms,
60    * the uniform values will be shared by multiple bubbles. Allow up to 9 times.
61    * @param[in] movementArea The size of the bubble moving area, usually the same size as the background.
62    * @param[in] geometry The geometry to be used by the renderer
63    * @param[in] textureSet The texture set to be used by the renderer
64    * @param[in] shader The shader set to be used by the renderer
65    */
66   void Initialize(unsigned int numberOfBubble, const Vector2& movementArea, Geometry geometry, TextureSet textureSet, Shader shader);
67
68   /**
69    * Return the mesh actor which is used to display the bubbles
70    */
71   Renderer& GetRenderer();
72
73   /**
74    * Sets the geometry to be used by the renderer
75    * @param[in] geometry The geometry to be used by the renderer
76    */
77   void SetGeometry(Geometry geometry);
78
79   /**
80    * Set the start and end positions of the index-th bubble's movement.
81    * @param[in] index Indicate which bubble these properties are applied on.
82    * @param[in] startAndEndPosition The start and the end position of movement.
83    */
84   void SetStartAndEndPosition(unsigned int index, const Vector4& startAndEndPosition);
85
86   /**
87    * Set the movement completed percentage of the index-th bubble.
88    * The bubble will appear at start position when percentage equals to zero,
89    * and disappear near end position (affected by gravity) when percentage equals to one.
90    * This percentage property is used to animate the bubble movement.
91    * @param[in] index Indicate which bubble this property is applied on.
92    * @param[in] percentage Set the percentage property value ( between zero and one ).
93    */
94   void SetPercentage(unsigned int index, float percentage);
95
96   /**
97    * Set the gravity applied to the y direction, which makes the bubbles no longer moving on a straight line.
98    * @param[in] gravity The gravity on the y direction.
99    */
100   void SetGravity(float gravity);
101
102   /**
103    * Set the scale factor applied to the bubbles
104    * @param[in] scale The scale factor applied on all bubbles.
105    */
106   void SetDynamicScale(float scale);
107
108   /**
109    * Get the idx-th percentage property.
110    * @param[in] idx The percentage property index.
111    * @return the idx-th percentage property.
112    */
113   Property GetPercentageProperty(unsigned int idx);
114
115   /**
116    * Reset the uniform values to default.
117    */
118   void ResetProperties();
119
120 private:
121   Renderer mRenderer;
122
123   //properties mapped as uniforms
124   std::vector<Property::Index> mIndicesOffset;             ///< Indices of the properties mapping to uniform array 'uOffset'
125   std::vector<Property::Index> mIndiceStartEndPos;         ///< Indices of the properties mapping to uniform array 'uStartAndEndPos'
126   std::vector<Property::Index> mIndicesPercentage;         ///< Indices of the properties mapping to uniform array 'uPercentage'
127   Property::Index              mIndexGravity;              ///< Index of the property mapping to uniform 'uGravity'
128   Property::Index              mIndexDynamicScale;         ///< Index of the property mapping to uniform 'uDynamicScale'
129   Property::Index              mIndexInvertedMovementArea; ///< Index of the property mapping to uniform 'uInvertedMovementArea'
130 };
131
132 } // namespace Internal
133
134 } // namespace Toolkit
135
136 } // namespace Dali
137
138 #endif // DALI_TOOLKIT_INTERNAL_BUBBLE_RENDERER_H