License conversion from Flora to Apache 2.0
[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::ControlImpl::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    * Called whenever a snap animation has completed
561    * @param[in] source the Animation instance that has completed.
562    */
563   void OnSnapAnimationFinished( Animation& source );
564
565   /**
566    * Called whenever a snap animation on the x-axis has completed
567    * @param[in] source the Animation instance that has completed.
568    */
569   void OnSnapXAnimationFinished( Animation& source );
570
571   /**
572    * Called whenever a snap animation on the y-axis has completed
573    * @param[in] source the Animation instance that has completed.
574    */
575   void OnSnapYAnimationFinished( Animation& source );
576
577   /**
578    * This is called internally whenever the Scroll Rulers are
579    * modified. This will update the properties: 'scroll-position-min'
580    * and 'scroll-position-max' to reflect the changes.
581    *
582    * @param[in] size size of the visible scroll area (ScrollView control size)
583    */
584   void UpdatePropertyDomain(const Vector3& size);
585
586   /**
587    * Called when the gesture starts.
588    */
589   void GestureStarted();
590
591   /**
592    * Amalgamated Gesture Continuing event
593    *
594    * @param[in] panDelta average panning delta from base position (0)
595    * @param[in] scaleDelta average scale delta from base scale (1)
596    * @param[in] rotationDelta average rotation delta from base angle (0)
597    */
598   void GestureContinuing(Vector2 panDelta, Vector2 scaleDelta, float rotationDelta);
599
600   /**
601    * Called upon pan gesture event.
602    *
603    * @param[in] gesture The gesture event.
604    */
605   void OnPan(PanGesture pan);
606
607   /**
608    * Extension of the above gestures.
609    *
610    * @param[in] gesture The gesture event.
611    */
612   void OnGestureEx(Gesture::State state);
613
614   /**
615    * Performs snapping while taking into account Velocity of gesture
616    * (velocity in pixels/sec)
617    *
618    * @param[in] velocity velocity in pixels/sec
619    */
620   bool SnapWithVelocity(Vector2 velocity);
621
622   /**
623    * Updates Container Transform based on Pan, Scale, and Rotation props.
624    * (occurs when continuing gesture i.e. dragging/pinching.)
625    */
626   void UpdateTransform();
627
628   /**
629    * Finishes Container Transform
630    * (occurs upon finishing gesture i.e. releasing)
631    */
632   void FinishTransform();
633
634   /**
635    * Sets Overshoot to origin / cancels animation
636    */
637   void SetOvershootToOrigin();
638
639   /**
640    * Animates Overshoot to origin
641    */
642   void AnimateOvershootToOrigin(float xDelay, float yDelay);
643
644   /**
645    * Called whenever a snap overshoot animation has completed.
646    * @param[in] source the Animation instance that has completed.
647    */
648   void OnSnapOvershootAnimationFinished( Animation& source );
649
650   /**
651    * Returns overshoot vector based on current position
652    *
653    * Overshoot vector is defined as how far outside of bounds
654    * the viewport is trying to view (prior to being clamped).
655    *
656    * an overshoot of (100,50), means user is in bottom right corner,
657    * trying to pan +100 to the right, and +50 below. This can be used
658    * to determine an effect, such as stretching.
659    *
660    * @param[in] position The position for which you wish to obtain overshoot vector
661    */
662   Vector3 GetOvershoot(Vector3& position) const;
663
664   /**
665    * Clamps position within the domain set up by X/Y Rulers
666    *
667    * @param[in,out] position The position you wish to clamp
668    */
669   void ClampPosition(Vector3& position) const;
670
671   /**
672    * Clamps position within the domain set up by X/Y Rulers
673    *
674    * @param[in,out] position The position you wish to clamp
675    * @param[out] clamped The results of the clamping.
676    */
677   void ClampPosition(Vector3& position, ClampState3 &clamped) const;
678
679   /**
680    * Wraps position within the domain set up by X/Y Rulers
681    *
682    * @note Only wraps if mWrapMode is enabled, and respective domains
683    * are enabled.
684    *
685    * @param[in,out] position The position you wish to wrap
686    */
687   void WrapPosition(Vector3& position) const;
688
689   /**
690    * Clamps scale within the domain set up by Scale-X/Scale-Y Rulers
691    *
692    * @param[in,out] scale The scale you wish to clamp
693    */
694   void ClampScale(Vector3& scale) const;
695
696   /**
697    * Clamps scale within the domain set up by Scale-X/Scale-Y Rulers
698    *
699    * @param[in,out] scale The scale you wish to clamp
700    * @param[out] clamped The results of the clamping.
701    */
702   void ClampScale(Vector3& scale, ClampState3 &clamped) const;
703
704   /**
705    * Updates the main internal scroll constraints with new ruler and domain
706    * values
707    */
708   void UpdateMainInternalConstraint();
709
710   /**
711    * Enables/disables the overshoot constraints
712    *
713    * @param[in] enabled whether to enable or disable the overshoot constraints
714    */
715   void SetOvershootConstraintsEnabled(bool enabled);
716
717   /**
718    * Sets internal constraints for this ScrollView.
719    * Many of these internal constraints are based on properties within
720    * ScrollView.
721    */
722   void SetInternalConstraints();
723
724 protected:
725
726   /**
727    * Construct a new ScrollView.
728    */
729   ScrollView();
730
731   /**
732    * A reference counted object may only be deleted by calling Unreference()
733    */
734   virtual ~ScrollView();
735
736 private:
737
738   /**
739    * Searches this ScrollView, and attempts to Unbind
740    * systematically this Actor from the ScrollView attached.
741    *
742    * @param[in] child The actor to be unbound.
743    */
744   virtual void FindAndUnbindActor(Actor child);
745
746   /**
747    * Gets position property.
748    *
749    * @return The current position
750    */
751   Vector3 GetPropertyPrePosition() const;
752
753   /**
754    * Gets position property.
755    *
756    * @return The current position
757    */
758   Vector3 GetPropertyPosition() const;
759
760   /**
761    * Gets scale property.
762    *
763    * @return The current scale
764    */
765   Vector3 GetPropertyScale() const;
766
767   /**
768    * Handles a Stopped animation. Its position/scale/rotation properties need to be
769    * saved, and the animation flag switched off.
770    */
771   void HandleStoppedAnimation();
772
773   /**
774    * Handles a Stopped animation (whether the animation completed, or was
775    * manually stopped). Its position/scale/rotation properties need to be
776    * saved, and the animation flag switched off.
777    */
778   void HandleSnapAnimationFinished();
779
780   /**
781    * Helper to start the refresh timer.
782    */
783   void StartRefreshTimer();
784
785   /**
786    * Helper to cancel the refresh timer.
787    */
788   void CancelRefreshTimer();
789
790   /**
791    * Refresh the ScrollView (used when animating to update application developer of changes)
792    * @return True if the refresh timer should be kept running.
793    */
794   bool OnRefreshTick();
795
796 private:
797
798   // Undefined
799   ScrollView(const ScrollView&);
800
801   // Undefined
802   ScrollView& operator=(const ScrollView& rhs);
803
804 private:
805
806   bool mInitialized;
807   bool mScrolling;                      ///< Flag indicating whether the scroll view is being scrolled (by user or animation)
808   bool mScrollInterrupted;              ///< Flag set for when a down event interrupts a scroll
809   unsigned long mTouchDownTime;         ///< The touch down time
810   Vector2 mTouchDownPosition;           ///< The touch down position
811
812   bool mSensitive;                      ///< Scroll Sensitivity Flag.
813
814   int mGestureStackDepth;               ///< How many gestures are currently occuring.
815   Vector2 mGestureReferencePosition;    ///< Point where scaling should occur from.
816   Vector2 mPinchGestureLastPosition;
817   Vector2 mPinchGestureLastScale;
818
819   Vector3 mPanDelta;                    ///< Amount currently panned.
820   Vector3 mScaleDelta;                  ///< Amount currently scaled.
821   float mRotationDelta;                 ///< Amount currently rotated.
822
823   // Scroll delegate pre and post position/scale/rotation properties...
824   Vector3 mScrollPrePosition;           ///< Scroll delegate pre-position
825   Vector3 mScrollPostPosition;          ///< Scroll delegate post-position (affected by current touch)
826   Vector3 mScrollPreScale;              ///< Scroll delegate pre-scale
827   Vector3 mScrollPostScale;             ///< Scroll delegate post-scale (affected by current touch)
828   float mScrollPreRotation;             ///< Scroll delegate pre-rotation
829   float mScrollPostRotation;            ///< Scroll delegate post-rotation (affected by current touch)
830   Vector3 mDomainOffset;                ///< Domain offset (this keeps track of the domain boundaries that scroll positions traverses)
831
832   // Rulers for each axes...
833   RulerPtr mRulerX;
834   RulerPtr mRulerY;
835   RulerPtr mRulerScaleX;
836   RulerPtr mRulerScaleY;
837   RulerPtr mRulerRotation;
838   bool mTouchDownReceived;
839   bool mActorAutoSnapEnabled;           ///< Whether to automatically snap to closest actor.
840   bool mAutoResizeContainerEnabled;     ///< Whether to automatically resize container (affects RulerDomain's on X/Y axes)
841   bool mWrapMode;                       ///< Whether to wrap contents based on container size.
842   bool mAxisAutoLock;                   ///< Whether to automatically lock axis when panning.
843   unsigned int mMinTouchesForPanning;   ///< Minimum number of touches for panning to be used.
844   unsigned int mMaxTouchesForPanning;   ///< Maximum number of touches for panning to be used.
845
846   Animation mSnapAnimation;
847   Animation mSnapXAnimation;             ///< Animates from current x-axis position to the snapped (or scrolled) x-axis position.
848   Animation mSnapYAnimation;             ///< Animates from current y-axis position to the snapped (or scrolled) y-axis position.
849   Animation mSnapOvershootAnimation;    ///< Animates scroll-overshoot from current position to 0,0 based on specified easing equation.
850
851
852   Vector2 mLastVelocity;                ///< Record the last velocity from PanGesture (Finish event doesn't have correct velocity)
853   LockAxis mLockAxis;
854
855   Timer mOvershootRefreshTimer;
856   Timer mRefreshTimer;                  ///< Refresh timer is used to provide the Application developer with updates as animations run.
857   int mRefreshIntervalMilliseconds;     ///< Refresh timer interval.
858
859   bool mAlterChild;                     ///< Internal flag to control behavior of OnChildAdd/OnChildRemove when Adding internal Actors.
860   Actor mInternalActor;                 ///< Internal actor (we keep internal actors in here e.g. scrollbars, so we can ignore it in searches)
861
862   ScrollViewEffectContainer mEffects;   ///< Container keeping track of all the applied effects.
863
864   float     mOvershootDelay;                    ///< Time to wait for input before reducing overshoot back to 0
865   Vector2   mMaxOvershoot;                      ///< Number of scrollable pixels that will take overshoot from 0.0f to 1.0f
866   bool      mDefaultMaxOvershoot;               ///< Whether to use default max overshoot or application defined one
867   float     mSnapOvershootDuration;             ///< Duration for overshoot snapping back to Vector3::ZERO
868   AlphaFunction mSnapOvershootAlphaFunction;    ///< AlphaFunction to be used for this overshoot.
869
870   float mSnapDuration;                          ///< Time for the snap animation to take (in seconds).
871   AlphaFunction mSnapAlphaFunction;             ///< AlphaFunction to be used for the Snap Animation.
872
873   float mFlickDuration;                         ///< Time for the flick animation to take (in seconds).
874   AlphaFunction mFlickAlphaFunction;            ///< AlphaFunction to be used for the Flick Animation.
875
876   float mAxisAutoLockGradient;                  ///< Axis Auto-lock gradient threshold. Above this gradient and it will lock scrolling to closest axis.
877   float mFrictionCoefficient;                   ///< Friction coefficient. Amount of friction to apply to free panning flick animation. in stage.lengths/sec
878   float mFlickSpeedCoefficient;                 ///< Flick velocity coefficient. Input touch velocity is multiplied by this.
879   float mMaxFlickSpeed;                         ///< Maximum flick speed. Maximum speed of flick in stage.lengths/sec.
880
881   Vector2 mMouseWheelScrollDistanceStep;        ///< The step of scroll distance in actor coordinates in X and Y axes for each mouse wheel event received.
882
883   //ScrollInternalConstraintsPtr mScrollInternalConstraints;
884   ActiveConstraint mScrollMainInternalPrePositionConstraint;
885   ActiveConstraint mScrollMainInternalPositionConstraint;
886   ActiveConstraint mScrollMainInternalXConstraint;
887   ActiveConstraint mScrollMainInternalYConstraint;
888   ActiveConstraint mScrollMainInternalOvershootXConstraint;
889   ActiveConstraint mScrollMainInternalOvershootYConstraint;
890   ActiveConstraint mScrollMainInternalDeltaConstraint;
891   ActiveConstraint mScrollMainInternalFinalConstraint;
892   ActiveConstraint mScrollMainInternalRelativeConstraint;
893
894   ScrollOvershootIndicatorPtr mOvershootIndicator;
895
896   Toolkit::ScrollView::SnapStartedSignalV2 mSnapStartedSignalV2;
897 };
898
899 } // namespace Internal
900
901 // Helpers for public-api forwarding methods
902
903 inline Toolkit::Internal::ScrollView& GetImpl(Toolkit::ScrollView& scrollView)
904 {
905   DALI_ASSERT_ALWAYS(scrollView);
906
907   Dali::RefObject& handle = scrollView.GetImplementation();
908
909   return static_cast<Toolkit::Internal::ScrollView&>(handle);
910 }
911
912 inline const Toolkit::Internal::ScrollView& GetImpl(const Toolkit::ScrollView& scrollView)
913 {
914   DALI_ASSERT_ALWAYS(scrollView);
915
916   const Dali::RefObject& handle = scrollView.GetImplementation();
917
918   return static_cast<const Toolkit::Internal::ScrollView&>(handle);
919 }
920
921 } // namespace Toolkit
922
923 } // namespace Dali
924
925 #endif // __DALI_TOOLKIT_INTERNAL_SCROLL_VIEW_H__