Merge "Add Visual descriptions to generate doxygen page" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / public-api / controls / scrollable / scroll-view / scroll-view.h
1 #ifndef __DALI_TOOLKIT_SCROLL_VIEW_H__
2 #define __DALI_TOOLKIT_SCROLL_VIEW_H__
3
4 /*
5  * Copyright (c) 2015 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/public-api/animation/alpha-function.h>
23
24 // INTERNAL INCLUDES
25 #include <dali-toolkit/public-api/controls/scrollable/scrollable.h>
26
27 namespace Dali
28 {
29
30 namespace Toolkit
31 {
32
33 namespace Internal DALI_INTERNAL
34 {
35 class ScrollView;
36 }
37 /**
38  * @addtogroup dali_toolkit_controls_scroll_view
39  * @{
40  */
41
42 /**
43  * @brief Enumeration for how axes/rotation or scale are clamped.
44  * @SINCE_1_0.0
45  */
46 enum ClampState
47 {
48   NotClamped,   ///< The quantity isn't clamped @SINCE_1_0.0
49   ClampedToMin, ///< The quantity is clamped to the min value @SINCE_1_0.0
50   ClampedToMax  ///< The quantity is clamped to the max value @SINCE_1_0.0
51 };
52
53 /**
54  * @brief A 2 dimensional clamp.
55  * @SINCE_1_0.0
56  */
57 struct ClampState2D
58 {
59   ClampState x; ///< The clamp state of the x axis
60   ClampState y; ///< The clamp state of the y axis
61 };
62
63 /**
64  * @brief Enumeration for the snap type.
65  * @SINCE_1_0.0
66  */
67 enum SnapType
68 {
69   Snap,  ///< Snap @SINCE_1_0.0
70   Flick  ///< Flick @SINCE_1_0.0
71 };
72
73 /**
74  * @brief Enumeration for DirectionBias types.
75  * @SINCE_1_0.0
76  */
77 enum DirectionBias
78 {
79   DirectionBiasLeft  = -1,  ///< Bias scroll snap to Left @SINCE_1_0.0
80   DirectionBiasNone  =  0,  ///< Don't bias scroll snap @SINCE_1_0.0
81   DirectionBiasRight =  1   ///< Bias scroll snap to Right @SINCE_1_0.0
82 };
83
84 /**
85  * @brief Used for specifying minimum/maximum extents of a ruler.
86  * @SINCE_1_0.0
87  */
88 class DALI_IMPORT_API RulerDomain
89 {
90 public:
91
92   /**
93    * @brief Creates Ruler domain allowing a point to traverse between min and max extents.
94    *
95    * @SINCE_1_0.0
96    * @param[in] min Minimum extent (point cannot traverse less than this)
97    * @param[in] max Maximum extent (point cannot traverse greater than this)
98    * @param[in] enabled Whether domain has been enabled or not
99    */
100   explicit RulerDomain(float min, float max, bool enabled = true);
101
102 public:
103
104   float min;    ///< Minimum extent (point cannot traverse less than this)
105   float max;    ///< Maximum extent (point cannot traverse greater than this)
106   bool enabled; ///< Whether domain has been enabled or not.
107
108   /**
109    * @brief Clamps value (x) from (min) to (max).
110    *
111    * An optional length parameter can be specified to suggest that the
112    * subject is not a point but a line to that should be clamped.
113    *
114    * @SINCE_1_0.0
115    * @param[in] x X point to be clamped between (min) and (max) extents
116    * @param[in] length (optional) The Length of the line from (x) to (x + length) to be clamped
117    * @param[in] scale Scaling parameter which treats domain as scaled in calculations
118    * @return The clamped value
119    */
120   float Clamp(float x, float length = 0.0f, float scale = 1.0f) const;
121
122   /**
123    * @brief Clamps value (x) from (min) to (max).
124    *
125    * An optional length parameter can be specified to suggest that the
126    * subject is not a point but a line to that should be clamped.
127    *
128    * @SINCE_1_0.0
129    * @param[in] x X point to be clamped between (min) and (max) extents
130    * @param[in] length (optional) The Length of the line from (x) to (x + length) to be clamped
131    * @param[in] scale Scaling parameter which treats domain as scaled in calculations
132    * @param[out] clamped Whether clamping occurred and which size (None, Min or Max)
133    * @return The clamped value
134    */
135   float Clamp(float x, float length, float scale, ClampState &clamped) const;
136
137   /**
138    * @brief Returns (max-min) size of ruler.
139    *
140    * @SINCE_1_0.0
141    * @return The size of the ruler from min to max
142    */
143   float GetSize() const;
144
145 };
146
147 // Forward declare future extension interface
148 class RulerExtension;
149
150 /**
151  * @brief Abstracts class to define scroll axes.
152  *
153  * It can specify whether they are traversable,
154  * where their snap points are and their domain.
155  * @SINCE_1_0.0
156  */
157 class DALI_IMPORT_API Ruler : public RefObject
158 {
159 public:
160   /// @brief The type of the ruler
161   enum RulerType {
162     Fixed,  ///< A fixed ruler @SINCE_1_0.0
163     Free    ///< A free ruler @SINCE_1_0.0
164   };
165
166 public:
167
168   /**
169    * @brief Constructs ruler, enabled by default, with limitless domain.
170    * @SINCE_1_0.0
171    */
172   Ruler();
173
174   /**
175    * @brief Snaps (x) in accordance to the ruler settings.
176    *
177    * @SINCE_1_0.0
178    * @param[in] x The input value on the ruler to be snapped
179    * @param[in] bias (optional) The biasing employed for snapping
180    * 0 floor input (floor x) "Used for Flick Left"
181    * 0.5 round input (floor x + 0.5) "Used for Release"
182    * 1 ceil input (floor x + 1.0) "Used for Flick Right"
183    * @return The position of the one dimensional point passed in once snapped.
184    */
185   virtual float Snap(float x, float bias = 0.5f) const = 0;
186
187   /**
188    * @brief Returns position from page, based on whatever the ruler
189    * defines as a page.
190    *
191    * If (wrap) is true, then will set volume to the number of
192    * times page has exceeded the domain's volume (volume being the
193    * number of pages within the domain), while wrapping the position
194    * within the domain.
195    *
196    * @SINCE_1_0.0
197    * @param[in] page The page index
198    * @param[out] volume The overflow volume when the page exceeds the domain (wrap must be enabled)
199    * @param[in] wrap Enable wrap mode
200    * @return The position representing this page point
201    */
202   virtual float GetPositionFromPage(unsigned int page, unsigned int &volume, bool wrap) const = 0;
203
204   /**
205    * @brief Returns page from position, based on whatever the ruler
206    * defines as a page.
207    *
208    * If (wrap) is true, then will return a page wrapped within the domain.
209    *
210    * @SINCE_1_0.0
211    * @param[in] position The position on the domain
212    * @param[in] wrap Enable wrap mode
213    * @return The page where this position resides
214    */
215   virtual unsigned int GetPageFromPosition(float position, bool wrap) const = 0;
216
217   /**
218    * @brief Returns the total number of pages within this Ruler.
219    *
220    * @SINCE_1_0.0
221    * @return The number of pages in the Ruler
222    */
223   virtual unsigned int GetTotalPages() const = 0;
224
225   /**
226    * @brief Gets the extension interface of the Ruler.
227    *
228    * @SINCE_1_0.0
229    * @return The extension interface of the Ruler
230    */
231   virtual RulerExtension* GetExtension() { return NULL; }
232
233 public:
234
235   /**
236    * @brief Gets the ruler type.
237    *
238    * @SINCE_1_0.0
239    * @return The ruler type
240    */
241   Ruler::RulerType GetType() const;
242
243   /**
244    * @brief Returns whether this axis has been enabled or not.
245    *
246    * @SINCE_1_0.0
247    * @return true if axis is enabled
248    */
249   bool IsEnabled() const;
250
251   /**
252    * @brief Enables ruler (ruler must be enabled in order to traverse along it).
253    * @SINCE_1_0.0
254    */
255   void Enable();
256
257   /**
258    * @brief Disables ruler.
259    * @SINCE_1_0.0
260    */
261   void Disable();
262
263   /**
264    * @brief Sets the Domain.
265    *
266    * @SINCE_1_0.0
267    * @param[in] domain Ruler domain object
268    */
269   void SetDomain(RulerDomain domain);
270
271   /**
272    * @brief Gets the Domain.
273    *
274    * @SINCE_1_0.0
275    * @return The domain
276    */
277   const RulerDomain &GetDomain() const;
278
279   /**
280    * @brief Disables Domain (minimum/maximum extents for this axis).
281    * @SINCE_1_0.0
282    */
283   void DisableDomain();
284
285   /**
286    * @brief Clamps value (x) from (min) to (max).
287    *
288    * An optional length parameter can be specified to suggest that the
289    * subject is not a point but a line that should be clamped.
290    *
291    * @SINCE_1_0.0
292    * @param[in] x X point to be clamped between (min) and (max) extents
293    * @param[in] length (optional) The Length of the line from (x) to (x + length) to be clamped
294    * @param[in] scale Scaling parameter which treats domain as scaled in calculations
295    * @return The clamped value
296    */
297   float Clamp(float x, float length = 0.0f, float scale = 1.0f) const;
298
299
300   /**
301    * @brief Clamps value (x) from (min) to (max).
302    *
303    * An optional length parameter can be specified to suggest that the
304    * subject is not a point but a line to that should be clamped.
305    *
306    * @SINCE_1_0.0
307    * @param[in] x X point to be clamped between (min) and (max) extents
308    * @param[in] length (optional) The Length of the line from (x) to (x + length) to be clamped
309    * @param[in] scale Scaling parameter which treats domain as scaled in calculations
310    * @param[out] clamped Whether clamping occurred and which size (None, Min or Max)
311    * @return The clamped value
312    */
313   float Clamp(float x, float length, float scale, ClampState &clamped) const;
314
315   /**
316    * @brief Snaps and Clamps (x) in accordance to ruler settings.
317    *
318    * @SINCE_1_0.0
319    * @param[in] x X value to be snapped in accordance to ruler snap value,
320    *            and clamped in accordance to the ruler's domain (if set)
321    * @param[in] bias (optional) The biasing employed for snapping
322    *            0 floor input (floor x) "Used for Flick Left"
323    *            0.5 round input (floor x + 0.5) "Used for Release"
324    *            1 ceil input (floor x + 1.0) "Used for Flick Right"
325    * @param[in] length (optional) The Length of the line from (x) to (x + length)
326    *            to be clamped
327    * @param[in] scale Scaling parameter which treats domain as scaled in calculations
328    * @return The clamped value after snapping
329    */
330   float SnapAndClamp(float x, float bias = 0.5f, float length = 0.0f, float scale = 1.0f) const;
331
332   /**
333    * @brief Snaps and Clamps (x) in accordance to ruler settings.
334    *
335    * @SINCE_1_0.0
336    * @param[in] x X value to be snapped in accordance to ruler snap value,
337    *            and clamped in accordance to the ruler's domain (if set)
338    * @param[in] bias (optional) The biasing employed for snapping
339    * 0 floor input (floor x) "Used for Flick Left"
340    * 0.5 round input (floor x + 0.5) "Used for Release"
341    * 1 ceil input (floor x + 1.0) "Used for Flick Right"
342    * @param[in] length (optional) The Length of the line from (x) to (x + length)
343    * to be clamped
344    * @param[in] scale Scaling parameter which treats domain as scaled in calculations
345    * @param[out] clamped Whether clamping occurred and which size (None, Min or Max)
346    * @return The clamped value after snapping
347    */
348   float SnapAndClamp(float x, float bias, float length, float scale, ClampState &clamped) const;
349
350 protected:
351
352   /**
353    * @brief Destructor - A reference counted object may only be deleted by calling Unreference().
354    * @SINCE_1_0.0
355    */
356   virtual ~Ruler();
357
358 protected:
359
360   RulerType mType;               ///< Type of Ruler (Fixed or Free).
361   bool mEnabled;                 ///< If the ruler is enabled.
362   RulerDomain mDomain;           ///< The domain of the ruler.
363
364 };
365
366 typedef IntrusivePtr<Ruler> RulerPtr; ///< Pointer to Dali::Toolkit::Ruler object @SINCE_1_0.0
367
368 /**
369  * @brief Concrete implementation of Ruler that has no snapping and has one single page.
370  * @SINCE_1_0.0
371  */
372 class DALI_IMPORT_API DefaultRuler : public Ruler
373 {
374 public:
375   /**
376    * @brief DefaultRuler constructor.
377    * @SINCE_1_0.0
378    */
379   DefaultRuler();
380
381   /**
382    * @copydoc Toolkit::Ruler::Snap
383    */
384   virtual float Snap(float x, float bias) const;
385
386   /**
387    * @copydoc Toolkit::Ruler::GetPositionFromPage
388    */
389   virtual float GetPositionFromPage(unsigned int page, unsigned int &volume, bool wrap) const;
390
391   /**
392    * @copydoc Toolkit::Ruler::GetPageFromPosition
393    */
394   virtual unsigned int GetPageFromPosition(float position, bool wrap) const;
395
396   /**
397    * @copydoc Toolkit::Ruler::GetTotalPages
398    */
399   virtual unsigned int GetTotalPages() const;
400 };
401
402 /**
403  * @brief Concrete implementation of Ruler that has fixed snapping.
404  * @SINCE_1_0.0
405  */
406 class DALI_IMPORT_API FixedRuler : public Ruler
407 {
408 public:
409   /**
410    * @brief Constructor.
411    *
412    * @SINCE_1_0.0
413    * @param[in] spacing The spacing between each interval on this ruler
414    */
415   FixedRuler(float spacing = 1.0f);
416
417   /**
418    * @copydoc Toolkit::Ruler::Snap
419    */
420   virtual float Snap(float x, float bias) const;
421
422   /**
423    * @copydoc Toolkit::Ruler::GetPositionFromPage
424    */
425   virtual float GetPositionFromPage(unsigned int page, unsigned int &volume, bool wrap) const;
426
427   /**
428    * @copydoc Toolkit::Ruler::GetPageFromPosition
429    */
430   virtual unsigned int GetPageFromPosition(float position, bool wrap) const;
431
432   /**
433    * @copydoc Toolkit::Ruler::GetTotalPages
434    */
435   virtual unsigned int GetTotalPages() const;
436
437 private:
438   float mSpacing; ///< The spacing between each interval
439 };
440
441 class ScrollViewEffect;
442 class ScrollView;
443
444 /**
445  * @brief ScrollView contains actors that can be scrolled manually (via touch)
446  * or automatically.
447  *
448  * Signals
449  * | %Signal Name      | Method                     |
450  * |-------------------|----------------------------|
451  * | snap-started      | @ref SnapStartedSignal()   |
452  * @SINCE_1_0.0
453  */
454 class DALI_IMPORT_API ScrollView : public Scrollable
455 {
456
457 public:
458
459   /**
460    * @brief Clamps signal event's data.
461    * @SINCE_1_0.0
462    */
463   struct ClampEvent
464   {
465     ClampState2D scale;       ///< Clamp information for scale axes
466     ClampState2D position;    ///< Clamp information for position axes
467     ClampState   rotation;    ///< Clamp information for rotation
468   };
469
470   /**
471    * @brief Snaps signal event's data.
472    * @SINCE_1_0.0
473    */
474   struct SnapEvent
475   {
476     SnapType type;    ///< Current snap commencing
477     Vector2 position; ///< Target snap position
478     float duration;   ///< Duration of snap animation.
479   };
480
481   /**
482    * @brief Enumeration for the start and end property ranges for this control.
483    * @SINCE_1_0.0
484    */
485   enum PropertyRange
486   {
487     PROPERTY_START_INDEX = Toolkit::Scrollable::PROPERTY_END_INDEX + 1,                        ///< @SINCE_1_1.18
488     PROPERTY_END_INDEX =   PROPERTY_START_INDEX + 1000,                                        ///< Reserve property indices, @SINCE_1_1.18
489
490     ANIMATABLE_PROPERTY_START_INDEX = Toolkit::Scrollable::ANIMATABLE_PROPERTY_END_INDEX + 1,
491     ANIMATABLE_PROPERTY_END_INDEX   = ANIMATABLE_PROPERTY_START_INDEX + 1000                   ///< Reserve animatable property indices @SINCE_1_0.0
492   };
493
494   /**
495    * @brief Enumeration for the instance of properties belonging to the ScrollView class.
496    * @SINCE_1_0.0
497    */
498   struct Property
499   {
500     /**
501      * @brief Enumeration for the instance of properties belonging to the ScrollView class.
502      * @SINCE_1_0.0
503      */
504     enum
505     {
506       // Event side properties
507       WRAP_ENABLED = PROPERTY_START_INDEX,               ///< Property, name "wrapEnabled",              @see SetWrapMode(),                 type bool,     @SINCE_1_1.18
508       PANNING_ENABLED,                                   ///< Property, name "panningEnabled",           @see SetScrollSensitive(),          type bool,     @SINCE_1_1.18
509       AXIS_AUTO_LOCK_ENABLED,                            ///< Property, name "axisAutoLockEnabled",      @see SetAxisAutoLock(),             type bool,     @SINCE_1_1.18
510       WHEEL_SCROLL_DISTANCE_STEP,                        ///< Property, name "wheelScrollDistanceStep",  @see SetWheelScrollDistanceStep(),  type Vector2,  @SINCE_1_1.18
511
512       SCROLL_POSITION = ANIMATABLE_PROPERTY_START_INDEX, ///< Property, name "scrollPosition",            type Vector2 @SINCE_1_0.0
513       SCROLL_PRE_POSITION,                               ///< Property, name "scrollPrePosition",         type Vector2 @SINCE_1_0.0
514       SCROLL_PRE_POSITION_X,                             ///< Property, name "scrollPrePositionX",        type float @SINCE_1_0.0
515       SCROLL_PRE_POSITION_Y,                             ///< Property, name "scrollPrePositionY",        type float @SINCE_1_0.0
516       SCROLL_PRE_POSITION_MAX,                           ///< Property, name "scrollPrePositionMax",      type Vector2 @SINCE_1_0.0
517       SCROLL_PRE_POSITION_MAX_X,                         ///< Property, name "scrollPrePositionMaxX",     type float @SINCE_1_0.0
518       SCROLL_PRE_POSITION_MAX_Y,                         ///< Property, name "scrollPrePositionMaxY",     type float @SINCE_1_0.0
519       OVERSHOOT_X,                                       ///< Property, name "overshootX",                type float @SINCE_1_0.0
520       OVERSHOOT_Y,                                       ///< Property, name "overshootY",                type float @SINCE_1_0.0
521       SCROLL_FINAL,                                      ///< Property, name "scrollFinal",               type Vector2 @SINCE_1_0.0
522       SCROLL_FINAL_X,                                    ///< Property, name "scrollFinalX",              type float @SINCE_1_0.0
523       SCROLL_FINAL_Y,                                    ///< Property, name "scrollFinalY",              type float @SINCE_1_0.0
524       WRAP,                                              ///< Property, name "wrap",                      type bool @SINCE_1_0.0
525       PANNING,                                           ///< Property, name "panning",                   type bool @SINCE_1_0.0
526       SCROLLING,                                         ///< Property, name "scrolling",                 type bool @SINCE_1_0.0
527       SCROLL_DOMAIN_SIZE,                                ///< Property, name "scrollDomainSize",          type Vector2 @SINCE_1_0.0
528       SCROLL_DOMAIN_SIZE_X,                              ///< Property, name "scrollDomainSizeX",         type float @SINCE_1_0.0
529       SCROLL_DOMAIN_SIZE_Y,                              ///< Property, name "scrollDomainSizeY",         type float @SINCE_1_0.0
530       SCROLL_DOMAIN_OFFSET,                              ///< Property, name "scrollDomainOffset",        type Vector2 @SINCE_1_0.0
531       SCROLL_POSITION_DELTA,                             ///< Property, name "scrollPositionDelta",       type Vector2 @SINCE_1_0.0
532       START_PAGE_POSITION                                ///< Property, name "startPagePosition",         type Vector3 @SINCE_1_0.0
533     };
534   };
535
536   // Typedefs
537
538   typedef Signal< void ( const SnapEvent& ) > SnapStartedSignalType; ///< SnapStarted signal type @SINCE_1_0.0
539
540 public:
541
542   /**
543    * @brief Creates an empty ScrollView handle.
544    * @SINCE_1_0.0
545    */
546   ScrollView();
547
548   /**
549    * @brief Copy constructor.
550    *
551    * Creates another handle that points to the same real object.
552    *
553    * @SINCE_1_0.0
554    * @param[in] handle Handle to copy from
555    */
556   ScrollView( const ScrollView& handle );
557
558   /**
559    * @brief Assignment operator.
560    *
561    * Changes this handle to point to another real object.
562    * @SINCE_1_0.0
563    * @param[in] handle The handle to copy from
564    * @return A reference to this
565    */
566   ScrollView& operator=( const ScrollView& handle );
567
568   /**
569    * @brief Destructor.
570    *
571    * This is non-virtual since derived Handle types must not contain data or virtual methods.
572    * @SINCE_1_0.0
573    */
574   ~ScrollView();
575
576   /**
577    * @brief Creates an initialized ScrollView.
578    *
579    * @SINCE_1_0.0
580    * @return A handle to a newly allocated Dali resource
581    */
582   static ScrollView New();
583
584   /**
585    * @brief Downcasts a handle to ScrollView handle.
586    *
587    * If handle points to a ScrollView, the downcast produces valid handle.
588    * If not, the returned handle is left uninitialized.
589    *
590    * @SINCE_1_0.0
591    * @param[in] handle Handle to an object
592    * @return A handle to a ScrollView or an uninitialized handle
593    */
594   static ScrollView DownCast( BaseHandle handle );
595
596 public:
597
598   /**
599    * @brief Gets snap-animation's AlphaFunction.
600    *
601    * @SINCE_1_0.0
602    * @return Current easing alpha function of the snap animation
603    */
604   AlphaFunction GetScrollSnapAlphaFunction() const;
605
606   /**
607    * @brief Sets snap-animation's AlphaFunction.
608    *
609    * @SINCE_1_0.0
610    * @param[in] alpha Easing alpha function of the snap animation
611    */
612   void SetScrollSnapAlphaFunction(AlphaFunction alpha);
613
614   /**
615    * @brief Gets flick-animation's AlphaFunction.
616    *
617    * @SINCE_1_0.0
618    * @return Current easing alpha function of the flick animation
619    */
620   AlphaFunction GetScrollFlickAlphaFunction() const;
621
622   /**
623    * @brief Sets flick-animation's AlphaFunction.
624    *
625    * @SINCE_1_0.0
626    * @param[in] alpha Easing alpha function of the flick animation
627    */
628   void SetScrollFlickAlphaFunction(AlphaFunction alpha);
629
630   /**
631    * @brief Gets the time for the scroll snap-animation.
632    *
633    * This animation occurs when the user drags, and releases.
634    *
635    * @SINCE_1_0.0
636    * @return The time in seconds for the animation to take
637    */
638   float GetScrollSnapDuration() const;
639
640   /**
641    * @brief Sets the time for the scroll snap-animation.
642    *
643    * This animation occurs when the user drags, and releases.
644    *
645    * @SINCE_1_0.0
646    * @param[in] time The time in seconds for the animation to take
647    */
648   void SetScrollSnapDuration(float time);
649
650   /**
651    * @brief Gets the time for the scroll flick-animation.
652    *
653    * This animation occurs when the user flicks scroll view.
654    *
655    * @SINCE_1_0.0
656    * @return The time in seconds for the animation to take
657    */
658   float GetScrollFlickDuration() const;
659
660   /**
661    * @brief Sets the time for the scroll flick-animation.
662    *
663    * This animation occurs when the user flicks scroll view.
664    *
665    * @SINCE_1_0.0
666    * @param[in] time The time in seconds for the animation to take
667    */
668   void SetScrollFlickDuration(float time);
669
670   /**
671    * @brief Sets X axis ruler.
672    *
673    * Defines how scrolling horizontally is snapped, and
674    * the boundary (domain) in which the ScrollView can pan.
675    *
676    * @SINCE_1_0.0
677    * @param[in] ruler The ruler to be used for the X axis
678    */
679   void SetRulerX(RulerPtr ruler);
680
681   /**
682    * @brief Sets Y axis ruler.
683    *
684    * Defines how scrolling vertically is snapped, and the boundary
685    * (domain) in which the ScrollView can pan.
686    *
687    * @SINCE_1_0.0
688    * @param[in] ruler The ruler to be used for the Y axis
689    */
690   void SetRulerY(RulerPtr ruler);
691
692   /**
693    * @brief Sets scroll sensibility of pan gesture.
694    *
695    * @SINCE_1_0.0
696    * @param[in] sensitive @c true to enable scroll, @c false to disable scrolling
697    * @note Unlike Actor::SetSensitive(), this determines whether this ScrollView
698    * should react (e.g. pan), without disrupting the sensitivity of its children.
699    *
700    */
701   void SetScrollSensitive(bool sensitive);
702
703   /**
704    * @brief Sets maximum overshoot amount.
705    *
706    * The final overshoot value is within 0.0f to 1.0f, but the maximum
707    * overshoot is in pixels (e.g. if you scroll 75 pixels beyond the
708    * edge of a scrollable area and the maximum overshoot is 100 then
709    * the final overshoot value will be 0.75f).
710    *
711    * @SINCE_1_0.0
712    * @param[in] overshootX The maximum number of horizontally scrolled pixels before overshoot X reaches 1.0f
713    * @param[in] overshootY The maximum number of vertically scrolled pixels before overshoot Y reaches 1.0f
714    */
715   void SetMaxOvershoot(float overshootX, float overshootY);
716
717   /**
718    * @brief Sets Snap Overshoot animation's AlphaFunction.
719    *
720    * @SINCE_1_0.0
721    * @param[in] alpha Easing alpha function of the overshoot snap animation
722    */
723   void SetSnapOvershootAlphaFunction(AlphaFunction alpha);
724
725   /**
726    * @brief Sets Snap Overshoot animation's Duration.
727    *
728    * @SINCE_1_0.0
729    * @param[in] duration The duration of the overshoot snap animation
730    * @note Set duration to 0 seconds to disable Animation.
731    *
732    */
733   void SetSnapOvershootDuration(float duration);
734
735   /**
736    * @brief Enables or Disables Actor Auto-Snap mode.
737    *
738    * When Actor Auto-Snap mode has been enabled, ScrollView will automatically
739    * snap to the closest actor (The closest actor will appear in the center of
740    * the ScrollView).
741    *
742    * @SINCE_1_0.0
743    * @param[in] enable Enables (true), or disables (false) Actor AutoSnap
744    */
745   void SetActorAutoSnap(bool enable);
746
747   /**
748    * @brief Enables or Disables Wrap mode for ScrollView contents.
749    *
750    * When enabled, the ScrollView contents are wrapped over the X/Y Domain.
751    *
752    * @SINCE_1_0.0
753    * @param[in] enable Enables (true), or disables (false) Wrap Mode
754    * @note You must apply a position constraint that causes Wrapping
755    * to all children.
756    *
757    */
758   void SetWrapMode(bool enable);
759
760   /**
761    * @brief Gets the current distance needed to scroll for ScrollUpdatedSignal to be emitted.
762    *
763    * @SINCE_1_0.0
764    * @return Current scroll update distance
765    */
766   int GetScrollUpdateDistance() const;
767
768   /**
769    * @brief Sets the distance needed to scroll for ScrollUpdatedSignal to be emitted.
770    *
771    * The scroll update distance tells ScrollView how far to move before ScrollUpdatedSignal the informs application.
772    * Each time the ScrollView crosses this distance the signal will be emitted.
773    *
774    * @SINCE_1_0.0
775    * @param[in] distance The distance for ScrollView to move before emitting update signal
776    */
777   void SetScrollUpdateDistance(int distance);
778
779   /**
780    * @brief Returns state of Axis Auto Lock mode.
781    *
782    * @SINCE_1_0.0
783    * @return Whether Axis Auto Lock mode has been enabled or not
784    */
785   bool GetAxisAutoLock() const;
786
787   /**
788    * @brief Enables or Disables Axis Auto Lock mode for panning within the ScrollView.
789    *
790    * When enabled, any pan gesture that appears mostly horizontal or mostly
791    * vertical, will be automatically restricted to horizontal only or vertical
792    * only panning, until the pan gesture has completed.
793    *
794    * @SINCE_1_0.0
795    * @param[in] enable Enables (true), or disables (false) AxisAutoLock mode
796    */
797   void SetAxisAutoLock(bool enable);
798
799   /**
800    * @brief Gets the gradient threshold at which a panning gesture
801    * should be locked to the Horizontal or Vertical axis.
802    *
803    * @SINCE_1_0.0
804    * @return The gradient, a value between 0.0 and 1.0f
805    */
806   float GetAxisAutoLockGradient() const;
807
808   /**
809    * @brief Sets the gradient threshold at which a panning gesture should be locked to the
810    * Horizontal or Vertical axis.
811    *
812    * By default, this is 0.36 (0.36:1) which means angles less than 20
813    * degrees to an axis will lock to that axis.
814    *
815    * @SINCE_1_0.0
816    * @param[in] gradient A value between 0.0 and 1.0 (auto-lock for all angles)
817    * @note Specifying a value of 1.0 (the maximum value accepted) indicates that
818    * all panning gestures will auto-lock either to the horizontal or vertical axis.
819    *
820    */
821   void SetAxisAutoLockGradient(float gradient);
822
823   /**
824    * @brief Gets the friction coefficient setting for ScrollView when
825    * flicking in free panning mode.
826    *
827    * This is a value in stage-diagonals per second^2.
828    * stage-diagonal = Length( stage.width, stage.height )
829    * @SINCE_1_0.0
830    * @return Friction coefficient is returned
831    */
832   float GetFrictionCoefficient() const;
833
834   /**
835    * @brief Sets the friction coefficient for ScrollView when flicking
836    * in free panning mode.
837    *
838    * This is a value in stage-diagonals per second^2.
839    * stage-diagonal = Length( stage.width, stage.height ).
840    * example:
841    * A stage 480x800 in size has a diagonal length of 933.
842    * Friction coefficient of 1.0 means the swipe velocity will
843    * reduce by 1.0 * 933 pixels/sec^2.
844    * @SINCE_1_0.0
845    * @param[in] friction Friction coefficient must be greater than 0.0 (default = 1.0)
846    */
847   void SetFrictionCoefficient(float friction);
848
849   /**
850    * @brief Gets the flick speed coefficient for ScrollView when
851    * flicking in free panning mode.
852    *
853    * This is a constant which multiplies the input touch
854    * flick velocity to determine the actual velocity at
855    * which to move the scrolling area.
856    * @SINCE_1_0.0
857    * @return The flick speed coefficient is returned
858    */
859   float GetFlickSpeedCoefficient() const;
860
861   /**
862    * @brief Sets the flick speed coefficient for ScrollView when
863    * flicking in free panning mode.
864    *
865    * This is a constant which multiplies the input touch
866    * flick velocity to determine the actual velocity at
867    * which to move the scrolling area.
868    * @SINCE_1_0.0
869    * @param[in] speed The flick speed coefficient (default = 1.0)
870    */
871   void SetFlickSpeedCoefficient(float speed);
872
873   /**
874    * @brief Returns the minimum pan distance required for a flick gesture in pixels.
875    *
876    * @SINCE_1_0.0
877    * @return Minimum pan distance vector with separate x and y distance
878    */
879   Vector2 GetMinimumDistanceForFlick() const;
880
881   /**
882    * @brief Sets the minimum pan distance required for a flick in pixels.
883    *
884    * Takes a Vector2 containing separate x and y values. As long as the pan distance exceeds one of these axes, a flick will be allowed.
885    *
886    * @SINCE_1_0.0
887    * @param[in] distance The minimum pan distance for a flick
888    */
889   void SetMinimumDistanceForFlick( const Vector2& distance );
890
891   /**
892    * @brief Returns the minimum pan speed required for a flick gesture in pixels per second.
893    *
894    * @SINCE_1_0.0
895    * @return Minimum pan speed
896    */
897   float GetMinimumSpeedForFlick() const;
898
899   /**
900    * @brief Sets the minimum pan speed required for a flick in pixels per second.
901    *
902    * @SINCE_1_0.0
903    * @param[in] speed The minimum pan speed for a flick
904    */
905   void SetMinimumSpeedForFlick( float speed );
906
907   /**
908    * @brief Gets the maximum flick speed setting for ScrollView when
909    * flicking in free panning mode.
910    *
911    * This is a value in stage-diagonals per second.
912    * stage-diagonal = Length( stage.width, stage.height )
913    * @SINCE_1_0.0
914    * @return Maximum flick speed is returned
915    */
916   float GetMaxFlickSpeed() const;
917
918   /**
919    * @brief Sets the maximum flick speed for the ScrollView when
920    * flicking in free panning mode.
921    *
922    * This is a value in stage-diagonals per second.
923    * stage-diagonal = Length( stage.width, stage.height )
924    * example:
925    * A stage 480x800 in size has a diagonal length of 933.
926    * Max Flick speed of 1.0 means the maximum velocity of
927    * a swipe can be 1.0 * 933 pixels/sec.
928    * @SINCE_1_0.0
929    * @param[in] speed Maximum flick speed (default = 3.0)
930    */
931   void SetMaxFlickSpeed(float speed);
932
933   /**
934    * @brief Gets the step of scroll distance in actor coordinates for
935    * each wheel event received in free panning mode.
936    *
937    * @SINCE_1_0.0
938    * @return The step of scroll distance(pixel) in X and Y axes
939    */
940   Vector2 GetWheelScrollDistanceStep() const;
941
942   /**
943    * @brief Sets the step of scroll distance in actor coordinates for
944    * each wheel event received in free panning mode.
945    *
946    * @SINCE_1_0.0
947    * @param[in] step The step of scroll distance(pixel) in X and Y axes
948    *
949    * @note If snap points are defined in the rulers, it will always
950    * scroll to the next snap point towards the scroll direction while
951    * receiving the wheel events.
952    *
953    */
954   void SetWheelScrollDistanceStep(Vector2 step);
955
956   /**
957    * @brief Retrieves current scroll position.
958    *
959    * @SINCE_1_0.0
960    * @return The current scroll position
961    */
962   Vector2 GetCurrentScrollPosition() const;
963
964   /**
965    * @brief Retrieves current scroll page based on ScrollView
966    * dimensions being the size of one page, and all pages laid out in
967    * a grid fashion, increasing from left to right until the end of
968    * the X-domain.
969    *
970    * @SINCE_1_0.0
971    * @note Pages start from 0 as the first page, not 1.
972    *
973    * @return The Current page
974    */
975   unsigned int GetCurrentPage() const;
976
977   /**
978    * @brief Scrolls View to position specified (contents will scroll to this position).
979    *
980    * Position 0,0 is the origin. Increasing X scrolls contents left, while
981    * increasing Y scrolls contents up.
982    * - If Rulers have been applied to the axes, then the contents will scroll until
983    * reaching the domain boundary.
984    * @SINCE_1_0.0
985    * @param[in] position The position to scroll to
986    * @note Contents will not snap to ruler snap points.
987    *
988    */
989   void ScrollTo(const Vector2& position);
990
991   /**
992    * @brief Scrolls View to position specified (contents will scroll to this position).
993    *
994    * Position 0,0 is the origin. Increasing X scrolls contents left, while
995    * increasing Y scrolls contents up.
996    * - If Rulers have been applied to the axes, then the contents will scroll until
997    * reaching the domain boundary.
998    * @SINCE_1_0.0
999    * @param[in] position The position to scroll to
1000    * @param[in] duration The duration of the animation in seconds
1001    * @note Contents will not snap to ruler snap points.
1002    *
1003    */
1004   void ScrollTo(const Vector2& position, float duration);
1005
1006   /**
1007    * @brief Scrolls View to position specified (contents will scroll to this position).
1008    *
1009    * Position 0,0 is the origin. Increasing X scrolls contents left, while
1010    * increasing Y scrolls contents up.
1011    * - If Rulers have been applied to the axes, then the contents will scroll until
1012    * reaching the domain boundary.
1013    * @SINCE_1_0.0
1014    * @param[in] position The position to scroll to
1015    * @param[in] duration The duration of the animation in seconds
1016    * @param[in] alpha The alpha function to use
1017    * @note Contents will not snap to ruler snap points.
1018    *
1019    */
1020   void ScrollTo(const Vector2& position, float duration, AlphaFunction alpha);
1021
1022   /**
1023    * @brief Scrolls View to position specified (contents will scroll to this position).
1024    *
1025    * Position 0,0 is the origin. Increasing X scrolls contents left, while
1026    * increasing Y scrolls contents up.
1027    * - If Rulers have been applied to the axes, then the contents will scroll until
1028    * reaching the domain boundary.
1029    * @SINCE_1_0.0
1030    * @param[in] position The position to scroll to
1031    * @param[in] duration The duration of the animation in seconds
1032    * @param[in] horizontalBias Whether to bias scrolling to left or right
1033    * @param[in] verticalBias Whether to bias scrolling to top or bottom
1034    * @note Contents will not snap to ruler snap points.
1035    * Biasing parameters are provided such that in scenarios with 2 or 2x2 pages in
1036    * wrap mode, the application developer can decide whether to scroll left or right
1037    * to get to the target page.
1038    *
1039    */
1040   void ScrollTo(const Vector2& position, float duration,
1041                 DirectionBias horizontalBias, DirectionBias verticalBias);
1042
1043   /**
1044    * @brief Scrolls View to position specified (contents will scroll to this position).
1045    *
1046    * Position 0,0 is the origin. Increasing X scrolls contents left, while
1047    * increasing Y scrolls contents up.
1048    * - If Rulers have been applied to the axes, then the contents will scroll until
1049    * reaching the domain boundary.
1050    * @SINCE_1_0.0
1051    * @param[in] position The position to scroll to
1052    * @param[in] duration The duration of the animation in seconds
1053    * @param[in] horizontalBias Whether to bias scrolling to left or right
1054    * @param[in] verticalBias Whether to bias scrolling to top or bottom
1055    * @param[in] alpha Alpha function to use
1056    * @note Contents will not snap to ruler snap points.
1057    * Biasing parameters are provided such that in scenarios with 2 or 2x2 pages in
1058    * wrap mode, the application developer can decide whether to scroll left or right
1059    * to get to the target page.
1060    *
1061    */
1062   void ScrollTo(const Vector2& position, float duration, AlphaFunction alpha,
1063                 DirectionBias horizontalBias, DirectionBias verticalBias);
1064
1065   /**
1066    * @brief Scrolls View to page currently based on assumption that each page is
1067    * "(page) * ScrollViewSize.width, 0".
1068    *
1069    * @SINCE_1_0.0
1070    * @param[in] page The page to scroll to
1071    * @note Should probably be upgraded so that page is an abstract class, that can be
1072    * a function of ScrollViewSize, ruler domain, ruler snap points etc. as pages may be
1073    * orchestrated in a 2D grid fashion, or variable width.
1074    *
1075    */
1076   void ScrollTo(unsigned int page);
1077
1078   /**
1079    * @brief Scrolls View to page currently based on assumption that each page is
1080    * "(page) * ScrollViewSize.width, 0".
1081    *
1082    * @SINCE_1_0.0
1083    * @param[in] page The page to scroll to
1084    * @param[in] duration The duration of the animation in seconds
1085    * @note Should probably be upgraded so that page is an abstract class, that can be
1086    * a function of ScrollViewSize, ruler domain, ruler snap points etc. as pages may be
1087    * orchestrated in a 2D grid fashion, or variable width.
1088    *
1089    */
1090   void ScrollTo(unsigned int page, float duration);
1091
1092   /**
1093    * @brief Scrolls View to page currently based on assumption that each page is
1094    * "(page) * ScrollViewSize.width, 0".
1095    *
1096    * @SINCE_1_0.0
1097    * @param[in] page The page to scroll to
1098    * @param[in] duration The duration of the animation in seconds
1099    * @param[in] bias Whether to bias scrolling to left or right
1100    * @note Should probably be upgraded so that page is an abstract class, that can be
1101    * a function of ScrollViewSize, ruler domain, ruler snap points etc. as pages may be
1102    * orchestrated in a 2D grid fashion, or variable width.
1103    * A biasing parameter is provided such that in scenarios with 2 pages in wrap mode,
1104    * the application developer can decide whether to scroll left or right to get to
1105    * the target page.
1106    *
1107    */
1108   void ScrollTo(unsigned int page, float duration, DirectionBias bias);
1109
1110   /**
1111    * @brief Scrolls View such that actor appears in the center of the ScrollView.
1112    *
1113    * @SINCE_1_0.0
1114    * @param[in] actor The actor to center in on (via Scrolling)
1115    * @note Actor must be a direct child of ScrollView, otherwise will
1116    * cause an assertion failure.
1117    */
1118   void ScrollTo(Actor& actor);
1119
1120   /**
1121    * @brief Scrolls View such that actor appears in the center of the ScrollView.
1122    *
1123    * @SINCE_1_0.0
1124    * @param[in] actor The actor to center in on (via Scrolling)
1125    * @param[in] duration The duration of the animation in seconds
1126    * @note Actor must be a direct child of ScrollView, otherwise will
1127    * cause an assertion failure.
1128    */
1129   void ScrollTo(Actor& actor, float duration);
1130
1131   /**
1132    * @brief Scrolls View to the nearest snap points as specified by the Rulers.
1133    *
1134    * If already at snap points, then will return false, and not scroll.
1135    *
1136    * @SINCE_1_0.0
1137    * @return True if Snapping necessary
1138    */
1139   bool ScrollToSnapPoint();
1140
1141   /**
1142    * @brief Applies a constraint that will affect the children of ScrollView.
1143    *
1144    * @SINCE_1_0.0
1145    * @param[in] constraint The constraint to apply
1146    * @note This affects all existing and future Actors that are added to scrollview.
1147    */
1148   void ApplyConstraintToChildren(Constraint constraint);
1149
1150   /**
1151    * @brief Removes all constraints that will affect the children of ScrollView.
1152    *
1153    * @SINCE_1_0.0
1154    * @note This removes all constraints from actors that have been added
1155    * to scrollview.
1156    */
1157   void RemoveConstraintsFromChildren();
1158
1159   /**
1160    * @brief Applies Effect to ScrollView.
1161    *
1162    * @SINCE_1_0.0
1163    * @param[in] effect The effect to apply to scroll view
1164    */
1165   void ApplyEffect(ScrollViewEffect effect);
1166
1167   /**
1168    * @brief Removes Effect from ScrollView.
1169    *
1170    * @SINCE_1_0.0
1171    * @param[in] effect The effect to remove
1172    */
1173   void RemoveEffect(ScrollViewEffect effect);
1174
1175   /**
1176    * @brief Remove All Effects from ScrollView.
1177    * @SINCE_1_0.0
1178    */
1179   void RemoveAllEffects();
1180
1181   /**
1182    * @brief Binds actor to this ScrollView.
1183    *
1184    * Once an actor is bound to a ScrollView, it will be subject to
1185    * that ScrollView's properties.
1186    *
1187    * @SINCE_1_0.0
1188    * @param[in] child The actor to add to this ScrollView
1189    */
1190   void BindActor(Actor child);
1191
1192   /**
1193    * @brief Unbinds Actor from this ScrollView.
1194    *
1195    * Once Unbound, this ScrollView will not affect the actor.
1196    * @SINCE_1_0.0
1197    * @param[in] child The actor to be unbound
1198    * @note This does not remove the child from the ScrollView container
1199    *
1200    */
1201   void UnbindActor(Actor child);
1202
1203   /**
1204    * @brief Allows the user to constrain the scroll view in a particular direction.
1205    *
1206    * @SINCE_1_0.0
1207    * @param[in] direction The axis to constrain the scroll-view to.
1208    *                      Usually set to PanGestureDetector::DIRECTION_VERTICAL or PanGestureDetector::DIRECTION_HORIZONTAL (but can be any other angle if desired).
1209    * @param[in] threshold The threshold to apply around the axis
1210    * @note If no threshold is specified, then the default threshold of PI * 0.25 radians (or 45 degrees) is used.
1211    */
1212   void SetScrollingDirection( Radian direction, Radian threshold = PanGestureDetector::DEFAULT_THRESHOLD );
1213
1214   /**
1215    * @brief Removes a direction constraint from the scroll view.
1216    *
1217    * @SINCE_1_0.0
1218    * @param[in] direction The axis to stop constraining to.
1219    *                      Usually will be PanGestureDetector::DIRECTION_VERTICAL or PanGestureDetector::DIRECTION_HORIZONTAL (but can be any other angle if desired).
1220    */
1221   void RemoveScrollingDirection( Radian direction );
1222
1223 public: // Signals
1224
1225   /**
1226    * @brief Signal emitted when the ScrollView has started to snap or flick (it tells the target
1227    * position, scale, rotation for the snap or flick).
1228    *
1229    * A callback of the following type may be connected:
1230    * @code
1231    *   void YourCallbackName(const SnapEvent& event);
1232    * @endcode
1233    * @SINCE_1_0.0
1234    * @return The signal to connect to
1235    * @pre The Object has been initialized.
1236    */
1237   SnapStartedSignalType& SnapStartedSignal();
1238
1239 public: // Not intended for application developers
1240
1241   /// @cond internal
1242   /**
1243    * @brief Creates a handle using the Toolkit::Internal implementation.
1244    *
1245    * @SINCE_1_0.0
1246    * @param[in] implementation The Control implementation
1247    */
1248   DALI_INTERNAL ScrollView(Internal::ScrollView& implementation);
1249
1250   /**
1251    * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
1252    *
1253    * @SINCE_1_0.0
1254    * @param[in] internal A pointer to the internal CustomActor
1255    */
1256   explicit DALI_INTERNAL ScrollView( Dali::Internal::CustomActor* internal );
1257   /// @endcond
1258 };
1259
1260 /**
1261  * @}
1262  */
1263 } // namespace Toolkit
1264
1265 } // namespace Dali
1266
1267 #endif // __DALI_TOOLKIT_SCROLL_VIEW_H__