Merge "Typo fixed in Control implementation doc." into tizen
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / public-api / shader-effects / bubble-effect / bubble-effect.h
1 #ifndef __DALI_TOOLKIT_SHADER_BUBBLE_EFFECT_H__
2 #define __DALI_TOOLKIT_SHADER_BUBBLE_EFFECT_H__
3
4 /*
5  * Copyright (c) 2014 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/shader-effects/shader-effect.h>
23
24 namespace Dali
25 {
26
27 namespace Toolkit
28 {
29
30 /**
31  * BubbleEffect is a custom shader to achieve similar effect of particle system by applying on a specially created MeshActor
32  * Each bubble is rendered on a patch with two triangles; and each mesh can contain multiple such patches.
33  */
34 class DALI_IMPORT_API BubbleEffect : public ShaderEffect
35 {
36 public:
37
38   /**
39    * Create an empty BubbleEffect handle
40    */
41   BubbleEffect();
42
43   /**
44    * @brief Destructor
45    *
46    * This is non-virtual since derived Handle types must not contain data or virtual methods.
47    */
48   ~BubbleEffect();
49
50   /**
51    * Create an initialized BubbleEffect
52    * @param[in] numberOfBubble How many groups of uniforms are used to control the bubble movement.
53    * Note: Limited by the maximum available uniforms, this parameter cannot be bigger than 100.
54    * Ideally use one group of uniform to control one bubble.
55    * If the num of patches in the MeshActor is more than groups of uniforms,
56    * the uniform values will be shared by multiple bubbles. Allow up to 9 times.
57    * @return A handle to a newly allocated Dali resource.
58    */
59   static BubbleEffect New( unsigned int numberOfBubble);
60
61   /**
62    * Set the bubble movement area for the BubbleEffect
63    * @param[in] movementArea The size of bubble movement area; by default, it is the stage size
64    */
65   void SetMovementArea( const Vector2& movementArea );
66
67   /**
68    * Set the start and end positions of the index-th bubble's movement.
69    * @param[in] index Indicate which bubble these properties are applied on.
70    * @param[in] startAndEndPosition The start and the end position of movement.
71    */
72   void SetStartAndEndPosition( unsigned int index, const Vector4& startAndEndPosition );
73
74   /**
75    * Set the movement completed percentage of the index-th bubble.
76    * The bubble will appear at start position when percentage equals to zero,
77    * and disappear near end position (affected by gravity) when percentage equals to one.
78    * This percentage property is used to animate the bubble movement.
79    * @param[in] index Indicate which bubble this property is applied on.
80    * @param[in] percentage Set the percentage property value ( between zero and one ).
81    */
82   void SetPercentage( unsigned int index, float percentage );
83
84   /**
85    * Set the gravity applied to the y direction, which makes the bubbles no longer moving on a straight line.
86    * @param[in] gravity The gravity on the y direction.
87    */
88   void SetGravity( float gravity );
89
90   /**
91    * Set the scale factor applied to the bubbles
92    * @param[in] scale The scale factor applied on all bubbles.
93    */
94   void SetDynamicScale( float scale );
95
96   /**
97    * Increase both the bubble size and moving speed.
98    * Animate this peoperty to create special effect such as all the bubbles blow up on the screen.
99    * @param[in] magnification The manified factor applied on the bubble size and moving speed.
100    */
101   void SetMagnification( float magnification );
102
103   /**
104    * Get the name for the idx-th percentage property.
105    * @param[in] index The percentage property index.
106    * @return std::string containing the property name.
107    */
108   std::string GetPercentagePropertyName( unsigned int index ) const;
109
110   /**
111    * Get the name for the magnification property.
112    * @return std::string containinf the property name.
113    */
114   std::string GetMagnificationPropertyName() const;
115
116   /**
117    * Reset the uniform values to default.
118    */
119   void ResetParameters();
120
121 private:// Not intended for application developers
122
123   DALI_INTERNAL BubbleEffect( ShaderEffect handle );
124
125 private:
126
127   unsigned int mNumberOfBubbles;
128   Vector2      mMovementArea;
129 };
130
131 } // namespace Toolkit
132
133 } // namespace Dali
134 #endif /* __DALI_TOOLKIT_SHADER_BUBBLE_EFFECT_H__ */