1 #ifndef __DALI_TOOLKIT_INTERNAL_SCROLL_VIEW_TWIST_EFFECT_H__
2 #define __DALI_TOOLKIT_INTERNAL_SCROLL_VIEW_TWIST_EFFECT_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali/public-api/animation/animation.h>
23 #include <dali/public-api/animation/alpha-functions.h>
24 #include <dali/public-api/animation/time-period.h>
25 #include <dali/public-api/object/ref-object.h>
26 #include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view.h>
27 #include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view-effect.h>
28 #include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view-twist-effect.h>
43 class ScrollViewEffect;
46 * @copydoc Toolkit::ScrollViewTwistEffect
48 class ScrollViewTwistEffect : public ScrollViewEffect
57 FlagDefaultDropOff = 0x08,
58 DefaultFlags = FlagTwist | FlagDropOff | FlagDefaultDropOff
64 ScrollViewTwistEffect();
69 * @copydoc ScrollViewEffect::GetMinimumDistanceForShrink
71 float GetMinimumDistanceForShrink() const;
74 * @copydoc ScrollViewEffect::SetMinimumDistanceForShrink
76 void SetMinimumDistanceForShrink(float distance);
79 * enable or disable this effect
80 * @param[in] enable when enableFlag is true, disable when enableFlag is false.
82 void EnableEffect(bool enableFlag);
85 * @copydoc ScrollViewEffect::ApplyToActor
87 void ApplyToActor( Actor child,
88 bool additionalEffects,
89 const Vector2& angleSwing,
95 * @copydoc Toolkit::ScrollViewEffect::Apply
97 void Apply(Actor child);
100 * @copydoc Toolkit::ScrollViewEffect::SetMaxSwingAngle
102 void SetMaxSwingAngle(const Vector2& maxSwingAngle);
105 * @copydoc Toolkit::ScrollViewEffect::GetMaxSwingAngle
107 Vector2 GetMaxSwingAngle() const;
110 * @copydoc Toolkit::ScrollViewEffect::SetSwingDropOff
112 void SetSwingDropOff(const Vector2& dropOff, const Vector2& distance, AlphaFunction function = NULL);
115 * @copydoc Toolkit::ScrollViewEffect::GetSwingDropOff
117 void GetSwingDropOff( Vector2& dropOff, Vector2& distance, AlphaFunction& function ) const;
122 * @copydoc ScrollViewEffect::OnAttach
124 virtual void OnAttach(Toolkit::ScrollView& scrollView);
127 * @copydoc ScrollViewEffect::OnDetach
129 virtual void OnDetach(Toolkit::ScrollView& scrollView);
134 * A reference counted object may only be deleted by calling Unreference()
136 virtual ~ScrollViewTwistEffect();
141 * Signal handler, called when the ScrollView starts to move
143 * @param[in] position The current scroll position
145 void OnScrollStart( const Vector3& position );
148 * Signal handler, called when the ScrollView is moving
150 * @param[in] position The current scroll positionApply
152 void OnScrollUpdate( const Vector3& position );
155 * Signal handler, called when the ScrollView has completed movement
157 * @param[in] position The current scroll position
159 void OnScrollComplete( const Vector3& position );
161 void OnScrollSnap( const Toolkit::ScrollView::SnapEvent& event );
164 * Signal handler, called when the Wobble Effect animation has completed.
166 * @param[in] animation The animation.
168 void OnAnimationFinished( Animation& animation );
170 void OnActivateAnimationFinished( Animation& animation );
172 * Attaches effect to Scroll Actor (ScrollView)
174 * Applies the same wobble effect to each Scroll Actor.
176 * @param[in] actor The attached Actor
178 void AttachActor(Actor actor);
181 * Detaches effect from Scroll Actor (ScrollView)
183 * @param[in] actor The attached Actor
185 void DetachActor(Actor actor);
188 * Continues Animation to time reaches endTime
190 * @param[in] endTime the target time to reach.
192 void ContinueAnimation(float endTime);
197 Animation mAnimation; ///< Animation Timer to drive the twist effect constraint.
198 float mActivationTime; ///< Time taken for overshoot to reach zero, which is the time we need to allow effect to be active
199 Animation mActivateAnimation;
200 Property::Index mPropertyTime; ///< Time property used by twist effect constraint to calculate timePassed.
201 bool mEnableEffect; ///< flag that decide whether enable or disable the twist effect.
202 bool mAdditionalEffects; ///< whether we want to apply extra effects
203 Property::Index mPropertyReference; ///< Reference point in scroll-contents, this point has no delay.
204 Property::Index mPropertyActivate; ///::< The further out from this point, the further the delay.
205 Property::Index mPropertyDepth; ///< Depth property used by twist effect constraint to shrink Actors.
206 float mMinimumDistanceForShrink; ///< Scrolling animation must last for longer than this amount to do shrink effect.s
207 Vector2 mMaxSwingAngle; ///< Maximum swing angle to be applied to x and y axes
208 Vector2 mDropOff; ///< Amount to drop off the angle on each axis of drop off distance
209 Vector2 mDropOffDistance; ///< Distance to apply the full drop off over
210 AlphaFunction mDropOffFunction; ///< Function to adjust how drop off is aplied over the distance, NULL for linear
211 float mScaleFactor; ///< Amount to scale by during translation
216 } // namespace Internal
218 // Helpers for public-api forwarding methods
220 inline Internal::ScrollViewTwistEffect& GetImpl(Dali::Toolkit::ScrollViewTwistEffect& obj)
222 DALI_ASSERT_ALWAYS(obj);
224 Dali::RefObject& handle = obj.GetBaseObject();
226 return static_cast<Internal::ScrollViewTwistEffect&>(handle);
229 inline const Internal::ScrollViewTwistEffect& GetImpl(const Dali::Toolkit::ScrollViewTwistEffect& obj)
231 DALI_ASSERT_ALWAYS(obj);
233 const Dali::RefObject& handle = obj.GetBaseObject();
235 return static_cast<const Internal::ScrollViewTwistEffect&>(handle);
238 } // namespace Toolkit
242 #endif // __DALI_TOOLKIT_INTERNAL_SCROLL_VIEW_TWIST_EFFECT_H__