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>
28 #include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view.h>
29 #include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view-effect.h>
30 #include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view-slide-effect.h>
31 #include <dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-effect-impl.h>
46 class ScrollSlideInfo;
48 typedef IntrusivePtr<ScrollSlideInfo> ScrollSlideInfoPtr;
51 * @copydoc Toolkit::ScrollViewSlideEffect
53 class ScrollViewSlideEffect : public ScrollViewEffect
60 ScrollViewSlideEffect();
65 * @copydoc ScrollViewEffect::GetSlideDirection
67 bool GetSlideDirection() const;
70 * @copydoc ScrollViewEffect::SetSlideDirection
72 void SetSlideDirection(bool vertical);
75 * @copydoc ScrollViewEffect::GetDelayReferenceOffset
77 const Vector3& GetDelayReferenceOffset() const;
80 * @copydoc ScrollViewEffect::SetDelayReferenceOffset
82 void SetDelayReferenceOffset(const Vector3& offset);
85 * @copydoc ScrollViewEffect::GetMaxDelayDuration
87 float GetMaxDelayDuration() const;
90 * @copydoc ScrollViewEffect::SetMaxDelayDuration
92 void SetMaxDelayDuration(float duration);
95 * @copydoc ScrollViewEffect::ApplyToActor
97 void ApplyToActor( Actor child,
103 * @copydoc ScrollViewEffect::OnAttach
105 virtual void OnAttach(Toolkit::ScrollView& scrollView);
108 * @copydoc ScrollViewEffect::OnDetach
110 virtual void OnDetach(Toolkit::ScrollView& scrollView);
115 * A reference counted object may only be deleted by calling Unreference()
117 virtual ~ScrollViewSlideEffect();
122 * Invoked when user touches the scroll-view
123 * We keep track of the touch as this is used to determine
124 * the reference point which is used to determine the delay
125 * factor for the Actors' movements.
126 * @param[in] actor The actor touched
127 * @param[in] event The touch Event
128 * @return Whether to consume the even or not.
130 bool OnScrollTouched(Actor actor, const TouchEvent& event);
133 * Signal handler, called when the ScrollView starts to move
135 * @param[in] position The current scroll position
137 void OnScrollStart( const Vector3& position );
140 * Signal handler, called when the ScrollView starts to snap
141 * @param[in] event The snap event.
143 void OnScrollSnapStarted(const Toolkit::ScrollView::SnapEvent& event);
146 * Signal handler, called some time after the ScrollView has completed
147 * movement. There is a delay as when the ScrollView has completed
148 * movement, there are Actors that have a delay, and take time to arrive
149 * at their final destination.
151 * @param[in] animation The animation delegate for this delay
153 void OnAnimationSnapFinished( Animation& animation );
156 * Signal handler, called when the Wobble Effect animation has completed.
158 * @param[in] animation The animation.
160 void OnAnimationFinished( Animation& animation );
163 * Attaches effect to Scroll Actor (ScrollView)
165 * Applies the same wobble effect to each Scroll Actor.
167 * @param[in] actor The attached Actor
169 void AttachActor(Actor actor);
172 * Detaches effect from Scroll Actor (ScrollView)
174 * @param[in] actor The attached Actor
176 void DetachActor(Actor actor);
179 * Continues Animation to time reaches endTime
181 * @param[in] endTime the target time to reach.
183 void ContinueAnimation(float endTime);
187 ScrollSlideInfoPtr mScrollSlideInfo; ///< Info structure to keep track of common properties amongst many constraints.
188 ActiveConstraint mInfoUpdateConstraint; ///< Constraint applied to scroll-view to update Info structure.
189 Animation mAnimation; ///< Animation Timer to drive the slide effect constraint.
190 Animation mAnimationSnap; ///< Animation Snap (this animates from from 1.0 to 0.0 when contents snap)
191 Property::Index mPropertyTime; ///< Time property used by slide effect constraint to calculate timePassed.
192 Property::Index mPropertyReference; ///< Reference point in scroll-contents, this point has no delay.
193 ///< The further out from this point, the further the delay.
194 Property::Index mPropertyActive; ///< Property indicates the progress of the scrolling from 1.0f (scrolling) to 0.0f (fully snapped)
195 Vector3 mDelayReferenceOffset; ///< Where to offset the delay reference point when dragging.
196 float mMaxDelayDuration; ///< Maximum duration of effect after scroll-view completes.
199 } // namespace Internal
201 // Helpers for public-api forwarding methods
203 inline Internal::ScrollViewSlideEffect& GetImpl(Dali::Toolkit::ScrollViewSlideEffect& obj)
205 DALI_ASSERT_ALWAYS(obj);
207 Dali::RefObject& handle = obj.GetBaseObject();
209 return static_cast<Internal::ScrollViewSlideEffect&>(handle);
212 inline const Internal::ScrollViewSlideEffect& GetImpl(const Dali::Toolkit::ScrollViewSlideEffect& obj)
214 DALI_ASSERT_ALWAYS(obj);
216 const Dali::RefObject& handle = obj.GetBaseObject();
218 return static_cast<const Internal::ScrollViewSlideEffect&>(handle);
221 } // namespace Toolkit
225 #endif // __DALI_TOOLKIT_INTERNAL_SCROLL_VIEW_SLIDE_EFFECT_H__