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