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) { mMaxSwingAngle = maxSwingAngle; }
105 * @copydoc Toolkit::ScrollViewEffect::SetSwingDropOff
107 void SetSwingDropOff(const Vector2& dropOff, const Vector2& distance, AlphaFunction function = NULL);
112 * @copydoc ScrollViewEffect::OnAttach
114 virtual void OnAttach(Toolkit::ScrollView& scrollView);
117 * @copydoc ScrollViewEffect::OnDetach
119 virtual void OnDetach(Toolkit::ScrollView& scrollView);
124 * A reference counted object may only be deleted by calling Unreference()
126 virtual ~ScrollViewTwistEffect();
131 * Signal handler, called when the ScrollView starts to move
133 * @param[in] position The current scroll position
135 void OnScrollStart( const Vector3& position );
138 * Signal handler, called when the ScrollView is moving
140 * @param[in] position The current scroll positionApply
142 void OnScrollUpdate( const Vector3& position );
145 * Signal handler, called when the ScrollView has completed movement
147 * @param[in] position The current scroll position
149 void OnScrollComplete( const Vector3& position );
151 void OnScrollSnap( const Toolkit::ScrollView::SnapEvent& event );
154 * Signal handler, called when the Wobble Effect animation has completed.
156 * @param[in] animation The animation.
158 void OnAnimationFinished( Animation& animation );
160 void OnActivateAnimationFinished( Animation& animation );
162 * Attaches effect to Scroll Actor (ScrollView)
164 * Applies the same wobble effect to each Scroll Actor.
166 * @param[in] actor The attached Actor
168 void AttachActor(Actor actor);
171 * Detaches effect from Scroll Actor (ScrollView)
173 * @param[in] actor The attached Actor
175 void DetachActor(Actor actor);
178 * Continues Animation to time reaches endTime
180 * @param[in] endTime the target time to reach.
182 void ContinueAnimation(float endTime);
187 Animation mAnimation; ///< Animation Timer to drive the twist effect constraint.
188 float mActivationTime; ///< Time taken for overshoot to reach zero, which is the time we need to allow effect to be active
189 Animation mActivateAnimation;
190 Property::Index mPropertyTime; ///< Time property used by twist effect constraint to calculate timePassed.
191 bool mEnableEffect; ///< flag that decide whether enable or disable the twist effect.
192 bool mAdditionalEffects; ///< whether we want to apply extra effects
193 Property::Index mPropertyReference; ///< Reference point in scroll-contents, this point has no delay.
194 Property::Index mPropertyActivate; ///::< The further out from this point, the further the delay.
195 Property::Index mPropertyDepth; ///< Depth property used by twist effect constraint to shrink Actors.
196 float mMinimumDistanceForShrink; ///< Scrolling animation must last for longer than this amount to do shrink effect.s
197 Vector2 mMaxSwingAngle; ///< Maximum swing angle to be applied to x and y axes
198 Vector2 mDropOff; ///< Amount to drop off the angle on each axis of drop off distance
199 Vector2 mDropOffDistance; ///< Distance to apply the full drop off over
200 AlphaFunction mDropOffFunction; ///< Function to adjust how drop off is aplied over the distance, NULL for linear
201 float mScaleFactor; ///< Amount to scale by during translation
206 } // namespace Internal
208 // Helpers for public-api forwarding methods
210 inline Internal::ScrollViewTwistEffect& GetImpl(Dali::Toolkit::ScrollViewTwistEffect& obj)
212 DALI_ASSERT_ALWAYS(obj);
214 Dali::RefObject& handle = obj.GetBaseObject();
216 return static_cast<Internal::ScrollViewTwistEffect&>(handle);
219 inline const Internal::ScrollViewTwistEffect& GetImpl(const Dali::Toolkit::ScrollViewTwistEffect& obj)
221 DALI_ASSERT_ALWAYS(obj);
223 const Dali::RefObject& handle = obj.GetBaseObject();
225 return static_cast<const Internal::ScrollViewTwistEffect&>(handle);
228 } // namespace Toolkit
232 #endif // __DALI_TOOLKIT_INTERNAL_SCROLL_VIEW_TWIST_EFFECT_H__