1 #ifndef __DALI_TOOLKIT_INTERNAL_SCROLL_VIEW_SLIDE_EFFECT_H__
2 #define __DALI_TOOLKIT_INTERNAL_SCROLL_VIEW_SLIDE_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-slide-effect.h>
42 class ScrollViewEffect;
44 class ScrollSlideInfo;
46 typedef IntrusivePtr<ScrollSlideInfo> ScrollSlideInfoPtr;
49 * @copydoc Toolkit::ScrollViewSlideEffect
51 class ScrollViewSlideEffect : public ScrollViewEffect
58 ScrollViewSlideEffect();
63 * @copydoc ScrollViewEffect::GetSlideDirection
65 bool GetSlideDirection() const;
68 * @copydoc ScrollViewEffect::SetSlideDirection
70 void SetSlideDirection(bool vertical);
73 * @copydoc ScrollViewEffect::GetDelayReferenceOffset
75 const Vector3& GetDelayReferenceOffset() const;
78 * @copydoc ScrollViewEffect::SetDelayReferenceOffset
80 void SetDelayReferenceOffset(const Vector3& offset);
83 * @copydoc ScrollViewEffect::GetMaxDelayDuration
85 float GetMaxDelayDuration() const;
88 * @copydoc ScrollViewEffect::SetMaxDelayDuration
90 void SetMaxDelayDuration(float duration);
93 * @copydoc ScrollViewEffect::ApplyToActor
95 void ApplyToActor( Actor child,
101 * @copydoc ScrollViewEffect::OnAttach
103 virtual void OnAttach(Toolkit::ScrollView& scrollView);
106 * @copydoc ScrollViewEffect::OnDetach
108 virtual void OnDetach(Toolkit::ScrollView& scrollView);
113 * A reference counted object may only be deleted by calling Unreference()
115 virtual ~ScrollViewSlideEffect();
120 * Invoked when user touches the scroll-view
121 * We keep track of the touch as this is used to determine
122 * the reference point which is used to determine the delay
123 * factor for the Actors' movements.
124 * @param[in] actor The actor touched
125 * @param[in] event The touch Event
126 * @return Whether to consume the even or not.
128 bool OnScrollTouched(Actor actor, const TouchEvent& event);
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 starts to snap
139 * @param[in] event The snap event.
141 void OnScrollSnapStarted(const Toolkit::ScrollView::SnapEvent& event);
144 * Signal handler, called some time after the ScrollView has completed
145 * movement. There is a delay as when the ScrollView has completed
146 * movement, there are Actors that have a delay, and take time to arrive
147 * at their final destination.
149 * @param[in] animation The animation delegate for this delay
151 void OnAnimationSnapFinished( Animation& animation );
154 * Signal handler, called when the Wobble Effect animation has completed.
156 * @param[in] animation The animation.
158 void OnAnimationFinished( 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);
185 ScrollSlideInfoPtr mScrollSlideInfo; ///< Info structure to keep track of common properties amongst many constraints.
186 ActiveConstraint mInfoUpdateConstraint; ///< Constraint applied to scroll-view to update Info structure.
187 Animation mAnimation; ///< Animation Timer to drive the twist effect constraint.
188 Animation mAnimationSnap; ///< Animation Snap (this animates from from 1.0 to 0.0 when contents snap)
189 Property::Index mPropertyTime; ///< Time property used by twist effect constraint to calculate timePassed.
190 Property::Index mPropertyReference; ///< Reference point in scroll-contents, this point has no delay.
191 ///< The further out from this point, the further the delay.
192 Property::Index mPropertyActive; ///< Property indicates the progress of the scrolling from 1.0f (scrolling) to 0.0f (fully snapped)
193 Vector3 mDelayReferenceOffset; ///< Where to offset the delay reference point when dragging.
194 float mMaxDelayDuration; ///< Maximum duration of effect after scroll-view completes.
197 } // namespace Internal
199 // Helpers for public-api forwarding methods
201 inline Internal::ScrollViewSlideEffect& GetImpl(Dali::Toolkit::ScrollViewSlideEffect& obj)
203 DALI_ASSERT_ALWAYS(obj);
205 Dali::RefObject& handle = obj.GetBaseObject();
207 return static_cast<Internal::ScrollViewSlideEffect&>(handle);
210 inline const Internal::ScrollViewSlideEffect& GetImpl(const Dali::Toolkit::ScrollViewSlideEffect& obj)
212 DALI_ASSERT_ALWAYS(obj);
214 const Dali::RefObject& handle = obj.GetBaseObject();
216 return static_cast<const Internal::ScrollViewSlideEffect&>(handle);
219 } // namespace Toolkit
223 #endif // __DALI_TOOLKIT_INTERNAL_SCROLL_VIEW_SLIDE_EFFECT_H__