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