BouncingEffect for overscroll
[platform/core/uifw/dali-toolkit.git] / base / dali-toolkit / public-api / shader-effects / bouncing-effect.h
1 #ifndef __DALI_TOOLKIT_SHADER_EFFECT_BOUNCING_H__
2 #define __DALI_TOOLKIT_SHADER_EFFECT_BOUNCING_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  * @brief BouncingEffect is a custom overscroll effect with two waves appearing at two sides then moving towards center and overlapping.
31  *
32  * Usage Example:
33  *
34  *  // Create the an imageActor, set shader effect, and add it to the stage
35  *  ImageActor imageActor = ImageActor::New( BitmapImage::New( 1, 1 ) );
36  *  imageActor.SetSize(720.f,58.f);
37  *  Toolkit::BouncingEffect bouncingEffect = Toolkit::BouncingEffect::New( Vector4(0.f,1.f,1.f,0.5f) );
38  *  imageActor.SetShaderEffect( bouncingEffect );
39  *  imageActor.SetParentOrigin( ParentOrigin::CENTER );
40  *  Stage::GetCurrent().Add( imageActor );
41  *
42  *   // Start the animation
43  *   Animation animation = Animation::New(1.f);
44  *   animation.AnimateTo( Property( bouncingEffect, bouncingEffect.GetProgressRatePropertyName() ),
45  *                        1.f, AlphaFunctions::Bounce );
46  *   animation.Play();
47  */
48 class BouncingEffect : public ShaderEffect
49 {
50 public:
51
52   /**
53    * @brief Creates an empty BouncingEffect handle
54    */
55   BouncingEffect();
56
57   /**
58    * @brief Virtual destructor
59    */
60   virtual ~BouncingEffect();
61
62   /**
63    * @brief Create a BouncingEffect object
64    *
65    * @param[in] color The color used on the bouncing stripe
66    * @return A handle to a newly allocated Dali resource.
67    */
68   static BouncingEffect New( const Vector4& color );
69
70   /**
71    * @brief Set the progress rate to the effect.
72    *
73    * The whole progress ( with progress rate from 0.0 to 1.0 ):
74    *      two waves appear at two sides; move towards center and overlap.
75    * @param[in] progressRate The progress rate value.
76    */
77   void SetProgressRate( float progressRate );
78
79   /**
80    * @brief Get the name for the progress rate property.
81    *
82    * @return A std::string containing the property name.
83    */
84   const std::string& GetProgressRatePropertyName() const;
85
86
87 private: // Not intended for application developers
88   BouncingEffect( ShaderEffect handle );
89
90 };
91
92 } // namespace Toolkit
93
94 } // namespace Dali
95
96 #endif // __DALI_TOOLKIT_SHADER_EFFECT_BOUNCING_H__