Fix for slider
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / public-api / shader-effects / motion-stretch-effect.h
1 #ifndef __DALI_TOOLKIT_SHADER_EFFECT_MOTION_STRETCH_H__
2 #define __DALI_TOOLKIT_SHADER_EFFECT_MOTION_STRETCH_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 // EXTERNAL INCLUDES
21
22 // INTERNAL INCLUDES
23 #include <dali/dali.h>
24
25 namespace Dali DALI_IMPORT_API
26 {
27
28 namespace Toolkit
29 {
30
31 /**
32  *
33  * Class for motion stretch shader that works on a per object basis. Objects will stretch in the direction of motion when they move, or if the camera moves. Can be applied
34  * to ImageActor or TextActor only.
35  *
36  * Usage example:-
37  *
38  * // Create shader used for doing motion stretch\n
39  * MotionStretchEffect MotionStretchEffect = MotionStretchEffect::New();
40  *
41  * // set actor shader to the stretch one\n
42  * Actor Actor = Actor::New( ... );\n
43  * Actor.SetShaderEffect( MotionStretchEffect );
44  *
45  */
46 class MotionStretchEffect : public ShaderEffect
47 {
48
49 public:
50
51   /**
52    * Create an uninitialized MotionStretchEffect; this can be initialized with MotionStretchEffect::New()
53    * Calling member functions with an uninitialized Dali::Object is not allowed.
54    */
55   MotionStretchEffect();
56
57   /**
58    * Virtual destructor.
59    */
60   virtual ~MotionStretchEffect();
61
62   /**
63    * Create an initialized MotionStretchEffect
64    * @return A handle to a newly allocated Dali resource.
65    */
66   static MotionStretchEffect New();
67
68   /**
69    * Create a  MotionStretchEffect and attach it to the specified actor
70    * @return A handle to a newly allocated Dali resource.
71    */
72   static MotionStretchEffect Apply( Actor handle );
73
74   /**
75    * Set geometry stretch factor property. This scales the amount the geometry
76    * stretches along the motion velocity vector. A smaller value means the geometry
77    * stretches less, larger it stretches more. Default 0.5.
78    * @param scalingFactor The scaling factor that extrudes the geometry forwards along the motion velocity vector.
79    */
80   void SetGeometryStretchFactor( float scalingFactor );
81
82   /**
83    * Set speed scaling factor property. This value is used to control how much
84    * to fade the actor near the edges, based on the speed the actor is moving.
85    * When the actor is at rest this is not applied. Default 0.5.
86    * @param scalingFactor The scaling factor that controls the edge fade of the actor.
87    */
88   void SetSpeedScalingFactor( float scalingFactor );
89
90   /**
91    * Set the displacement from the centre of the actor that the actor will start to
92    * fade towards its edges. This is used to prevent an unsightly hard edge
93    * between the stretched actor and the scene. Depends on the values of the
94    * vertices in the vertex stream. When the actor is at rest this is not applied.
95    * Default Vector2(0.25, 0.25), which is half way towards the edge for an ImageRenderer::QUAD.
96    * @param displacement The displacement from the centre of the actor that the actor will start to edge fade.
97    */
98   void SetObjectFadeStart( Vector2 displacement );
99
100   /**
101    * Set the displacement from the centre of the actor that the actor will
102    * finish fading towards its edges. This is used to prevent an unsightly hard
103    * edge between the stretched actor and the scene. Depends on the values of
104    * the vertices in the vertex stream. When the actor is at rest this is not applied.
105    * Default 0.5, which is all the way towards the edge for an ImageRenderer::QUAD.
106    * @param displacement The displacement from the centre of the actor that the actor will finish edge fading.
107    */
108   void SetObjectFadeEnd( Vector2 displacement );
109
110   /**
111    * Set a global scaler applied to the alpha of the actor. Used to make the
112    * stretched actor a bit more subtle and reveal a bit of the background behind
113    * it as it moves. When the actor is at rest this is not applied. Default 0.75.
114    * @param alphaScale The scaling factor which multiplies the alpha of each pixel of the actor.
115    */
116   void SetAlphaScale( float alphaScale );
117
118
119   /**
120    * Get the name for the texcoord scale property. Useful for animation.
121    * @return A std::string containing the property name
122    */
123   const std::string& GetTexcoordScalePropertyName() const;
124
125   /**
126    * Get the name for the geometry stretching property. Useful for animation.
127    * @return A std::string containing the property name
128    */
129   const std::string& GetGeometryStretchFactorPropertyName() const;
130
131   /**
132    * Get the name for the speed scaling property. Useful for animation.
133    * @return A std::string containing the property name
134    */
135   const std::string& GetSpeedScalingFactorPropertyName() const;
136
137   /**
138    * Get the name for the fade start X property. Useful for animation.
139    * @return A std::string containing the property name
140    */
141   const std::string& GetObjectFadeStartPropertyName() const;
142
143   /**
144    * Get the name for the fade end X property. Useful for animation.
145    * @return A std::string containing the property name
146    */
147   const std::string& GetObjectFadeEndPropertyName() const;
148
149   /**
150    * Get the name for the alpha scale property. Useful for animation.
151    * @return A std::string containing the property name
152    */
153   const std::string& GetAlphaScalePropertyName() const;
154
155 private:
156   // Not intended for application developers
157   MotionStretchEffect( ShaderEffect handle );
158 };
159
160 }
161
162 }
163
164 #endif //#ifndef __DALI_TOOLKIT_SHADER_EFFECT_MOTION_STRETCH_H__
165