Add 'ExclusiveArch: armv7l' limit build to arm architecture
[platform/core/uifw/dali-toolkit.git] / base / dali-toolkit / internal / controls / scrollable / scroll-view / scroll-view-twist-effect-impl.h
1 #ifndef __DALI_TOOLKIT_INTERNAL_SCROLL_VIEW_TWIST_EFFECT_H__
2 #define __DALI_TOOLKIT_INTERNAL_SCROLL_VIEW_TWIST_EFFECT_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/public-api/animation/animation.h>
22 #include <dali/public-api/animation/alpha-functions.h>
23 #include <dali/public-api/animation/time-period.h>
24 #include <dali/public-api/object/ref-object.h>
25 #include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view.h>
26 #include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view-effect.h>
27 #include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view-twist-effect.h>
28
29 namespace Dali
30 {
31
32 class Animation;
33
34 namespace Toolkit
35 {
36
37 class ScrollView;
38
39 namespace Internal
40 {
41
42 class ScrollViewEffect;
43
44 /**
45  * @copydoc Toolkit::ScrollViewTwistEffect
46  */
47 class ScrollViewTwistEffect : public ScrollViewEffect
48 {
49
50 public:
51   enum Flag
52   {
53     FlagTwist = 0x01,
54     FlagScale = 0x02,
55     FlagDropOff = 0x04,
56     FlagDefaultDropOff = 0x08,
57     DefaultFlags = FlagTwist | FlagDropOff | FlagDefaultDropOff
58   };
59
60   /**
61    * Constructor
62    */
63   ScrollViewTwistEffect();
64
65 public:
66
67   /**
68    * @copydoc ScrollViewEffect::GetMinimumDistanceForShrink
69    */
70   float GetMinimumDistanceForShrink() const;
71
72   /**
73    * @copydoc ScrollViewEffect::SetMinimumDistanceForShrink
74    */
75   void SetMinimumDistanceForShrink(float distance);
76
77   /**
78    * enable or disable this effect
79    * @param[in] enable when enableFlag is true, disable when enableFlag is false.
80    */
81   void EnableEffect(bool enableFlag);
82
83   /**
84    * @copydoc ScrollViewEffect::ApplyToActor
85    */
86   void ApplyToActor( Actor child,
87                      bool additionalEffects,
88                      const Vector2& angleSwing,
89                      float scaleAmount,
90                      float delayMin,
91                      float delayMax );
92
93   /**
94    * @copydoc Toolkit::ScrollViewEffect::Apply
95    */
96   void Apply(Actor child);
97
98   /**
99    * @copydoc Toolkit::ScrollViewEffect::SetMaxSwingAngle
100    */
101   void SetMaxSwingAngle(const Vector2& maxSwingAngle) { mMaxSwingAngle = maxSwingAngle; }
102
103   /**
104    * @copydoc Toolkit::ScrollViewEffect::SetSwingDropOff
105    */
106   void SetSwingDropOff(const Vector2& dropOff, const Vector2& distance, AlphaFunction function = NULL);
107
108 public:
109
110   /**
111    * @copydoc ScrollViewEffect::OnAttach
112    */
113   virtual void OnAttach(Toolkit::ScrollView& scrollView);
114
115   /**
116    * @copydoc ScrollViewEffect::OnDetach
117    */
118   virtual void OnDetach(Toolkit::ScrollView& scrollView);
119
120 protected:
121
122   /**
123    * A reference counted object may only be deleted by calling Unreference()
124    */
125   virtual ~ScrollViewTwistEffect();
126
127 private:
128
129   /**
130    * Signal handler, called when the ScrollView starts to move
131    *
132    * @param[in] position The current scroll position
133    */
134   void OnScrollStart( const Vector3& position );
135
136   /**
137    * Signal handler, called when the ScrollView is moving
138    *
139    * @param[in] position The current scroll positionApply
140    */
141   void OnScrollUpdate( const Vector3& position );
142
143   /**
144    * Signal handler, called when the ScrollView has completed movement
145    *
146    * @param[in] position The current scroll position
147    */
148   void OnScrollComplete( const Vector3& position );
149
150   void OnScrollSnap( const Toolkit::ScrollView::SnapEvent& event );
151
152   /**
153    * Signal handler, called when the Wobble Effect animation has completed.
154    *
155    * @param[in] animation The animation.
156    */
157   void OnAnimationFinished( Animation& animation );
158
159   void OnActivateAnimationFinished( Animation& animation );
160   /**
161    * Attaches effect to Scroll Actor (ScrollView)
162    *
163    * Applies the same wobble effect to each Scroll Actor.
164    *
165    * @param[in] actor The attached Actor
166    */
167   void AttachActor(Actor actor);
168
169   /**
170    * Detaches effect from Scroll Actor (ScrollView)
171    *
172    * @param[in] actor The attached Actor
173    */
174   void DetachActor(Actor actor);
175
176   /**
177    * Continues Animation to time reaches endTime
178    *
179    * @param[in] endTime the target time to reach.
180    */
181   void ContinueAnimation(float endTime);
182
183 private:
184
185   ushort mFlags;
186   Animation mAnimation;                         ///< Animation Timer to drive the twist effect constraint.
187   Animation mActivateAnimation;
188   Property::Index mPropertyTime;                ///< Time property used by twist effect constraint to calculate timePassed.
189   bool mEnableEffect;                           ///< flag that decide whether enable or disable the twist effect.
190   bool mAdditionalEffects;                      ///< whether we want to apply extra effects
191   Property::Index mPropertyReference;           ///< Reference point in scroll-contents, this point has no delay.
192   Property::Index mPropertyActivate;                                              ///::< The further out from this point, the further the delay.
193   Property::Index mPropertyDepth;               ///< Depth property used by twist effect constraint to shrink Actors.
194   float mMinimumDistanceForShrink;              ///< Scrolling animation must last for longer than this amount to do shrink effect.s
195   Vector2 mMaxSwingAngle;                       ///< Maximum swing angle to be applied to x and y axes
196   Vector2 mDropOff;                             ///< Amount to drop off the angle on each axis of drop off distance
197   Vector2 mDropOffDistance;                     ///< Distance to apply the full drop off over
198   AlphaFunction mDropOffFunction;                      ///< Function to adjust how drop off is aplied over the distance, NULL for linear
199   float mScaleFactor;                           ///< Amount to scale by during translation
200   float mDelayMin;
201   float mDelayMax;
202 };
203
204 } // namespace Internal
205
206 // Helpers for public-api forwarding methods
207
208 inline Internal::ScrollViewTwistEffect& GetImpl(Dali::Toolkit::ScrollViewTwistEffect& obj)
209 {
210   DALI_ASSERT_ALWAYS(obj);
211
212   Dali::RefObject& handle = obj.GetBaseObject();
213
214   return static_cast<Internal::ScrollViewTwistEffect&>(handle);
215 }
216
217 inline const Internal::ScrollViewTwistEffect& GetImpl(const Dali::Toolkit::ScrollViewTwistEffect& obj)
218 {
219   DALI_ASSERT_ALWAYS(obj);
220
221   const Dali::RefObject& handle = obj.GetBaseObject();
222
223   return static_cast<const Internal::ScrollViewTwistEffect&>(handle);
224 }
225
226 } // namespace Toolkit
227
228 } // namespace Dali
229
230 #endif // __DALI_TOOLKIT_INTERNAL_SCROLL_VIEW_TWIST_EFFECT_H__