(ScrollView) Provide a ScrollTo API that allows setting a different alpha function...
[platform/core/uifw/dali-toolkit.git] / base / dali-toolkit / internal / controls / scrollable / scroll-view / scroll-view-impl.h
1 #ifndef __DALI_TOOLKIT_INTERNAL_SCROLL_VIEW_H__
2 #define __DALI_TOOLKIT_INTERNAL_SCROLL_VIEW_H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/dali.h>
23
24 // INTERNAL INCLUDES
25 #include <dali-toolkit/public-api/controls/control-impl.h>
26 #include <dali-toolkit/internal/controls/scrollable/scroll-view/scroll-base-impl.h>
27 #include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view.h>
28 #include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view-effect.h>
29
30 // predefined effect includes
31 #include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view-custom-effect.h>
32
33 namespace Dali
34 {
35
36 namespace Toolkit
37 {
38
39 namespace Internal
40 {
41
42 class ScrollView;
43 typedef IntrusivePtr<ScrollView>    ScrollViewPtr;
44
45 class ScrollInternalConstraints;
46 typedef IntrusivePtr<ScrollInternalConstraints>    ScrollInternalConstraintsPtr;
47
48 class ScrollOvershootIndicator;
49 typedef IntrusivePtr<ScrollOvershootIndicator> ScrollOvershootIndicatorPtr;
50
51 /**
52  * @copydoc Toolkit::ScrollView
53  */
54 class ScrollView : public ScrollBase
55 {
56 public:
57
58   /**
59    * FindDirection specifies how searching is conducted within the Find... routines.
60    */
61   enum FindDirection
62   {
63     None = -3,        ///< Includes none within the search query.
64     All = -2,         ///< Includes all within the search query.
65     Left = -1,        ///< Includes only those not right !(>)
66     Right = 1,        ///< Includes only those right (>)
67     Up = -1,          ///< Includes only those not below  !(>)
68     Down = 1,         ///< Includes only those below (>)
69     Out = -1,         ///< Includes only those not infront  !(>)
70     In = 1            ///< Includes only those infront (>)
71   };
72
73   enum LockAxis
74   {
75     LockPossible = 0, ///< Locking is possible, but not set in stone yet.
76     LockHorizontal,   ///< Locking is set to horizontal. (can pan vertically)
77     LockVertical,     ///< Locking is set to vertical. (can pan horizontally)
78     LockNone          ///< Locking is set to none (free panning).
79   };
80
81   enum ScrollStateFlag
82   {
83     AnimatingInternalX = 0x01, ///< animating mPropertyX due to externally requested ScrollTo or internal snapping operation
84     AnimatingInternalY = 0x02, ///< animating mPropertyY due to externally requested ScrollTo or internal snapping operation
85     SnappingInternalX  = 0x04, ///< snapping mPropertyX back to mPropertyPreScroll x value to remove x overshoot over time
86     SnappingInternalY  = 0x08, ///< snapping mPropertyY back to mPropertyPreScroll y value to remove y overshoot over time
87   };
88
89   static const unsigned int SCROLL_X_STATE_MASK = AnimatingInternalX | SnappingInternalX;
90   static const unsigned int SCROLL_Y_STATE_MASK = AnimatingInternalY | SnappingInternalY;
91   static const unsigned int SCROLL_ANIMATION_FLAGS = AnimatingInternalX | AnimatingInternalY;
92   static const unsigned int SNAP_ANIMATION_FLAGS = SnappingInternalX | SnappingInternalY;
93
94 public:
95
96   /**
97    * Create a new ScrollView.
98    * @return A public handle to the newly allocated ScrollView.
99    */
100   static Dali::Toolkit::ScrollView New();
101
102 public:
103
104   /**
105    * @copydoc Toolkit::ScrollView::GetScrollSnapAlphaFunction
106    */
107   AlphaFunction GetScrollSnapAlphaFunction() const;
108
109   /**
110    * @copydoc Toolkit::ScrollView::SetScrollSnapAlphaFunction
111    */
112   void SetScrollSnapAlphaFunction(AlphaFunction alpha);
113
114   /**
115    * @copydoc Toolkit::ScrollView::GetScrollFlickAlphaFunction
116    */
117   AlphaFunction GetScrollFlickAlphaFunction() const;
118
119   /**
120    * @copydoc Toolkit::ScrollView::SetScrollFlickAlphaFunction
121    */
122   void SetScrollFlickAlphaFunction(AlphaFunction alpha);
123
124   /**
125    * @copydoc Toolkit::ScrollView::GetScrollSnapDuration
126    */
127   float GetScrollSnapDuration() const;
128
129   /**
130    * @copydoc Toolkit::ScrollView::SetScrollSnapDuration
131    */
132   void SetScrollSnapDuration(float time);
133
134   /**
135    * @copydoc Toolkit::ScrollView::GetScrollFlickDuration
136    */
137   float GetScrollFlickDuration() const;
138
139   /**
140    * @copydoc Toolkit::ScrollView::SetScrollFlickDuration
141    */
142   void SetScrollFlickDuration(float time);
143
144   /**
145    * @copydoc Toolkit::ScrollView::ApplyEffect
146    */
147   void ApplyEffect(Toolkit::ScrollViewEffect effect);
148
149   /**
150    * @brief ApplyEffect Applies a predefined effect
151    * @param effect
152    */
153   Toolkit::ScrollViewEffect ApplyEffect(Toolkit::ScrollView::PageEffect effect);
154
155   /**
156    * @copydoc Toolkit::ScrollView::RemoveEffect
157    */
158   void RemoveEffect(Toolkit::ScrollViewEffect effect);
159
160   /**
161    * @copydoc Toolkit::ScrollView::RemoveAllEffects
162    */
163   void RemoveAllEffects();
164
165   /**
166    * @copydoc Toolkit::ScrollView::ApplyConstraintToChildren
167    */
168   void ApplyConstraintToChildren(Constraint constraint);
169
170   /**
171    * @copydoc Toolkit::ScrollView::RemoveConstraintsFromChildren
172    */
173   void RemoveConstraintsFromChildren();
174
175   /**
176    * @copydoc Toolkit::ScrollView::GetRulerX
177    */
178   const RulerPtr GetRulerX() const;
179
180   /**
181    * @copydoc Toolkit::ScrollView::GetRulerY
182    */
183   const RulerPtr GetRulerY() const;
184
185   /**
186    * @copydoc Toolkit::ScrollView::SetRulerX
187    */
188   void SetRulerX(RulerPtr ruler);
189
190   /**
191    * @copydoc Toolkit::ScrollView::SetRulerY
192    */
193   void SetRulerY(RulerPtr ruler);
194
195   /**
196    * @copydoc Toolkit::ScrollView::SetScrollSensitive
197    */
198   void SetScrollSensitive(bool sensitive);
199
200   /**
201    * @copydoc Toolkit::ScrollView::SetMaxOvershoot
202    */
203   void SetMaxOvershoot(float overshootX, float overshootY);
204
205   /**
206    * @copydoc Toolkit::ScrollView::SetSnapOvershootAlphaFunction
207    */
208   void SetSnapOvershootAlphaFunction(AlphaFunction alpha);
209
210   /**
211    * @copydoc Toolkit::ScrollView::SetSnapOvershootDuration
212    */
213   void SetSnapOvershootDuration(float duration);
214
215   /**
216    * @copydoc Toolkit::ScrollView::SetTouchesRequiredForPanning
217    */
218   void SetTouchesRequiredForPanning(unsigned int minTouches, unsigned int maxTouches, bool endOutside);
219
220   /**
221    * @copydoc Toolkit::ScrollView::SetActorAutoSnap
222    */
223   void SetActorAutoSnap(bool enable);
224
225   /**
226    * Enables or Disables Auto Resizing mode for ScrollView contents.
227    *
228    * When enabled, the ScrollView's X/Y Domains are restricted to the
229    * dimensions of the content's bounds, which may change as Actors are
230    * Added/Removed, and repositioned.
231    *
232    * @note This has been disabled for now, as this requires some fundamental
233    * changes to the way Actors positions and bounds are retrieved.
234    * (currently only constraints have these initial state knowledge)
235    *
236    * @param[in] enable Enables (true), or disables (false) Auto Resize.
237    */
238   void SetAutoResize(bool enable);
239
240   /**
241    * Returns whether the wrap mode has been enabled (true) or not (false).
242    *
243    * @return Wrap Mode Enabled flag.
244    */
245   bool GetWrapMode() const;
246
247   /**
248    * @copydoc Toolkit::ScrollView::SetWrapMode
249    */
250   void SetWrapMode(bool enable);
251
252   /**
253    * @copydoc Toolkit::ScrollView::GetScrollupdateDistance
254    */
255   int GetScrollUpdateDistance() const;
256
257   /**
258    * @copydoc Toolkit::ScrollView::SetScrollUpdateDistance
259    */
260   void SetScrollUpdateDistance(int distance);
261
262   /**
263    * @copydoc Toolkit::ScrollView::GetAxisAutoLock
264    */
265   bool GetAxisAutoLock() const;
266
267   /**
268    * @copydoc Toolkit::ScrollView::SetAxisAutoLock
269    */
270   void SetAxisAutoLock(bool enable);
271
272   /**
273    * @copydoc Toolkit::ScrollView::GetAxisAutoLockGradient
274    */
275   float GetAxisAutoLockGradient() const;
276
277   /**
278    * @copydoc Toolkit::ScrollView::SetAxisAutoLockGradient
279    */
280   void SetAxisAutoLockGradient(float gradient);
281
282   /**
283    * @copydoc Toolkit::ScrollView::GetFrictionCoefficient
284    */
285   float GetFrictionCoefficient() const;
286
287   /**
288    * @copydoc Toolkit::ScrollView::SetFrictionCoefficient
289    */
290   void SetFrictionCoefficient(float friction);
291
292   /**
293    * @copydoc Toolkit::ScrollView::GetFlickSpeedCoefficient
294    */
295   float GetFlickSpeedCoefficient() const;
296
297   /**
298    * @copydoc Toolkit::ScrollView::SetFlickSpeedCoefficient
299    */
300   void SetFlickSpeedCoefficient(float speed);
301
302   /**
303    * @copydoc Toolkit::ScrollView::GetMinimumDistanceForFlick
304    */
305   Vector2 GetMinimumDistanceForFlick() const;
306
307   /**
308    * @copydoc Toolkit::ScrollView::SetMinimumDistanceForFlick
309    */
310   void SetMinimumDistanceForFlick( const Vector2& distance );
311
312   /**
313    * @copydoc Toolkit::ScrollView::GetMinimumSpeedForFlick
314    */
315   float GetMinimumSpeedForFlick() const;
316
317   /**
318    * @copydoc Toolkit::ScrollView::SetMinimumSpeedForFlick
319    */
320   void SetMinimumSpeedForFlick( float speed );
321
322   /**
323    * @copydoc Toolkit::ScrollView::GetMaxFlickSpeed
324    */
325   float GetMaxFlickSpeed() const;
326
327   /**
328    * @copydoc Toolkit::ScrollView::SetMaxFlickSpeed
329    */
330   void SetMaxFlickSpeed(float speed);
331
332   /**
333    * @copydoc Toolkit::ScrollView::GetMouseWheelScrollDistanceStep
334    */
335   Vector2 GetMouseWheelScrollDistanceStep() const;
336
337   /**
338    * @copydoc Toolkit::ScrollView::SetMouseWheelScrollDistanceStep
339    */
340   void SetMouseWheelScrollDistanceStep(Vector2 step);
341
342   /**
343    * @copydoc Toolkit::ScrollView::GetCurrentPage
344    */
345   unsigned int GetCurrentPage() const;
346
347   /**
348    * @copydoc Toolkit::ScrollView::GetCurrentScrollPosition
349    */
350   Vector3 GetCurrentScrollPosition() const;
351
352   /**
353    * @copydoc Toolkit::ScrollView::SetScrollPosition
354    */
355   void SetScrollPosition(const Vector3& position);
356
357   /**
358    * @copydoc Toolkit::Scrollable::GetDomainSize
359    */
360   Vector3 GetDomainSize() const;
361
362   /**
363    * @copydoc ScrollTo(const Vector3&)
364    */
365   void TransformTo(const Vector3& position,
366                    DirectionBias horizontalBias = DirectionBiasNone, DirectionBias verticalBias = DirectionBiasNone);
367
368   /**
369    * @copydoc ScrollTo(const Vector3&, float, AlhpaFunction, DirectionBias, DirectionBias)
370    */
371   void TransformTo(const Vector3& position, float duration, AlphaFunction alpha,
372                    DirectionBias horizontalBias = DirectionBiasNone, DirectionBias verticalBias = DirectionBiasNone);
373
374   /**
375    * @copydoc Toolkit::ScrollView::ScrollTo(const Vector3 &position)
376    */
377   void ScrollTo(const Vector3 &position);
378
379   /**
380    * @copydoc Toolkit::Scrollable::ScrollTo(const Vector3& position, float duration)
381    */
382   void ScrollTo(const Vector3& position, float duration);
383
384   /**
385    * @copydoc Toolkit::Scrollable::ScrollTo(const Vector3& position, float duration, AlphaFunction alpha)
386    */
387   void ScrollTo(const Vector3& position, float duration, AlphaFunction alpha);
388
389   /**
390    * @copydoc Toolkit::ScrollView::ScrollTo(const Vector3 &position, float duration, DirectionBias horizontalBias, DirectionBias verticalBias)
391    */
392   void ScrollTo(const Vector3& position, float duration,
393                 DirectionBias horizontalBias, DirectionBias verticalBias);
394
395   /**
396    * @copydoc Toolkit::ScrollView::ScrollTo(const Vector3 &position, float duration, AlphaFunction alpha, DirectionBias horizontalBias, DirectionBias verticalBias)
397    */
398   void ScrollTo(const Vector3& position, float duration, AlphaFunction alpha,
399                 DirectionBias horizontalBias, DirectionBias verticalBias);
400
401   /**
402    * @copydoc Toolkit::ScrollView::ScrollTo(unsigned int page)
403    */
404   void ScrollTo(unsigned int page);
405
406   /**
407    * @copydoc Toolkit::ScrollView::ScrollTo(unsigned int page, float duration, DirectionBias bias)
408    */
409   void ScrollTo(unsigned int page, float duration, DirectionBias bias = DirectionBiasNone);
410
411   /**
412    * @copydoc Toolkit::ScrollView::ScrollTo(Actor& actor)
413    */
414   void ScrollTo(Actor &actor);
415
416   /**
417    * @copydoc Toolkit::ScrollView::ScrollTo(Actor& actor, float duration)
418    */
419   void ScrollTo(Actor &actor, float duration);
420
421   /**
422    * @copydoc Toolkit::ScrollView::SetScrollingDirection()
423    */
424   void SetScrollingDirection( Radian direction, Radian threshold );
425
426   /**
427    * @copydoc Toolkit::ScrollView::RemoveScrollingDirection()
428    */
429   void RemoveScrollingDirection( Radian angle );
430
431   /**
432     * Finds the closest Actor to the current center of the ScrollView.
433     *
434     * @return A handle to the actor if found, or an empty handle if not.
435     */
436    Actor FindClosestActor();
437
438   /**
439    * Finds the closest Actor to position in ScrollView
440    *
441    * @param[in] position position within ScrollView.
442    * @param[in] dirX Whether to search only those elements that are Left,Right, or All
443    * @param[in] dirY Whether to search only those elements that are Up,Down, or All
444    * @param[in] dirZ Whether to search only those elements that are Out,In, or All
445    * @return A handle to the actor if found, or an empty handle if not.
446    */
447   Actor FindClosestActorToPosition(const Vector3& position, FindDirection dirX = All, FindDirection dirY = All, FindDirection dirZ = All);
448
449   /**
450    * @copydoc Toolkit::ScrollView::ScrollToSnapPoint
451   */
452   bool ScrollToSnapPoint();
453
454   /**
455    * Stops animation
456    */
457   void StopAnimation(void);
458
459   /**
460    * Stops the input animation
461    *
462    * @param[in] the animation to stop
463    */
464   void StopAnimation(Animation& animation);
465
466   /**
467    * Animates to position transform.
468    *
469    * @param[in] position The position to animate to
470    * @param[in] positionDuration The number of seconds this animation should run for in each axis.
471    * @param[in] alpha The easing alpha function to use.
472    * @param[in] findShortcuts (optional) Whether to find the shortest route (in Wrap mode)
473    * @param[in] horizontalBias (optional) Whether to bias animation to left or right (or no biasing)
474    * @param[in] verticalBias (optional) Whether to bias animation to top or bottom (or no biasing)
475    * @return True if animation necessary and taking place to reach desired transform.
476    */
477   bool AnimateTo(const Vector3& position, const Vector3& positionDuration,
478                              AlphaFunction alpha, bool findShortcuts = true,
479                              DirectionBias horizontalBias = DirectionBiasNone, DirectionBias verticalBias = DirectionBiasNone,
480                              SnapType snapType = Snap);
481
482   /**
483    * @copydoc Toolkit::Scrollable::AddOverlay()
484    */
485   void AddOverlay(Actor actor);
486
487   /**
488    * @copydoc Toolkit::Scrollable::RemoveOverlay()
489    */
490   void RemoveOverlay(Actor actor);
491
492   /**
493    * @copydoc Toolkit::Internal::Scrollable::SetOvershootEffectColor
494    */
495   void SetOvershootEffectColor( const Vector4& color );
496
497 public: //Signals
498
499   /**
500    * @copydoc Dali::Toolkit::ScrollView::SnapStartedSignal()
501    */
502   Toolkit::ScrollView::SnapStartedSignalV2& SnapStartedSignal();
503
504   /**
505    * Connects a callback function with the object's signals.
506    * @param[in] object The object providing the signal.
507    * @param[in] tracker Used to disconnect the signal.
508    * @param[in] signalName The signal to connect to.
509    * @param[in] functor A newly allocated FunctorDelegate.
510    * @return True if the signal was connected.
511    * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
512    */
513   static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
514
515 private: // private overriden functions from CustomActorImpl and Controls
516
517   /**
518    * @copydoc Dali::CustomActorImpl::OnSizeAnimation(Animation&, const Vector3&)
519    */
520   virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize);
521
522   /**
523    * @copydoc Dali::Control::OnControlSizeSet(const Vector3&)
524    */
525   virtual void OnControlSizeSet( const Vector3& size );
526
527   /**
528    * From CustomActorImpl; called after a child has been added to the owning actor.
529    * @param[in] child The child which has been added.
530    */
531   virtual void OnChildAdd(Actor& child);
532
533   /**
534    * From CustomActorImpl; called shortly before a child is removed from the owning actor.
535    * @param[in] child The child being removed.
536    */
537   virtual void OnChildRemove(Actor& child);
538
539   /**
540    * @copydoc Dali::CustomActorImpl::OnPropertySet( Property::Index index, Property::Value propertyValue )
541    */
542   virtual void OnPropertySet( Property::Index index, Property::Value propertyValue );
543
544   /**
545    * From CustomActorImpl; called after a touch-signal is received by the owning actor.
546    *
547    * We don't listen to these events as content within the contain may consume events.
548    *
549    * @param[in] event The touch event.
550    * @return True if the event should be consumed.
551    */
552   virtual bool OnTouchEvent(const TouchEvent& event);
553
554   /**
555    * From CustomActorImpl; called after a mouse-wheel-event is received by the owning actor.
556    * @param[in] event The mouse wheel event.
557    * @return True if the event should be consumed.
558    */
559   virtual bool OnMouseWheelEvent(const MouseWheelEvent& event);
560
561   /**
562    * @copydoc Toolkit::Control::OnInitialize()
563    */
564   virtual void OnInitialize();
565
566   /**
567    * @copydoc Toolkit::Control::OnControlStageConnection()
568    */
569   virtual void OnControlStageConnection();
570
571   /**
572    * @copydoc Toolkit::Control::OnControlStageConnection()
573    */
574   virtual void OnControlStageDisconnection();
575
576   /**
577    * @copydoc Toolkit::Control::OnAccessibilityPan()
578    */
579   virtual bool OnAccessibilityPan(PanGesture gesture);
580
581   /**
582    * @copydoc Toolkit::Scrollable::SetOvershootEnabled()
583    */
584   virtual void SetOvershootEnabled(bool enable);
585
586 private:
587
588   /**
589    * Start a timer which calls OnTouchDownTimeout()
590    */
591   void StartTouchDownTimer();
592
593   /**
594    * Stop a timer which calls OnTouchDownTimeout()
595    */
596   void StopTouchDownTimer();
597
598   /**
599    * Helper to detect when touch-point has been down (outside of pan gesture)
600    */
601   bool OnTouchDownTimeout();
602
603   /**
604    * Called whenever a snap animation has completed
605    * @param[in] source the Animation instance that has completed.
606    * Resets all scrolling animations and states, leaving current scroll position at mPropertyPosition
607    */
608   void ResetScrolling();
609
610   /**
611    * Updates mScrollInternalPosition, mScrollPrePosition and mScrollPostPosition from their property counterparts
612    */
613   void UpdateLocalScrollProperties();
614
615   /**
616    * Makes sure scroll values are ready for animated scrolling
617    */
618   void PreAnimatedScrollSetup();
619
620   /**
621    * Finish an animated scroll, ensuring all scroll properties are updated
622    * and synchronised
623    */
624   void FinaliseAnimatedScroll();
625
626   /**
627    * Animates the internal x property to the given value
628    *
629    * @param[in] position The X position to animate to
630    * @param[in] duration The time in seconds for animation
631    * @param[in] alpha The alpha function to use for animating
632    */
633   void AnimateInternalXTo( float position, float duration, AlphaFunction alpha );
634
635   /**
636    * Animates the internal y property to the given value
637    *
638    * @param[in] position The Y position to animate to
639    * @param[in] duration The time in seconds for animation
640    * @param[in] alpha The alpha function to use for animating
641    */
642   void AnimateInternalYTo( float position, float duration, AlphaFunction alpha );
643
644   /**
645    * Called whenever a snap animation on the x-axis has completed
646    * @param[in] source the Animation instance that has completed.
647    */
648   void OnScrollAnimationFinished( Animation& source );
649
650   /**
651    * Called when either the X or Y internal scroll positions have finished snapping back to mPropertyPrePosition
652    *
653    * @param[in] source the Animation instance that has completed.
654    */
655   void OnSnapInternalPositionFinished( Animation& source );
656
657   /**
658    * Called whenever a snap animation on the x-axis has completed and we need to snap pre scroll
659    * position to our clamped position
660    * @param[in] position The x position to snap pre scroll property to
661    */
662   void SnapInternalXTo( float position );
663
664   /**
665    * Called whenever a snap animation on the y-axis has completed and we need to snap pre scroll
666    * position to our clamped position
667    * @param[in] position The y position to snap pre scroll property to
668    */
669   void SnapInternalYTo( float position );
670
671   /**
672    * This is called internally whenever the Scroll Rulers are
673    * modified. This will update the properties: 'scroll-position-min'
674    * and 'scroll-position-max' to reflect the changes.
675    *
676    * @param[in] size size of the visible scroll area (ScrollView control size)
677    */
678   void UpdatePropertyDomain(const Vector3& size);
679
680   /**
681    * Called when the gesture starts.
682    */
683   void GestureStarted();
684
685   /**
686    * Amalgamated Gesture Continuing event
687    *
688    * @param[in] panDelta average panning delta from base position (0)
689    */
690   void GestureContinuing(const Vector2& panDelta);
691
692   /**
693    * Called upon pan gesture event.
694    *
695    * @param[in] gesture The gesture event.
696    */
697   void OnPan(PanGesture pan);
698
699   /**
700    * Extension of the above gestures.
701    *
702    * @param[in] gesture The gesture event.
703    */
704   void OnGestureEx(Gesture::State state);
705
706   /**
707    * Performs snapping while taking into account Velocity of gesture
708    * (velocity in pixels/sec)
709    *
710    * @param[in] velocity velocity in pixels/sec
711    */
712   bool SnapWithVelocity(Vector2 velocity);
713
714   /**
715    * Finishes Container Transform
716    * (occurs upon finishing gesture i.e. releasing)
717    */
718   void FinishTransform();
719
720   /**
721    * Returns overshoot vector based on current position
722    *
723    * Overshoot vector is defined as how far outside of bounds
724    * the viewport is trying to view (prior to being clamped).
725    *
726    * an overshoot of (100,50), means user is in bottom right corner,
727    * trying to pan +100 to the right, and +50 below. This can be used
728    * to determine an effect, such as stretching.
729    *
730    * @param[in] position The position for which you wish to obtain overshoot vector
731    */
732   Vector3 GetOvershoot(Vector3& position) const;
733
734   /**
735    * Clamps position within the domain set up by X/Y Rulers
736    *
737    * @param[in,out] position The position you wish to clamp
738    */
739   void ClampPosition(Vector3& position) const;
740
741   /**
742    * Clamps position within the domain set up by X/Y Rulers
743    *
744    * @param[in,out] position The position you wish to clamp
745    * @param[out] clamped The results of the clamping.
746    */
747   void ClampPosition(Vector3& position, ClampState3 &clamped) const;
748
749   /**
750    * Wraps position within the domain set up by X/Y Rulers
751    *
752    * @note Only wraps if mWrapMode is enabled, and respective domains
753    * are enabled.
754    *
755    * @param[in,out] position The position you wish to wrap
756    */
757   void WrapPosition(Vector3& position) const;
758
759   /**
760    * Updates the main internal scroll constraints with new ruler and domain
761    * values
762    */
763   void UpdateMainInternalConstraint();
764
765   /**
766    * Enables/disables the overshoot constraints
767    *
768    * @param[in] enabled whether to enable or disable the overshoot constraints
769    */
770   void SetOvershootConstraintsEnabled(bool enabled);
771
772   /**
773    * Sets internal constraints for this ScrollView.
774    * Many of these internal constraints are based on properties within
775    * ScrollView.
776    */
777   void SetInternalConstraints();
778
779 protected:
780
781   /**
782    * Construct a new ScrollView.
783    */
784   ScrollView();
785
786   /**
787    * A reference counted object may only be deleted by calling Unreference()
788    */
789   virtual ~ScrollView();
790
791 private:
792
793   /**
794    * Searches this ScrollView, and attempts to Unbind
795    * systematically this Actor from the ScrollView attached.
796    *
797    * @param[in] child The actor to be unbound.
798    */
799   virtual void FindAndUnbindActor(Actor child);
800
801   /**
802    * Gets position property.
803    *
804    * @return The current position
805    */
806   Vector3 GetPropertyPrePosition() const;
807
808   /**
809    * Gets position property.
810    *
811    * @return The current position
812    */
813   Vector3 GetPropertyPosition() const;
814
815   /**
816    * Handles a Stopped animation. Its position properties need to be saved, and the animation flag
817    * switched off.
818    */
819   void HandleStoppedAnimation();
820
821   /**
822    * Handles a Stopped animation (whether the animation completed, or was
823    * manually stopped). Its position properties need to be saved, and the
824    * animation flag switched off.
825    */
826   void HandleSnapAnimationFinished();
827
828   /**
829    * Checks if the property notifications are active and adds them if not
830    */
831   void SetScrollUpdateNotification( bool enabled );
832
833   /**
834    * Refresh the ScrollView (used when animating to update application developer of changes)
835    * @return True if the refresh timer should be kept running.
836    */
837   void OnScrollUpdateNotification(Dali::PropertyNotification& source);
838
839 private:
840
841   // Undefined
842   ScrollView(const ScrollView&);
843
844   // Undefined
845   ScrollView& operator=(const ScrollView& rhs);
846
847 private:
848
849   unsigned long mTouchDownTime;         ///< The touch down time
850
851   int mGestureStackDepth;               ///< How many gestures are currently occuring.
852   Vector2 mPanStartPosition;            ///< Where the pan gesture's touch down occured
853   Vector3 mPanDelta;                    ///< Amount currently panned.
854
855   unsigned int mScrollStateFlags;       ///< flags indicating current state of scrolling
856   // Scroll delegate pre and post position properties...
857   Vector3 mScrollPrePosition;           ///< Wrapped scroll position, but not clamped
858   Vector3 mScrollPostPosition;          ///< Wrapped and clamped, this is the final scroll position used
859   Vector3 mScrollTargetPosition;        ///< Final target position for an animated scroll
860   Vector3 mDomainOffset;                ///< Domain offset (this keeps track of the domain boundaries that scroll positions traverses)
861
862   // Rulers for each axes...
863   RulerPtr mRulerX;
864   RulerPtr mRulerY;
865
866   // Last property values set to ScrollView
867   Vector3 mMinScroll;
868   Vector3 mMaxScroll;
869
870   unsigned int mMinTouchesForPanning;   ///< Minimum number of touches for panning to be used.
871   unsigned int mMaxTouchesForPanning;   ///< Maximum number of touches for panning to be used.
872
873   Animation mInternalXAnimation;        ///< Animates mPropertyX to a snap position or application requested scroll position
874   Animation mInternalYAnimation;        ///< Animates mPropertyY to a snap position or application requested scroll position
875
876
877   Vector2 mLastVelocity;                ///< Record the last velocity from PanGesture (Finish event doesn't have correct velocity)
878   LockAxis mLockAxis;
879
880   Timer mTouchDownTimer;                ///< Used to interrupt snap-animation. This cannot be done in OnTouchEvent without breaking fast flick behavior.
881
882   float mScrollUpdateDistance;          ///< Distance for scrolling to travel for the scroll update notifications
883   Dali::PropertyNotification mScrollXUpdateNotification; ///< scroll x position update notification
884   Dali::PropertyNotification mScrollYUpdateNotification; ///< scroll y position update notification
885
886   Actor mInternalActor;                 ///< Internal actor (we keep internal actors in here e.g. scrollbars, so we can ignore it in searches)
887
888   ScrollViewEffectContainer mEffects;   ///< Container keeping track of all the applied effects.
889
890   float     mOvershootDelay;                    ///< Time to wait for input before reducing overshoot back to 0
891   Vector2   mMaxOvershoot;                      ///< Number of scrollable pixels that will take overshoot from 0.0f to 1.0f
892   Vector2   mUserMaxOvershoot;                  ///< Set by user, allows overriding of default max overshoot for the scroll indicator
893   float     mSnapOvershootDuration;             ///< Duration for overshoot snapping back to Vector3::ZERO
894   AlphaFunction mSnapOvershootAlphaFunction;    ///< AlphaFunction to be used for this overshoot.
895
896   float mSnapDuration;                          ///< Time for the snap animation to take (in seconds).
897   AlphaFunction mSnapAlphaFunction;             ///< AlphaFunction to be used for the Snap Animation.
898
899   Vector2 mMinFlickDistance;                      ///< Minimum pan distance required for a flick
900   float mFlickSpeedThreshold;                   ///< Minimum pan speed required for a flick in pixels/ms
901   float mFlickDuration;                         ///< Time for the flick animation to take (in seconds).
902   AlphaFunction mFlickAlphaFunction;            ///< AlphaFunction to be used for the Flick Animation.
903
904   float mAxisAutoLockGradient;                  ///< Axis Auto-lock gradient threshold. Above this gradient and it will lock scrolling to closest axis.
905   float mFrictionCoefficient;                   ///< Friction coefficient. Amount of friction to apply to free panning flick animation. in stage.lengths/sec
906   float mFlickSpeedCoefficient;                 ///< Flick velocity coefficient. Input touch velocity is multiplied by this.
907   float mMaxFlickSpeed;                         ///< Maximum flick speed. Maximum speed of flick in stage.lengths/sec.
908
909   Vector2 mMouseWheelScrollDistanceStep;        ///< The step of scroll distance in actor coordinates in X and Y axes for each mouse wheel event received.
910
911   //ScrollInternalConstraintsPtr mScrollInternalConstraints;
912   ActiveConstraint mScrollMainInternalPrePositionConstraint;
913   ActiveConstraint mScrollMainInternalPositionConstraint;
914   ActiveConstraint mScrollMainInternalOvershootXConstraint;
915   ActiveConstraint mScrollMainInternalOvershootYConstraint;
916   ActiveConstraint mScrollMainInternalDeltaConstraint;
917   ActiveConstraint mScrollMainInternalFinalConstraint;
918   ActiveConstraint mScrollMainInternalRelativeConstraint;
919
920   ScrollOvershootIndicatorPtr mOvershootIndicator;
921
922   Toolkit::ScrollView::SnapStartedSignalV2 mSnapStartedSignalV2;
923
924   bool mInAccessibilityPan : 1;           ///< With AccessibilityPan its easier to move between snap positions
925   bool mInitialized:1;
926   bool mScrolling:1;                      ///< Flag indicating whether the scroll view is being scrolled (by user or animation)
927   bool mScrollInterrupted:1;              ///< Flag set for when a down event interrupts a scroll
928   bool mPanning:1;                        ///< Whether scroll view is currently panning or not
929   bool mSensitive:1;                      ///< Scroll Sensitivity Flag.
930   bool mTouchDownTimeoutReached:1;        ///< Indicates when down event timeout occured without corresponding up event (touch still down)
931   bool mActorAutoSnapEnabled:1;           ///< Whether to automatically snap to closest actor.
932   bool mAutoResizeContainerEnabled:1;     ///< Whether to automatically resize container (affects RulerDomain's on X/Y axes)
933   bool mWrapMode:1;                       ///< Whether to wrap contents based on container size.
934   bool mAxisAutoLock:1;                   ///< Whether to automatically lock axis when panning.
935   bool mAlterChild:1;                     ///< Internal flag to control behavior of OnChildAdd/OnChildRemove when Adding internal Actors.
936   bool mDefaultMaxOvershoot:1;            ///< Whether to use default max overshoot or application defined one
937   bool mCanScrollHorizontal:1;            ///< Local value of our property to check against
938   bool mCanScrollVertical:1;              ///< Local value of our property to check against
939 };
940
941 } // namespace Internal
942
943 // Helpers for public-api forwarding methods
944
945 inline Toolkit::Internal::ScrollView& GetImpl(Toolkit::ScrollView& scrollView)
946 {
947   DALI_ASSERT_ALWAYS(scrollView);
948
949   Dali::RefObject& handle = scrollView.GetImplementation();
950
951   return static_cast<Toolkit::Internal::ScrollView&>(handle);
952 }
953
954 inline const Toolkit::Internal::ScrollView& GetImpl(const Toolkit::ScrollView& scrollView)
955 {
956   DALI_ASSERT_ALWAYS(scrollView);
957
958   const Dali::RefObject& handle = scrollView.GetImplementation();
959
960   return static_cast<const Toolkit::Internal::ScrollView&>(handle);
961 }
962
963 } // namespace Toolkit
964
965 } // namespace Dali
966
967 #endif // __DALI_TOOLKIT_INTERNAL_SCROLL_VIEW_H__