e40ea541926f39d9467150a82f83557e786eb18a
[platform/core/uifw/dali-toolkit.git] / optional / dali-toolkit / public-api / shader-effects / water-effect.h
1 #ifndef __DALI_TOOLKIT_WATER_EFFECT_H__
2 #define __DALI_TOOLKIT_WATER_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 // INTERNAL INCLUDES
22 #include <dali/dali.h>
23
24 namespace Dali DALI_IMPORT_API
25 {
26
27 namespace Toolkit
28 {
29
30 namespace Internal DALI_INTERNAL
31 {
32
33 /**
34  * WaterEffect implementation class
35  */
36 class WaterEffect;
37
38 } // namespace Internal
39
40 /**
41  * WaterEffect is a custom shader effect to achieve water like effects on Image actors
42  *
43  * Usage example:
44  *
45  *   WaterEffect waterEffect = WaterEffect::New( numberOfDrops );
46  *
47  *   actor.SetShaderEffect( waterEffect );
48  *
49  *   // Set initial values
50  *   waterEffect.SetCenter( 1, centerPosition );
51  *   waterEffect.SetPropagation( 1, INITIAL_RADIUS );
52  *
53  *   // Animate the wave propagation
54  *   std::string propertyName = waterEffect.GetPropagationPropertyName( 1 );
55  *   animation.AnimateTo( Property(waterEffect, propertyName), FINAL_RADIUS );
56  */
57 class WaterEffect : public ShaderEffect
58 {
59 public:
60
61   /**
62    * Create an uninitialized WaterEffect; this can be initialized with WaterEffect::New()
63    * Calling member functions with an uninitialized Dali::Object is not allowed.
64    */
65   WaterEffect();
66
67   /**
68    * @brief Destructor
69    *
70    * This is non-virtual since derived Handle types must not contain data or virtual methods.
71    */
72   ~WaterEffect();
73
74   /**
75    * Create an initialized WaterEffect.
76    * @param [in] numberOfWaves The number of waves.
77    * @return A handle to a newly allocated Dali resource
78    */
79   static WaterEffect New( unsigned int numberOfWaves );
80
81   /**
82    * Get the number of waves the shader supports.
83    * @return The number of waves in the shader.
84    */
85   unsigned int GetNumberOfWaves() const;
86
87   /**
88    * Set the amplitude of a wave.
89    * @param [in] index The index of the wave to change
90    * @param [in] amplitude The new amplitude of the wave
91    * @pre index has to be between 0 and GetNumberOfWaves() - 1
92    */
93   void SetAmplitude( unsigned int index, float amplitude );
94
95   /**
96    * Set the center point of a wave in texture coordinates.
97    * @param [in] index The index of the wave to change
98    * @param [in] center The center point of the wave
99    * @pre index has to be between 0 and GetNumberOfWaves() - 1
100    */
101   void SetCenter( unsigned int index, const Vector2& center );
102
103   /**
104    * Set the propagation radius of a wave.
105    * @param [in] index The index of the wave to change
106    * @param [in] radius The propagation radius
107    * @pre index has to be between 0 and GetNumberOfWaves() - 1
108    */
109   void SetPropagation( unsigned int index, float radius );
110
111   /**
112    * Get the amplitude of a wave.
113    * @param [in] index The index of the wave
114    * @return The new amplitude of the wave
115    * @pre index has to be between 0 and GetNumberOfWaves() - 1
116    */
117   float GetAmplitude( unsigned int index ) const;
118
119   /**
120    * Get the center point of a wave in texture coordinates.
121    * @param [in] index The index of the wave
122    * @return The center point of the wave
123    * @pre index has to be between 0 and GetNumberOfWaves() - 1
124    */
125   Vector2 GetCenter( unsigned int index ) const;
126
127   /**
128    * Get the propagation radius of a wave.
129    * @param [in] index The index of the wave
130    * @return The propagation radius
131    * @pre index has to be between 0 and GetNumberOfWaves() - 1
132    */
133   float GetPropagation( unsigned int index ) const;
134
135   /**
136    * Get the name for the amplitude property of a wave.
137    * @param [in] index The index of the wave
138    * @return A std::string containing the property name
139    * @pre index has to be between 0 and GetNumberOfWaves() - 1
140    */
141   std::string GetAmplitudePropertyName( unsigned int index ) const;
142
143   /**
144    * Get the name for the center property of a wave.
145    * @param [in] index The index of the wave
146    * @return A std::string containing the property name
147    * @pre index has to be between 0 and GetNumberOfWaves() - 1
148    */
149   std::string GetCenterPropertyName( unsigned int index ) const;
150
151   /**
152    * Get the name for the propagation property.
153    * @param [in] index The index of the wave
154    * @return A std::string containing the property name
155    * @pre index has to be between 0 and GetNumberOfWaves() - 1
156    */
157   std::string GetPropagationPropertyName( unsigned int index ) const;
158
159 public: // Not intended for developer use
160
161   WaterEffect( ShaderEffect handle, Internal::WaterEffect* shaderExtension );
162 };
163
164 } // namespace Toolkit
165
166 } // namespace Dali
167
168 #endif // __DALI_TOOLKIT_WATER_EFFECT_H__