1 #ifndef __DALI_TOOLKIT_SCROLL_VIEW_H__
2 #define __DALI_TOOLKIT_SCROLL_VIEW_H__
5 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali/public-api/animation/alpha-function.h>
25 #include <dali-toolkit/public-api/controls/scrollable/scrollable.h>
33 namespace Internal DALI_INTERNAL
38 * @addtogroup dali_toolkit_controls_scroll_view
43 * @brief How axes/rotation or scale are clamped
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
54 * @brief A 2 dimensional clamp
59 ClampState x; ///< The clamp state of the x axis
60 ClampState y; ///< The clamp state of the y axis
64 * @brief The snap type
69 Snap, ///< Snap @SINCE_1_0.0
70 Flick ///< Flick @SINCE_1_0.0
74 * @brief DirectionBias types.
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
85 * @brief Used for specifying minimum/maximum extents of a ruler.
88 class DALI_IMPORT_API RulerDomain
93 * @brief Creates Ruler domain allowing a point to traverse between min and max extents.
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.
100 explicit RulerDomain(float min, float max, bool enabled = true);
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.
109 * @brief Clamps value (x) from (min) to (max).
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.
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.
120 float Clamp(float x, float length = 0.0f, float scale = 1.0f) const;
123 * @brief Clamps value (x) from (min) to (max).
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.
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 occured and which size (None, Min or Max)
133 * @return The clamped value.
135 float Clamp(float x, float length, float scale, ClampState &clamped) const;
138 * @brief Returns (max-min) size of ruler.
141 * @return The size of the ruler from min to max.
143 float GetSize() const;
147 // Forward declare future extension interface
148 class RulerExtension;
151 * @brief Abstract class to define scroll axes.
153 * It can specify whether they are traversable, where their snap
154 * points are and their domain.
157 class DALI_IMPORT_API Ruler : public RefObject
160 /// @brief The type of the ruler
162 Fixed, ///< A fixed ruler @SINCE_1_0.0
163 Free ///< A free ruler @SINCE_1_0.0
169 * @brief Constructs ruler, default enabled, with limitless domain.
175 * @brief Snaps (x) in accordance to the ruler settings.
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.
185 virtual float Snap(float x, float bias = 0.5f) const = 0;
188 * @brief Returns position from page, based on whatever the ruler
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
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.
202 virtual float GetPositionFromPage(unsigned int page, unsigned int &volume, bool wrap) const = 0;
205 * @brief Returns page from position, based on whatever the ruler
208 * If (wrap) is true, then will return a page wrapped within the domain.
211 * @param[in] position The position on the domain
212 * @param[in] wrap Enable wrap mode
213 * @return The page where this position resides.
215 virtual unsigned int GetPageFromPosition(float position, bool wrap) const = 0;
218 * @brief Returns the total number of pages within this Ruler.
221 * @return The number of pages in the Ruler.
223 virtual unsigned int GetTotalPages() const = 0;
226 * @brief Gets the extension interface of the Ruler.
229 * @return The extension interface of the Ruler
231 virtual RulerExtension* GetExtension() { return NULL; }
236 * @brief Gets the ruler type.
239 * @return The ruler type.
241 Ruler::RulerType GetType() const;
244 * @brief Returns whether this axis has been enabled or not.
247 * @return true if axis is enabled
249 bool IsEnabled() const;
252 * @brief Enables ruler (ruler must be enabled in order to traverse along it).
258 * @brief Disables ruler.
264 * @brief Sets Domain.
267 * @param[in] domain Ruler domain object.
269 void SetDomain(RulerDomain domain);
272 * @brief Gets Domain.
277 const RulerDomain &GetDomain() const;
280 * @brief Disables Domain (minimum/maximum extents for this axis).
283 void DisableDomain();
286 * @brief Clamps value (x) from (min) to (max).
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.
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.
297 float Clamp(float x, float length = 0.0f, float scale = 1.0f) const;
301 * @brief Clamps value (x) from (min) to (max).
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.
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 occured and which size (None, Min or Max)
311 * @return The clamped value.
313 float Clamp(float x, float length, float scale, ClampState &clamped) const;
316 * @brief Snaps and Clamps (x) in accordance to ruler settings.
319 * @param[in] 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)
327 * @param[in] scale Scaling parameter which treats domain as scaled in calculations.
328 * @return the clamped value after snapping
330 float SnapAndClamp(float x, float bias = 0.5f, float length = 0.0f, float scale = 1.0f) const;
333 * @brief Snaps and Clamps (x) in accordance to ruler settings.
336 * @param[in] 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)
344 * @param[in] scale Scaling parameter which treats domain as scaled in calculations.
345 * @param[out] clamped Whether clamping occured and which size (None, Min or Max)
346 * @return The clamped value after snapping
348 float SnapAndClamp(float x, float bias, float length, float scale, ClampState &clamped) const;
353 * @brief Destructor - A reference counted object may only be deleted by calling Unreference().
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.
366 typedef IntrusivePtr<Ruler> RulerPtr; ///< Pointer to Dali::Toolkit::Ruler object @SINCE_1_0.0
369 * @brief Concrete implementation of Ruler that has no snapping and has one single page.
372 class DALI_IMPORT_API DefaultRuler : public Ruler
376 * @brief DefaultRuler constructor.
382 * @copydoc Toolkit::Ruler::Snap
384 virtual float Snap(float x, float bias) const;
387 * @copydoc Toolkit::Ruler::GetPositionFromPage
389 virtual float GetPositionFromPage(unsigned int page, unsigned int &volume, bool wrap) const;
392 * @copydoc Toolkit::Ruler::GetPageFromPosition
394 virtual unsigned int GetPageFromPosition(float position, bool wrap) const;
397 * @copydoc Toolkit::Ruler::GetTotalPages
399 virtual unsigned int GetTotalPages() const;
403 * @brief Concrete implementation of Ruler that has fixed snapping.
406 class DALI_IMPORT_API FixedRuler : public Ruler
413 * @param[in] spacing The spacing between each interval on this ruler.
415 FixedRuler(float spacing = 1.0f);
418 * @copydoc Toolkit::Ruler::Snap
420 virtual float Snap(float x, float bias) const;
423 * @copydoc Toolkit::Ruler::GetPositionFromPage
425 virtual float GetPositionFromPage(unsigned int page, unsigned int &volume, bool wrap) const;
428 * @copydoc Toolkit::Ruler::GetPageFromPosition
430 virtual unsigned int GetPageFromPosition(float position, bool wrap) const;
433 * @copydoc Toolkit::Ruler::GetTotalPages
435 virtual unsigned int GetTotalPages() const;
438 float mSpacing; ///< The spacing between each interval
441 class ScrollViewEffect;
445 * @brief ScrollView contains actors that can be scrolled manually (via touch)
449 * | %Signal Name | Method |
450 * |-------------------|----------------------------|
451 * | snap-started | @ref SnapStartedSignal() |
454 class DALI_IMPORT_API ScrollView : public Scrollable
460 * @brief Clamp signal event's data
465 ClampState2D scale; ///< Clamp information for scale axes
466 ClampState2D position; ///< Clamp information for position axes
467 ClampState rotation; ///< Clamp information for rotation
471 * @brief Snap signal event's data.
476 SnapType type; ///< Current snap commencing
477 Vector2 position; ///< Target snap position
478 float duration; ///< Duration of snap animation.
482 * @brief The start and end property ranges for this control.
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
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
495 * @brief An enumeration of properties belonging to the ScrollView class.
502 // Event side properties
503 WRAP_ENABLED = PROPERTY_START_INDEX, ///< Property, name "wrapEnabled", @see SetWrapMode(), type bool, @SINCE_1_1.18
504 PANNING_ENABLED, ///< Property, name "panningEnabled", @see SetScrollSensitive(), type bool, @SINCE_1_1.18
505 AXIS_AUTO_LOCK_ENABLED, ///< Property, name "axisAutoLockEnabled", @see SetAxisAutoLock(), type bool, @SINCE_1_1.18
506 WHEEL_SCROLL_DISTANCE_STEP, ///< Property, name "wheelScrollDistanceStep", @see SetWheelScrollDistanceStep(), type Vector2, @SINCE_1_1.18
508 SCROLL_POSITION = ANIMATABLE_PROPERTY_START_INDEX, ///< Property, name "scrollPosition", type Vector2 @SINCE_1_0.0
509 SCROLL_PRE_POSITION, ///< Property, name "scrollPrePosition", type Vector2 @SINCE_1_0.0
510 SCROLL_PRE_POSITION_X, ///< Property, name "scrollPrePositionX", type float @SINCE_1_0.0
511 SCROLL_PRE_POSITION_Y, ///< Property, name "scrollPrePositionY", type float @SINCE_1_0.0
512 SCROLL_PRE_POSITION_MAX, ///< Property, name "scrollPrePositionMax", type Vector2 @SINCE_1_0.0
513 SCROLL_PRE_POSITION_MAX_X, ///< Property, name "scrollPrePositionMaxX", type float @SINCE_1_0.0
514 SCROLL_PRE_POSITION_MAX_Y, ///< Property, name "scrollPrePositionMaxY", type float @SINCE_1_0.0
515 OVERSHOOT_X, ///< Property, name "overshootX", type float @SINCE_1_0.0
516 OVERSHOOT_Y, ///< Property, name "overshootY", type float @SINCE_1_0.0
517 SCROLL_FINAL, ///< Property, name "scrollFinal", type Vector2 @SINCE_1_0.0
518 SCROLL_FINAL_X, ///< Property, name "scrollFinalX", type float @SINCE_1_0.0
519 SCROLL_FINAL_Y, ///< Property, name "scrollFinalY", type float @SINCE_1_0.0
520 WRAP, ///< Property, name "wrap", type bool @SINCE_1_0.0
521 PANNING, ///< Property, name "panning", type bool @SINCE_1_0.0
522 SCROLLING, ///< Property, name "scrolling", type bool @SINCE_1_0.0
523 SCROLL_DOMAIN_SIZE, ///< Property, name "scrollDomainSize", type Vector2 @SINCE_1_0.0
524 SCROLL_DOMAIN_SIZE_X, ///< Property, name "scrollDomainSizeX", type float @SINCE_1_0.0
525 SCROLL_DOMAIN_SIZE_Y, ///< Property, name "scrollDomainSizeY", type float @SINCE_1_0.0
526 SCROLL_DOMAIN_OFFSET, ///< Property, name "scrollDomainOffset", type Vector2 @SINCE_1_0.0
527 SCROLL_POSITION_DELTA, ///< Property, name "scrollPositionDelta", type Vector2 @SINCE_1_0.0
528 START_PAGE_POSITION ///< Property, name "startPagePosition", type Vector3 @SINCE_1_0.0
534 typedef Signal< void ( const SnapEvent& ) > SnapStartedSignalType; ///< SnapStarted signal type @SINCE_1_0.0
539 * @brief Creates an empty ScrollView handle.
545 * @brief Copy constructor.
547 * Creates another handle that points to the same real object
550 * @param[in] handle to copy from
552 ScrollView( const ScrollView& handle );
555 * @brief Assignment operator.
557 * Changes this handle to point to another real object
559 * @param[in] handle The handle to copy from
560 * @return A reference to this
562 ScrollView& operator=( const ScrollView& handle );
567 * This is non-virtual since derived Handle types must not contain data or virtual methods.
573 * @brief Create an initialized ScrollView.
576 * @return A handle to a newly allocated Dali resource.
578 static ScrollView New();
581 * @brief Downcast an Object handle to ScrollView.
583 * If handle points to a ScrollView the downcast produces valid
584 * handle. If not the returned handle is left uninitialized.
587 * @param[in] handle Handle to an object
588 * @return handle to a ScrollView or an uninitialized handle
590 static ScrollView DownCast( BaseHandle handle );
595 * @brief Get snap-animation's AlphaFunction.
598 * @return Current easing alpha function of the snap animation.
600 AlphaFunction GetScrollSnapAlphaFunction() const;
603 * @brief Set snap-animation's AlphaFunction.
606 * @param[in] alpha Easing alpha function of the snap animation.
608 void SetScrollSnapAlphaFunction(AlphaFunction alpha);
611 * @brief Get flick-animation's AlphaFunction.
614 * @return Current easing alpha function of the flick animation.
616 AlphaFunction GetScrollFlickAlphaFunction() const;
619 * @brief Set flick-animation's AlphaFunction.
622 * @param[in] alpha Easing alpha function of the flick animation.
624 void SetScrollFlickAlphaFunction(AlphaFunction alpha);
627 * @brief Gets the time for the scroll snap-animation.
629 * This animation occurs when the user drags, and releases.
632 * @return The time in seconds for the animation to take.
634 float GetScrollSnapDuration() const;
637 * @brief Sets the time for the scroll snap-animation.
639 * This animation occurs when the user drags, and releases.
642 * @param[in] time The time in seconds for the animation to take.
644 void SetScrollSnapDuration(float time);
647 * @brief Gets the time for the scroll flick-animation.
649 * This animation occurs when the user flicks scroll view.
652 * @return The time in seconds for the animation to take.
654 float GetScrollFlickDuration() const;
657 * @brief Sets the time for the scroll flick-animation.
659 * This animation occurs when the user flicks scroll view.
662 * @param[in] time The time in seconds for the animation to take.
664 void SetScrollFlickDuration(float time);
667 * @brief Set X axis ruler.
669 * Defines how scrolling horizontally is snapped, and
670 * the boundary (domain) in which the ScrollView can pan.
673 * @param[in] ruler The ruler to be used for the X axis
675 void SetRulerX(RulerPtr ruler);
678 * @brief Set Y axis ruler.
680 * Defines how scrolling vertically is snapped, and the boundary
681 * (domain) in which the ScrollView can pan.
684 * @param[in] ruler The ruler to be used for the Y axis
686 void SetRulerY(RulerPtr ruler);
689 * @brief Set Scroll's touch sensitivity.
692 * @param[in] sensitive true to enable scroll, false to disable scrolling
693 * @note Unlike SetSensitive(), this determines whether this ScrollView
694 * should react (e.g. pan), without disrupting the sensitivity of it's children.
697 void SetScrollSensitive(bool sensitive);
700 * @brief Set maximum overshoot amount.
702 * The final overshoot value is within 0.0f to 1.0f, but the maximum
703 * overshoot is in pixels (e.g. if you scroll 75 pixels beyond the
704 * edge of a scrollable area and the maximum overshoot is 100 then
705 * the final overshoot value will be 0.75f)
708 * @param[in] overshootX the maximum number of horizontally scrolled pixels before overshoot X reaches 1.0f
709 * @param[in] overshootY the maximum number of vertically scrolled pixels before overshoot Y reaches 1.0f
711 void SetMaxOvershoot(float overshootX, float overshootY);
714 * @brief Set Snap Overshoot animation's AlphaFunction.
717 * @param[in] alpha Easing alpha function of the overshoot snap animation.
719 void SetSnapOvershootAlphaFunction(AlphaFunction alpha);
722 * @brief Set Snap Overshoot animation's Duration.
725 * @param[in] duration The duration of the overshoot snap animation.
726 * @note Set duration to 0 seconds, to disable Animation.
729 void SetSnapOvershootDuration(float duration);
732 * @brief Enables or Disables Actor Auto-Snap mode.
734 * When Actor Auto-Snap mode has been enabled, ScrollView will automatically
735 * snap to the closest actor (The closest actor will appear in the center of
739 * @param[in] enable Enables (true), or disables (false) Actor AutoSnap
741 void SetActorAutoSnap(bool enable);
744 * @brief Enables or Disables Wrap mode for ScrollView contents.
746 * When enabled, the ScrollView contents are wrapped over the X/Y Domain.
749 * @param[in] enable Enables (true), or disables (false) Wrap Mode.
750 * @note You must apply a position constraint that causes Wrapping
754 void SetWrapMode(bool enable);
757 * @brief Gets the current distance needed to scroll for ScrollUpdatedSignal to be emitted
760 * @return Current scroll update distance
762 int GetScrollUpdateDistance() const;
765 * @brief Sets the distance needed to scroll for ScrollUpdatedSignal to be emitted
767 * The scroll update distance tells ScrollView how far to move before ScrollUpdatedSignal the informs application.
768 * Each time the ScrollView crosses this distance the signal will be emitted
771 * @param[in] distance The distance for ScrollView to move before emitting update signal
773 void SetScrollUpdateDistance(int distance);
776 * @brief Returns state of Axis Auto Lock mode.
779 * @return Whether Axis Auto Lock mode has been enabled or not.
781 bool GetAxisAutoLock() const;
784 * @brief Enables or Disables Axis Auto Lock mode for panning within the ScrollView.
786 * When enabled, any pan gesture that appears mostly horizontal or mostly
787 * vertical, will be automatically restricted to horizontal only or vertical
788 * only panning, until the pan gesture has completed.
791 * @param[in] enable Enables (true), or disables (false) AxisAutoLock mode.
793 void SetAxisAutoLock(bool enable);
796 * @brief Gets the gradient threshold at which a panning gesture
797 * should be locked to the Horizontal or Vertical axis.
800 * @return The gradient, a value between 0.0 and 1.0f.
802 float GetAxisAutoLockGradient() const;
805 * @brief Sets the gradient threshold at which a panning gesture should be locked to the
806 * Horizontal or Vertical axis.
808 * By default this is 0.36 (0.36:1) which means angles less than 20
809 * degrees to an axis will lock to that axis.
811 * @note: Specifying a value of 1.0 (the maximum value accepted) indicates that
812 * all panning gestures will auto-lock. Either to the horizontal or vertical axis.
815 * @param[in] gradient A value between 0.0 and 1.0 (auto-lock for all angles)
817 void SetAxisAutoLockGradient(float gradient);
820 * @brief Gets the friction coefficient setting for ScrollView when
821 * flicking in free panning mode.
823 * This is a value in stage-diagonals per second^2.
824 * stage-diagonal = Length( stage.width, stage.height )
826 * @return Friction coefficient is returned.
828 float GetFrictionCoefficient() const;
831 * @brief Sets the friction coefficient for ScrollView when flicking
832 * in free panning mode.
834 * This is a value in stage-diagonals per second^2.
835 * stage-diagonal = Length( stage.width, stage.height ).
837 * A stage 480x800 in size has a diagonal length of 933.
838 * Friction coefficient of 1.0 means the swipe velocity will
839 * reduce by 1.0 * 933 pixels/sec^2.
841 * @param[in] friction Friction coefficient, must be greater than 0.0 (default = 1.0)
843 void SetFrictionCoefficient(float friction);
846 * @brief Gets the flick speed coefficient for ScrollView when
847 * flicking in free panning mode.
849 * This is a constant which multiplies the input touch
850 * flick velocity to determine the actual velocity at
851 * which to move the scrolling area.
853 * @return The flick speed coefficient is returned.
855 float GetFlickSpeedCoefficient() const;
858 * @brief Sets the flick speed coefficient for ScrollView when
859 * flicking in free panning mode.
861 * This is a constant which multiplies the input touch
862 * flick velocity to determine the actual velocity at
863 * which to move the scrolling area.
865 * @param[in] speed The flick speed coefficient (default = 1.0).
867 void SetFlickSpeedCoefficient(float speed);
870 * @brief Returns the minimum pan distance required for a flick gesture in pixels
873 * @return Minimum pan distance vector with separate x and y distance
875 Vector2 GetMinimumDistanceForFlick() const;
878 * @brief Sets the minimum pan distance required for a flick in pixels
880 * 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
883 * @param[in] distance The minimum pan distance for a flick
885 void SetMinimumDistanceForFlick( const Vector2& distance );
888 * @brief Returns the minimum pan speed required for a flick gesture in pixels per second
891 * @return Minimum pan speed
893 float GetMinimumSpeedForFlick() const;
896 * @brief Sets the minimum pan speed required for a flick in pixels per second
899 * @param[in] speed The minimum pan speed for a flick
901 void SetMinimumSpeedForFlick( float speed );
904 * @brief Gets the maximum flick speed setting for ScrollView when
905 * flicking in free panning mode.
907 * This is a value in stage-diagonals per second.
908 * stage-diagonal = Length( stage.width, stage.height )
910 * @return Maximum flick speed is returned
912 float GetMaxFlickSpeed() const;
915 * @brief Sets the maximum flick speed for the ScrollView when
916 * flicking in free panning mode.
918 * This is a value in stage-diagonals per second.
919 * stage-diagonal = Length( stage.width, stage.height )
921 * A stage 480x800 in size has a diagonal length of 933.
922 * Max Flick speed of 1.0 means the maximum velocity of
923 * a swipe can be 1.0 * 933 pixels/sec.
925 * @param[in] speed Maximum flick speed (default = 3.0)
927 void SetMaxFlickSpeed(float speed);
930 * @brief Gets the step of scroll distance in actor coordinates for
931 * each wheel event received in free panning mode.
934 * @return The step of scroll distance(pixel) in X and Y axes.
936 Vector2 GetWheelScrollDistanceStep() const;
939 * @brief Sets the step of scroll distance in actor coordinates for
940 * each wheel event received in free panning mode.
943 * @param[in] step The step of scroll distance(pixel) in X and Y axes.
945 * @note: If snap points are defined in the rulers, it will always
946 * scroll to the next snap point towards the scroll direction while
947 * receiving the wheel events.
950 void SetWheelScrollDistanceStep(Vector2 step);
953 * @brief Retrieves current scroll position.
955 * @returns The current scroll position.
958 Vector2 GetCurrentScrollPosition() const;
961 * @brief Retrieves current scroll page based on ScrollView
962 * dimensions being the size of one page, and all pages laid out in
963 * a grid fashion, increasing from left to right until the end of
966 * @note: Pages start from 0 as the first page, not 1.
968 * @returns The Current page.
971 unsigned int GetCurrentPage() const;
974 * @brief Scrolls View to position specified (contents will scroll to this position).
976 * Position 0,0 is the origin. Increasing X scrolls contents left, while
977 * increasing Y scrolls contents up.
978 * - If Rulers have been applied to the axes, then the contents will scroll until
979 * reaching the domain boundary.
981 * @param[in] position The position to scroll to.
982 * @note Contents will not snap to ruler snap points.
985 void ScrollTo(const Vector2& position);
988 * @brief Scrolls View to position specified (contents will scroll to this position).
990 * Position 0,0 is the origin. Increasing X scrolls contents left, while
991 * increasing Y scrolls contents up.
992 * - If Rulers have been applied to the axes, then the contents will scroll until
993 * reaching the domain boundary.
995 * @param[in] position The position to scroll to.
996 * @param[in] duration The duration of the animation in seconds
997 * @note Contents will not snap to ruler snap points.
1000 void ScrollTo(const Vector2& position, float duration);
1003 * @brief Scrolls View to position specified (contents will scroll to this position)
1005 * Position 0,0 is the origin. Increasing X scrolls contents left, while
1006 * increasing Y scrolls contents up.
1007 * - If Rulers have been applied to the axes, then the contents will scroll until
1008 * reaching the domain boundary.
1010 * @param[in] position The position to scroll to.
1011 * @param[in] duration The duration of the animation in seconds
1012 * @param[in] alpha The alpha function to use
1013 * @note Contents will not snap to ruler snap points.
1016 void ScrollTo(const Vector2& position, float duration, AlphaFunction alpha);
1019 * @brief Scrolls View to position specified (contents will scroll to this position).
1021 * Position 0,0 is the origin. Increasing X scrolls contents left, while
1022 * increasing Y scrolls contents up.
1023 * - If Rulers have been applied to the axes, then the contents will scroll until
1024 * reaching the domain boundary.
1026 * @param[in] position The position to scroll to.
1027 * @param[in] duration The duration of the animation in seconds
1028 * @param[in] horizontalBias Whether to bias scrolling to left or right.
1029 * @param[in] verticalBias Whether to bias scrolling to top or bottom.
1030 * @note Contents will not snap to ruler snap points.
1031 * Biasing parameters are provided such that in scenarios with 2 or 2x2 pages in
1032 * wrap mode, the application developer can decide whether to scroll left or right
1033 * to get to the target page
1036 void ScrollTo(const Vector2& position, float duration,
1037 DirectionBias horizontalBias, DirectionBias verticalBias);
1040 * @brief Scrolls View to position specified (contents will scroll to this position)
1042 * Position 0,0 is the origin. Increasing X scrolls contents left, while
1043 * increasing Y scrolls contents up.
1044 * - If Rulers have been applied to the axes, then the contents will scroll until
1045 * reaching the domain boundary.
1047 * @param[in] position The position to scroll to.
1048 * @param[in] duration The duration of the animation in seconds
1049 * @param[in] horizontalBias Whether to bias scrolling to left or right.
1050 * @param[in] verticalBias Whether to bias scrolling to top or bottom.
1051 * @param[in] alpha Alpha function to use
1052 * @note Contents will not snap to ruler snap points.
1053 * Biasing parameters are provided such that in scenarios with 2 or 2x2 pages in
1054 * wrap mode, the application developer can decide whether to scroll left or right
1055 * to get to the target page
1058 void ScrollTo(const Vector2& position, float duration, AlphaFunction alpha,
1059 DirectionBias horizontalBias, DirectionBias verticalBias);
1062 * @brief Scrolls View to page currently based on assumption that each page is
1063 * "(page) * ScrollViewSize.width, 0".
1066 * @param[in] page to scroll to
1067 * @note Should probably be upgraded so that page is an abstract class, that can be
1068 * a function of ScrollViewSize, ruler domain, ruler snap points etc. as pages may be
1069 * orchestrated in a 2D grid fashion, or variable width.
1072 void ScrollTo(unsigned int page);
1075 * @brief Scrolls View to page currently based on assumption that each page is
1076 * "(page) * ScrollViewSize.width, 0".
1079 * @param[in] page to scroll to
1080 * @param[in] duration The duration of the animation in seconds
1081 * @note Should probably be upgraded so that page is an abstract class, that can be
1082 * a function of ScrollViewSize, ruler domain, ruler snap points etc. as pages may be
1083 * orchestrated in a 2D grid fashion, or variable width.
1086 void ScrollTo(unsigned int page, float duration);
1089 * @brief Scrolls View to page currently based on assumption that each page is
1090 * "(page) * ScrollViewSize.width, 0".
1093 * @param[in] page to scroll to
1094 * @param[in] duration The duration of the animation in seconds
1095 * @param[in] bias Whether to bias scrolling to left or right.
1096 * @note Should probably be upgraded so that page is an abstract class, that can be
1097 * a function of ScrollViewSize, ruler domain, ruler snap points etc. as pages may be
1098 * orchestrated in a 2D grid fashion, or variable width.
1099 * A biasing parameter is provided such that in scenarios with 2 pages in wrap mode,
1100 * the application developer can decide whether to scroll left or right to get to
1104 void ScrollTo(unsigned int page, float duration, DirectionBias bias);
1107 * @brief Scrolls View such that actor appears in the center of the ScrollView.
1110 * @param[in] actor The actor to center in on (via Scrolling).
1111 * @note Actor must be a direct child of ScrollView, otherwise will
1112 * cause an assertion failure.
1114 void ScrollTo(Actor& actor);
1117 * @brief Scrolls View such that actor appears in the center of the ScrollView.
1120 * @param[in] actor The actor to center in on (via Scrolling).
1121 * @param[in] duration The duration of the animation in seconds
1122 * @note Actor must be a direct child of ScrollView, otherwise will
1123 * cause an assertion failure.
1125 void ScrollTo(Actor& actor, float duration);
1128 * @brief Scrolls View to the nearest snap points as specified by the Rulers.
1130 * If already at snap points, then will return false, and not scroll.
1133 * @return True if Snapping necessary.
1135 bool ScrollToSnapPoint();
1138 * @brief Applies a constraint that will affect the children of ScrollView.
1141 * @param[in] constraint The constraint to apply
1142 * @note this affects all existing and future Actors that are added to scrollview.
1144 void ApplyConstraintToChildren(Constraint constraint);
1147 * @brief Removes all constraints that will affect the children of ScrollView.
1150 * @note this removes all constraints from actors that have been added
1153 void RemoveConstraintsFromChildren();
1156 * @brief Apply Effect to ScrollView.
1159 * @param[in] effect The effect to apply to scroll view
1161 void ApplyEffect(ScrollViewEffect effect);
1164 * @brief Remove Effect from ScrollView.
1167 * @param[in] effect The effect to remove.
1169 void RemoveEffect(ScrollViewEffect effect);
1172 * @brief Remove All Effects from ScrollView.
1175 void RemoveAllEffects();
1178 * @brief Binds actor to this ScrollView.
1180 * Once an actor is bound to a ScrollView, it will be subject to
1181 * that ScrollView's properties.
1184 * @param[in] child The actor to add to this ScrollView.
1186 void BindActor(Actor child);
1189 * @brief Unbind Actor from this ScrollView.
1191 * Once Unbound, this ScrollView will not affect the actor.
1193 * @param[in] child The actor to be unbound.
1194 * @note this does not remove the child from the ScrollView container
1197 void UnbindActor(Actor child);
1200 * @brief Allows the user to constrain the scroll view in a particular direction.
1203 * @param[in] direction The axis to constrain the scroll-view to.
1204 * Usually set to PanGestureDetector::DIRECTION_VERTICAL or PanGestureDetector::DIRECTION_HORIZONTAL (but can be any other angle if desired).
1205 * @param[in] threshold The threshold to apply around the axis.
1206 * @note If no threshold is specified, then the default threshold of PI * 0.25 radians (or 45 degrees) is used.
1208 void SetScrollingDirection( Radian direction, Radian threshold = PanGestureDetector::DEFAULT_THRESHOLD );
1211 * @brief Remove a direction constraint from the scroll view.
1214 * @param[in] direction The axis to stop constraining to.
1215 * Usually will be PanGestureDetector::DIRECTION_VERTICAL or PanGestureDetector::DIRECTION_HORIZONTAL (but can be any other angle if desired).
1217 void RemoveScrollingDirection( Radian direction );
1222 * @brief Signal emitted when the ScrollView has started to snap or flick (it tells the target
1223 * position, scale, rotation for the snap or flick)
1225 * A callback of the following type may be connected:
1227 * void YourCallbackName(const SnapEvent& event);
1230 * @return The signal to connect to.
1231 * @pre The Object has been initialized.
1233 SnapStartedSignalType& SnapStartedSignal();
1235 public: // Not intended for application developers
1238 * @brief Creates a handle using the Toolkit::Internal implementation.
1241 * @param[in] implementation The Control implementation.
1243 DALI_INTERNAL ScrollView(Internal::ScrollView& implementation);
1246 * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
1249 * @param[in] internal A pointer to the internal CustomActor.
1251 explicit DALI_INTERNAL ScrollView( Dali::Internal::CustomActor* internal );
1257 } // namespace Toolkit
1261 #endif // __DALI_TOOLKIT_SCROLL_VIEW_H__