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 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
11 // http://floralicense.org/license/
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.
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>
42 class ScrollViewEffect;
45 * @copydoc Toolkit::ScrollViewTwistEffect
47 class ScrollViewTwistEffect : public ScrollViewEffect
56 FlagDefaultDropOff = 0x08,
57 DefaultFlags = FlagTwist | FlagDropOff | FlagDefaultDropOff
63 ScrollViewTwistEffect();
68 * @copydoc ScrollViewEffect::GetMinimumDistanceForShrink
70 float GetMinimumDistanceForShrink() const;
73 * @copydoc ScrollViewEffect::SetMinimumDistanceForShrink
75 void SetMinimumDistanceForShrink(float distance);
78 * enable or disable this effect
79 * @param[in] enable when enableFlag is true, disable when enableFlag is false.
81 void EnableEffect(bool enableFlag);
84 * @copydoc ScrollViewEffect::ApplyToActor
86 void ApplyToActor( Actor child,
87 bool additionalEffects,
88 const Vector2& angleSwing,
94 * @copydoc Toolkit::ScrollViewEffect::Apply
96 void Apply(Actor child);
99 * @copydoc Toolkit::ScrollViewEffect::SetMaxSwingAngle
101 void SetMaxSwingAngle(const Vector2& maxSwingAngle) { mMaxSwingAngle = maxSwingAngle; }
104 * @copydoc Toolkit::ScrollViewEffect::SetSwingDropOff
106 void SetSwingDropOff(const Vector2& dropOff, const Vector2& distance, AlphaFunction function = NULL);
111 * @copydoc ScrollViewEffect::OnAttach
113 virtual void OnAttach(Toolkit::ScrollView& scrollView);
116 * @copydoc ScrollViewEffect::OnDetach
118 virtual void OnDetach(Toolkit::ScrollView& scrollView);
123 * A reference counted object may only be deleted by calling Unreference()
125 virtual ~ScrollViewTwistEffect();
130 * Signal handler, called when the ScrollView starts to move
132 * @param[in] position The current scroll position
134 void OnScrollStart( const Vector3& position );
137 * Signal handler, called when the ScrollView is moving
139 * @param[in] position The current scroll positionApply
141 void OnScrollUpdate( const Vector3& position );
144 * Signal handler, called when the ScrollView has completed movement
146 * @param[in] position The current scroll position
148 void OnScrollComplete( const Vector3& position );
150 void OnScrollSnap( const Toolkit::ScrollView::SnapEvent& event );
153 * Signal handler, called when the Wobble Effect animation has completed.
155 * @param[in] animation The animation.
157 void OnAnimationFinished( Animation& animation );
159 void OnActivateAnimationFinished( Animation& animation );
161 * Attaches effect to Scroll Actor (ScrollView)
163 * Applies the same wobble effect to each Scroll Actor.
165 * @param[in] actor The attached Actor
167 void AttachActor(Actor actor);
170 * Detaches effect from Scroll Actor (ScrollView)
172 * @param[in] actor The attached Actor
174 void DetachActor(Actor actor);
177 * Continues Animation to time reaches endTime
179 * @param[in] endTime the target time to reach.
181 void ContinueAnimation(float endTime);
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
204 } // namespace Internal
206 // Helpers for public-api forwarding methods
208 inline Internal::ScrollViewTwistEffect& GetImpl(Dali::Toolkit::ScrollViewTwistEffect& obj)
210 DALI_ASSERT_ALWAYS(obj);
212 Dali::RefObject& handle = obj.GetBaseObject();
214 return static_cast<Internal::ScrollViewTwistEffect&>(handle);
217 inline const Internal::ScrollViewTwistEffect& GetImpl(const Dali::Toolkit::ScrollViewTwistEffect& obj)
219 DALI_ASSERT_ALWAYS(obj);
221 const Dali::RefObject& handle = obj.GetBaseObject();
223 return static_cast<const Internal::ScrollViewTwistEffect&>(handle);
226 } // namespace Toolkit
230 #endif // __DALI_TOOLKIT_INTERNAL_SCROLL_VIEW_TWIST_EFFECT_H__