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