Remove obsolete and non functional SizeChanged signal from actor
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / scrollable / scroll-view / scroll-overshoot-indicator-impl.h
1 #ifndef __DALI_TOOLKIT_INTERNAL_SCROLL_OVERSHOOT_INDICATOR_H__
2 #define __DALI_TOOLKIT_INTERNAL_SCROLL_OVERSHOOT_INDICATOR_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/actors/actor.h>
23 #include <dali/public-api/animation/animation.h>
24 #include <dali/public-api/common/intrusive-ptr.h>
25 #include <dali/public-api/math/vector4.h>
26 #include <dali/public-api/object/property-notification.h>
27 #include <dali/public-api/object/ref-object.h>
28
29 namespace Dali
30 {
31
32 namespace Toolkit
33 {
34
35 namespace Internal
36 {
37 class Scrollable;
38 class ScrollOvershootEffect;
39 class ScrollOvershootEffectGradient;
40 class ScrollOvershootEffectRipple;
41 typedef IntrusivePtr<ScrollOvershootEffect> ScrollOvershootEffectPtr;
42 typedef IntrusivePtr<ScrollOvershootEffectGradient> ScrollOvershootEffectGradientPtr;
43 typedef IntrusivePtr<ScrollOvershootEffectRipple> ScrollOvershootEffectRipplePtr;
44
45 struct ScrollOvershootIndicator : public Dali::RefObject
46 {
47 public:
48
49   /**
50    * ScrollOvershootIndicator constructor.
51    */
52   ScrollOvershootIndicator();
53
54   /**
55    * Virtual destructor
56    */
57   virtual ~ScrollOvershootIndicator();
58
59   /**
60    * Attaches the scroll indicator to a scrollable actor
61    *
62    * &param[in] scrollable The scrollable actor to attach to
63    */
64   void AttachToScrollable(Scrollable& scrollable);
65
66   /**
67    * Detaches the scroll indicator from a scrollable actor
68    *
69    * &param[in] scrollable The scrollable actor to detach from
70    */
71   void DetachFromScrollable(Scrollable& scrollable);
72
73   /**
74    * Resets the indicator
75    */
76   void Reset();
77
78   /**
79    * Clears the overshoot
80    */
81   void ClearOvershoot();
82
83   /**
84    * Create an initialized ScrollOvershootIndicator
85    *
86    * @return A pointer to the created ScrollOvershootIndicator.
87    */
88   static ScrollOvershootIndicator* New();
89
90   /**
91    * Set the color of the overshoot effect.
92    * @parm[in] color The color of the overshoot effect
93    */
94   void SetOvershootEffectColor( const Vector4& color );
95
96 private:
97   ScrollOvershootEffectPtr mEffectX;                      ///< effect used for x-axis/horizontal display
98   ScrollOvershootEffectPtr mEffectY;                      ///< effect used for y-axis/vertical display
99 };
100
101 /**
102  * ScrollOvershootEffect is a derivable class, designed to allow the application programmer to create their own
103  * overshoot effect and apply it with minimal implementation required
104  */
105 struct ScrollOvershootEffect : public Dali::RefObject
106 {
107 public:
108   /**
109    * Create a new overshoot effect, passing in whether it is vertical or horizontal
110    *
111    * @param[in] vertical whether this effect is a vertical or horizontal one
112    */
113   ScrollOvershootEffect( bool vertical );
114
115   /**
116    * Virtual destructor
117    */
118   virtual ~ScrollOvershootEffect() {}
119
120   /**
121    * Returns if this is a vertical or horizontal overhoot effect
122    *
123    * @return true or false
124    */
125   bool IsVertical() const;
126
127   /**
128    * Applies the indicator effect, all derived effects must implement this function
129    *
130    * @param[in] scrollable the scrollable object to apply this effect to
131    */
132   virtual void Apply() = 0;
133
134   /**
135    * Removes the indicator effect, all derived effects must implement this function
136    *
137    * @param[in] scrollable the scrollable object to remove this effect from
138    */
139   virtual void Remove( Scrollable& scrollable ) = 0;
140
141   /**
142    * Resets this overshoot effect
143    */
144   virtual void Reset() = 0;
145
146   /**
147    * Sets up property notifications for overshoot values
148    */
149   virtual void UpdatePropertyNotifications() {}
150
151   /**
152    * @copydoc ScrollOvershootIndicator::SetOvershootEffectColor()
153    */
154   virtual void SetOvershootEffectColor( const Vector4& color ) = 0;
155
156   /**
157    * Sets shader overshoot value, either immediately of by animating over time
158    *
159    * @param[in] amount The amount to set overshoot to [-1.0f,1.0f]
160    * @param[in] animate Whether to animate or set immediately
161    */
162   virtual void SetOvershoot(float amount, bool animate = true) = 0;
163
164 private:
165   bool mVertical;                      ///< whether this is a vertical/horizontal effect
166 };
167
168 /**
169  * ScrollOvershootEffectRipple creates an animated bounce effect at the end of the scrollable area if the user
170  * attempts to scroll past it
171  */
172 struct ScrollOvershootEffectRipple : public ScrollOvershootEffect, public ConnectionTracker
173 {
174   enum AnimationState
175   {
176     AnimatingIn  = 0x01,  ///< animating overshoot to 0
177     AnimatingOut = 0x02,  ///< animating overshoot to negative (overshoot image displays in +ve area of screen)
178     AnimateBack  = 0x04,  ///< indicates that we need to animate overshoot back to zero immediately after it has finished animating in
179   };
180
181 public:
182
183   /**
184    * Create a new gradient overshoot effect, passing in whether it is vertical or horizontal
185    *
186    * @param[in] vertical Whether this indicator is vertical or horizontal
187    */
188   ScrollOvershootEffectRipple( bool vertical, Scrollable& scrollable );
189
190   /**
191    * @copydoc ScrollOvershootEffect::Apply
192    */
193   virtual void Apply();
194
195   /**
196    * @copydoc ScrollOvershootEffect::Remove
197    */
198   virtual void Remove( Scrollable& scrollable );
199
200   /**
201    * @copydoc ScrollOvershootEffect::Reset
202    */
203   virtual void Reset();
204
205   /**
206    * @copydoc ScrollOvershootEffect::UpdatePropertyNotifications
207    */
208   void UpdatePropertyNotifications();
209
210   /**
211    * @copydoc ScrollOvershootEffect::SetOvershootEffectColor()
212    */
213   void SetOvershootEffectColor( const Vector4& color );
214
215   /**
216    * Updates the vibility of the overshoot image as well as updating its size, position and rotation
217    * This function is called when animation starts and finishes
218    *
219    * @param[in] visible Whether to set the image visible or not
220    */
221   void UpdateVisibility( bool visible );
222
223   /**
224    * Informs overshoot effect to update image position and to animate effect overshoot value for a
225    * positive overshoot value from scrollview
226    *
227    * @param[in] source the property notification that triggered this callback
228    */
229   void OnOvershootNotification(PropertyNotification& source);
230
231   /**
232    * @copydoc ScrollOvershootEffect::SetOvershoot()
233    */
234   void SetOvershoot(float amount, bool animate = true);
235
236   /**
237    * Connects to the animation finished signal of our overshoot animation
238    *
239    * @param[in] animation the animation instance that has finished
240    */
241   void OnOvershootAnimFinished(Animation& animation);
242
243   /**
244    * Creates a new ScrollOvershootEffectGradient objects and returns a pointer to it
245    *
246    * @param[in] vertical whether to create a vertical(true) or horizontal effect
247    * @return a pointer to the new effect
248    */
249   static ScrollOvershootEffectRipplePtr New( bool vertical, Scrollable& scrollable );
250
251 private:
252   Actor                 mOvershootOverlay;             ///< the actor which displays the overshoot effect
253   Scrollable&           mAttachedScrollView;           ///< the actor that this indicator has been attached to
254   Animation             mScrollOvershootAnimation;     ///< overshoot animation
255   PropertyNotification  mOvershootIncreaseNotification;///< notification used to inform as overshoot increases
256   PropertyNotification  mOvershootDecreaseNotification;///< notification used to inform as overshoot decreases
257   Property::Index       mOvershootProperty;            ///< index of the overshoot property in the scrollable actor
258   Property::Index       mEffectOvershootProperty;      ///< index of the effect's overshoot property
259   float                mOvershoot;                    ///< last overshoot value as detected by notifications
260   unsigned short      mAnimationStateFlags;          ///< contains flags indicating the current state of the overshoot animation
261 };
262
263 } // namespace Internal
264
265 } // namespace Toolkit
266
267 } // namespace Dali
268
269 #endif // __DALI_TOOLKIT_INTERNAL_SCROLL_OVERSHOOT_INDICATOR_H__