ScrollBar refactoring
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / scrollable / scroll-view / scroll-view-wobble-effect-impl.h
1 #ifndef __DALI_TOOLKIT_INTERNAL_SCROLL_VIEW_WOBBLE_EFFECT_H__
2 #define __DALI_TOOLKIT_INTERNAL_SCROLL_VIEW_WOBBLE_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 // EXTERNAL INCLUDES
22 #include <dali/public-api/animation/animation.h>
23 #include <dali/public-api/animation/alpha-function.h>
24 #include <dali/public-api/animation/time-period.h>
25 #include <dali/public-api/object/ref-object.h>
26 #include <dali/public-api/actors/custom-actor.h>
27
28 // INTERNAL INCLUDES
29 #include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view.h>
30 #include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view-effect.h>
31 #include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view-wobble-effect.h>
32
33 namespace Dali
34 {
35
36 class Animation;
37
38 namespace Toolkit
39 {
40
41 class ScrollView;
42
43 namespace Internal
44 {
45
46 class ScrollViewEffect;
47
48 /**
49  * @copydoc Toolkit::ScrollViewWobbleEffect
50  */
51 class ScrollViewWobbleEffect : public ScrollViewEffect
52 {
53
54 public:
55
56   /**
57    * Constructor
58    */
59   ScrollViewWobbleEffect();
60
61   /**
62    * Increases the Stable Count (when this reaches mStableTotal)
63    * Then all constraints are stable, and the animation can stop.
64    */
65   void IncrementStableCount();
66
67   /**
68    * Returns animation cycle id. Every time a new animation starts
69    * this cycle id is increased.
70    *
71    * @return The Animation Cycle id is returned.
72    */
73   unsigned int GetAnimationCycleId() const;
74
75 public:
76
77   /**
78    * @copydoc ScrollViewEffect::OnAttach
79    */
80   virtual void OnAttach(Toolkit::ScrollView& scrollView);
81
82   /**
83    * @copydoc ScrollViewEffect::OnDetach
84    */
85   virtual void OnDetach(Toolkit::ScrollView& scrollView);
86
87 protected:
88
89   /**
90    * A reference counted object may only be deleted by calling Unreference()
91    */
92   virtual ~ScrollViewWobbleEffect();
93
94 private:
95
96   /**
97    * Signal handler, called when the ScrollView starts to move
98    *
99    * @param[in] position The current scroll position
100    */
101   void OnScrollStart( const Vector2& position );
102
103   /**
104    * Signal handler, called when the ScrollView is moving
105    *
106    * @param[in] position The current scroll position
107    */
108   void OnScrollUpdate( const Vector2& position );
109
110   /**
111    * Signal handler, called when the ScrollView has completed movement
112    *
113    * @param[in] position The current scroll position
114    */
115   void OnScrollComplete( const Vector2& position );
116
117   /**
118    * Signal handler, called when the Wobble Effect animation has completed.
119    *
120    * @param[in] animation The animation.
121    */
122   void OnAnimationFinished( Animation& animation );
123
124   /**
125    * Attaches effect to Scroll Actor (ScrollView)
126    *
127    * Applies the same wobble effect to each Scroll Actor.
128    *
129    * @param[in] actor The attached Actor
130    */
131   void AttachActor(Actor actor);
132
133   /**
134    * Detaches effect from Scroll Actor (ScrollView)
135    *
136    * @param[in] actor The attached Actor
137    */
138   void DetachActor(Actor actor);
139
140   /**
141    * Continues Animation to time reaches endTime
142    *
143    * @param[in] endTime the target time to reach.
144    */
145   void ContinueAnimation(float endTime);
146
147 private:
148
149   Animation mAnimation;                         ///< Animation Timer to drive the wobble effect constraint.
150   Property::Index mPropertyTime;                ///< Time property used by wobble effect constraint to calculate timePassed.
151
152   int mStableCurrent;                           ///< Stability current - how many wobble constraints are not wobbling (or have neglible wobble).
153   unsigned int mAnimationCycleId;               ///< The start of each new animation cycle is a unique number.
154
155 };
156
157 } // namespace Internal
158
159 } // namespace Toolkit
160
161 } // namespace Dali
162
163 #endif // __DALI_TOOLKIT_INTERNAL_SCROLL_VIEW_WOBBLE_EFFECT_H__