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 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-slide-effect.h>
43 class ScrollViewEffect;
45 class ScrollSlideInfo;
47 typedef IntrusivePtr<ScrollSlideInfo> ScrollSlideInfoPtr;
50 * @copydoc Toolkit::ScrollViewSlideEffect
52 class ScrollViewSlideEffect : public ScrollViewEffect
59 ScrollViewSlideEffect();
64 * @copydoc ScrollViewEffect::GetSlideDirection
66 bool GetSlideDirection() const;
69 * @copydoc ScrollViewEffect::SetSlideDirection
71 void SetSlideDirection(bool vertical);
74 * @copydoc ScrollViewEffect::GetDelayReferenceOffset
76 const Vector3& GetDelayReferenceOffset() const;
79 * @copydoc ScrollViewEffect::SetDelayReferenceOffset
81 void SetDelayReferenceOffset(const Vector3& offset);
84 * @copydoc ScrollViewEffect::GetMaxDelayDuration
86 float GetMaxDelayDuration() const;
89 * @copydoc ScrollViewEffect::SetMaxDelayDuration
91 void SetMaxDelayDuration(float duration);
94 * @copydoc ScrollViewEffect::ApplyToActor
96 void ApplyToActor( Actor child,
102 * @copydoc ScrollViewEffect::OnAttach
104 virtual void OnAttach(Toolkit::ScrollView& scrollView);
107 * @copydoc ScrollViewEffect::OnDetach
109 virtual void OnDetach(Toolkit::ScrollView& scrollView);
114 * A reference counted object may only be deleted by calling Unreference()
116 virtual ~ScrollViewSlideEffect();
121 * Invoked when user touches the scroll-view
122 * We keep track of the touch as this is used to determine
123 * the reference point which is used to determine the delay
124 * factor for the Actors' movements.
125 * @param[in] actor The actor touched
126 * @param[in] event The touch Event
127 * @return Whether to consume the even or not.
129 bool OnScrollTouched(Actor actor, const TouchEvent& event);
132 * Signal handler, called when the ScrollView starts to move
134 * @param[in] position The current scroll position
136 void OnScrollStart( const Vector3& position );
139 * Signal handler, called when the ScrollView starts to snap
140 * @param[in] event The snap event.
142 void OnScrollSnapStarted(const Toolkit::ScrollView::SnapEvent& event);
145 * Signal handler, called some time after the ScrollView has completed
146 * movement. There is a delay as when the ScrollView has completed
147 * movement, there are Actors that have a delay, and take time to arrive
148 * at their final destination.
150 * @param[in] animation The animation delegate for this delay
152 void OnAnimationSnapFinished( Animation& animation );
155 * Signal handler, called when the Wobble Effect animation has completed.
157 * @param[in] animation The animation.
159 void OnAnimationFinished( 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);
186 ScrollSlideInfoPtr mScrollSlideInfo; ///< Info structure to keep track of common properties amongst many constraints.
187 ActiveConstraint mInfoUpdateConstraint; ///< Constraint applied to scroll-view to update Info structure.
188 Animation mAnimation; ///< Animation Timer to drive the twist effect constraint.
189 Animation mAnimationSnap; ///< Animation Snap (this animates from from 1.0 to 0.0 when contents snap)
190 Property::Index mPropertyTime; ///< Time property used by twist effect constraint to calculate timePassed.
191 Property::Index mPropertyReference; ///< Reference point in scroll-contents, this point has no delay.
192 ///< The further out from this point, the further the delay.
193 Property::Index mPropertyActive; ///< Property indicates the progress of the scrolling from 1.0f (scrolling) to 0.0f (fully snapped)
194 Vector3 mDelayReferenceOffset; ///< Where to offset the delay reference point when dragging.
195 float mMaxDelayDuration; ///< Maximum duration of effect after scroll-view completes.
198 } // namespace Internal
200 // Helpers for public-api forwarding methods
202 inline Internal::ScrollViewSlideEffect& GetImpl(Dali::Toolkit::ScrollViewSlideEffect& obj)
204 DALI_ASSERT_ALWAYS(obj);
206 Dali::RefObject& handle = obj.GetBaseObject();
208 return static_cast<Internal::ScrollViewSlideEffect&>(handle);
211 inline const Internal::ScrollViewSlideEffect& GetImpl(const Dali::Toolkit::ScrollViewSlideEffect& obj)
213 DALI_ASSERT_ALWAYS(obj);
215 const Dali::RefObject& handle = obj.GetBaseObject();
217 return static_cast<const Internal::ScrollViewSlideEffect&>(handle);
220 } // namespace Toolkit
224 #endif // __DALI_TOOLKIT_INTERNAL_SCROLL_VIEW_SLIDE_EFFECT_H__