1 #ifndef DALI_TOOLKIT_SCROLL_VIEW_H
2 #define DALI_TOOLKIT_SCROLL_VIEW_H
5 * Copyright (c) 2020 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 Enumeration for 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 Enumeration for the snap type.
69 Snap, ///< Snap @SINCE_1_0.0
70 Flick ///< Flick @SINCE_1_0.0
74 * @brief Enumeration for 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_TOOLKIT_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 occurred 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 Abstracts class to define scroll axes.
153 * It can specify whether they are traversable,
154 * where their snap points are and their domain.
157 class DALI_TOOLKIT_API Ruler : public RefObject
161 * @brief Enumeration for the type of the ruler.
165 Fixed, ///< A fixed ruler @SINCE_1_0.0
166 Free ///< A free ruler @SINCE_1_0.0
172 * @brief Constructs ruler, enabled by default, with limitless domain.
178 * @brief Snaps (x) in accordance to the ruler settings.
181 * @param[in] x The input value on the ruler to be snapped
182 * @param[in] bias (optional) The biasing employed for snapping
183 * 0 floor input (floor x) "Used for Flick Left"
184 * 0.5 round input (floor x + 0.5) "Used for Release"
185 * 1 ceil input (floor x + 1.0) "Used for Flick Right"
186 * @return The position of the one dimensional point passed in once snapped.
188 virtual float Snap(float x, float bias = 0.5f) const = 0;
191 * @brief Returns position from page, based on whatever the ruler
194 * If (wrap) is true, then will set volume to the number of
195 * times page has exceeded the domain's volume (volume being the
196 * number of pages within the domain), while wrapping the position
200 * @param[in] page The page index
201 * @param[out] volume The overflow volume when the page exceeds the domain (wrap must be enabled)
202 * @param[in] wrap Enable wrap mode
203 * @return The position representing this page point
205 virtual float GetPositionFromPage(unsigned int page, unsigned int &volume, bool wrap) const = 0;
208 * @brief Returns page from position, based on whatever the ruler
211 * If (wrap) is true, then will return a page wrapped within the domain.
214 * @param[in] position The position on the domain
215 * @param[in] wrap Enable wrap mode
216 * @return The page where this position resides
218 virtual unsigned int GetPageFromPosition(float position, bool wrap) const = 0;
221 * @brief Returns the total number of pages within this Ruler.
224 * @return The number of pages in the Ruler
226 virtual unsigned int GetTotalPages() const = 0;
229 * @brief Gets the extension interface of the Ruler.
232 * @return The extension interface of the Ruler
234 virtual RulerExtension* GetExtension() { return NULL; }
239 * @brief Gets the ruler type.
242 * @return The ruler type
244 Ruler::RulerType GetType() const;
247 * @brief Returns whether this axis has been enabled or not.
250 * @return true if axis is enabled
252 bool IsEnabled() const;
255 * @brief Enables ruler (ruler must be enabled in order to traverse along it).
261 * @brief Disables ruler.
267 * @brief Sets the Domain.
270 * @param[in] domain Ruler domain object
272 void SetDomain(RulerDomain domain);
275 * @brief Gets the Domain.
280 const RulerDomain &GetDomain() const;
283 * @brief Disables Domain (minimum/maximum extents for this axis).
286 void DisableDomain();
289 * @brief Clamps value (x) from (min) to (max).
291 * An optional length parameter can be specified to suggest that the
292 * subject is not a point but a line that should be clamped.
295 * @param[in] x X point to be clamped between (min) and (max) extents
296 * @param[in] length (optional) The Length of the line from (x) to (x + length) to be clamped
297 * @param[in] scale Scaling parameter which treats domain as scaled in calculations
298 * @return The clamped value
300 float Clamp(float x, float length = 0.0f, float scale = 1.0f) const;
304 * @brief Clamps value (x) from (min) to (max).
306 * An optional length parameter can be specified to suggest that the
307 * subject is not a point but a line to that should be clamped.
310 * @param[in] x X point to be clamped between (min) and (max) extents
311 * @param[in] length (optional) The Length of the line from (x) to (x + length) to be clamped
312 * @param[in] scale Scaling parameter which treats domain as scaled in calculations
313 * @param[out] clamped Whether clamping occurred and which size (None, Min or Max)
314 * @return The clamped value
316 float Clamp(float x, float length, float scale, ClampState &clamped) const;
319 * @brief Snaps and Clamps (x) in accordance to ruler settings.
322 * @param[in] x X value to be snapped in accordance to ruler snap value,
323 * and clamped in accordance to the ruler's domain (if set)
324 * @param[in] bias (optional) The biasing employed for snapping
325 * 0 floor input (floor x) "Used for Flick Left"
326 * 0.5 round input (floor x + 0.5) "Used for Release"
327 * 1 ceil input (floor x + 1.0) "Used for Flick Right"
328 * @param[in] length (optional) The Length of the line from (x) to (x + length)
330 * @param[in] scale Scaling parameter which treats domain as scaled in calculations
331 * @return The clamped value after snapping
333 float SnapAndClamp(float x, float bias = 0.5f, float length = 0.0f, float scale = 1.0f) const;
336 * @brief Snaps and Clamps (x) in accordance to ruler settings.
339 * @param[in] x X value to be snapped in accordance to ruler snap value,
340 * and clamped in accordance to the ruler's domain (if set)
341 * @param[in] bias (optional) The biasing employed for snapping
342 * 0 floor input (floor x) "Used for Flick Left"
343 * 0.5 round input (floor x + 0.5) "Used for Release"
344 * 1 ceil input (floor x + 1.0) "Used for Flick Right"
345 * @param[in] length (optional) The Length of the line from (x) to (x + length)
347 * @param[in] scale Scaling parameter which treats domain as scaled in calculations
348 * @param[out] clamped Whether clamping occurred and which size (None, Min or Max)
349 * @return The clamped value after snapping
351 float SnapAndClamp(float x, float bias, float length, float scale, ClampState &clamped) const;
356 * @brief Destructor - A reference counted object may only be deleted by calling Unreference().
363 RulerType mType; ///< Type of Ruler (Fixed or Free).
364 bool mEnabled; ///< If the ruler is enabled.
365 RulerDomain mDomain; ///< The domain of the ruler.
369 typedef IntrusivePtr<Ruler> RulerPtr; ///< Pointer to Dali::Toolkit::Ruler object @SINCE_1_0.0
372 * @brief Concrete implementation of Ruler that has no snapping and has one single page.
375 class DALI_TOOLKIT_API DefaultRuler : public Ruler
379 * @brief DefaultRuler constructor.
385 * @copydoc Toolkit::Ruler::Snap
387 virtual float Snap(float x, float bias) const;
390 * @copydoc Toolkit::Ruler::GetPositionFromPage
392 virtual float GetPositionFromPage(unsigned int page, unsigned int &volume, bool wrap) const;
395 * @copydoc Toolkit::Ruler::GetPageFromPosition
397 virtual unsigned int GetPageFromPosition(float position, bool wrap) const;
400 * @copydoc Toolkit::Ruler::GetTotalPages
402 virtual unsigned int GetTotalPages() const;
406 * @brief Concrete implementation of Ruler that has fixed snapping.
409 class DALI_TOOLKIT_API FixedRuler : public Ruler
413 * @brief Constructor.
416 * @param[in] spacing The spacing between each interval on this ruler
418 FixedRuler(float spacing = 1.0f);
421 * @copydoc Toolkit::Ruler::Snap
423 virtual float Snap(float x, float bias) const;
426 * @copydoc Toolkit::Ruler::GetPositionFromPage
428 virtual float GetPositionFromPage(unsigned int page, unsigned int &volume, bool wrap) const;
431 * @copydoc Toolkit::Ruler::GetPageFromPosition
433 virtual unsigned int GetPageFromPosition(float position, bool wrap) const;
436 * @copydoc Toolkit::Ruler::GetTotalPages
438 virtual unsigned int GetTotalPages() const;
441 float mSpacing; ///< The spacing between each interval
444 class ScrollViewEffect;
448 * @brief ScrollView contains actors that can be scrolled manually (via touch)
452 * | %Signal Name | Method |
453 * |-------------------|----------------------------|
454 * | snap-started | @ref SnapStartedSignal() |
457 class DALI_TOOLKIT_API ScrollView : public Scrollable
463 * @brief Clamps signal event's data.
468 ClampState2D scale; ///< Clamp information for scale axes
469 ClampState2D position; ///< Clamp information for position axes
470 ClampState rotation; ///< Clamp information for rotation
474 * @brief Snaps signal event's data.
479 SnapType type; ///< Current snap commencing
480 Vector2 position; ///< Target snap position
481 float duration; ///< Duration of snap animation.
485 * @brief Enumeration for the start and end property ranges for this control.
490 PROPERTY_START_INDEX = Toolkit::Scrollable::PROPERTY_END_INDEX + 1, ///< @SINCE_1_1.18
491 PROPERTY_END_INDEX = PROPERTY_START_INDEX + 1000, ///< Reserve property indices, @SINCE_1_1.18
493 ANIMATABLE_PROPERTY_START_INDEX = Toolkit::Scrollable::ANIMATABLE_PROPERTY_END_INDEX + 1,
494 ANIMATABLE_PROPERTY_END_INDEX = ANIMATABLE_PROPERTY_START_INDEX + 1000 ///< Reserve animatable property indices @SINCE_1_0.0
498 * @brief Enumeration for the instance of properties belonging to the ScrollView class.
504 * @brief Enumeration for the instance of properties belonging to the ScrollView class.
509 ///////////////////////////////////////////////////////////////////////////////
510 // Event side (non-animatable) properties
511 ///////////////////////////////////////////////////////////////////////////////
514 * @brief Whether wrapping is enabled.
515 * @details Name "wrapEnabled", type Property::BOOLEAN.
519 WRAP_ENABLED = PROPERTY_START_INDEX,
522 * @brief Whether panning is enabled.
523 * @details Name "panningEnabled", type Property::BOOLEAN.
525 * @see SetScrollSensitive()
530 * @brief Whether the Axis Auto Lock mode for panning within the ScrollView is enabled.
531 * @details Name "axisAutoLockEnabled", type Property::BOOLEAN.
533 * @see SetAxisAutoLock()
535 AXIS_AUTO_LOCK_ENABLED,
538 * @brief The step of scroll distance in actor coordinates for each wheel event received in free panning mode.
539 * @details Name "wheelScrollDistanceStep", type Property::VECTOR2.
541 * @see SetWheelScrollDistanceStep()
543 WHEEL_SCROLL_DISTANCE_STEP,
546 * @brief The scroll mode.
547 * @details Name "scrollMode", type Property::MAP.
548 * The scroll mode map is a frontend for the Ruler helper class, containing the following keys:
550 * | %Property Name | Type | Required | Description |
551 * |----------------------|----------|----------|---------------------------------------------------------------------------------------------------------------------------------------|
552 * | xAxisScrollEnabled | BOOLEAN | No | True if the content can be scrolled in X axis or false if not. |
553 * | xAxisSnapToInterval | FLOAT | No | When set, causes scroll view to snap to multiples of the value of the interval in the X axis while flicking. (by default no snapping) |
554 * | xAxisScrollBoundary | FLOAT | No | When set, causes scroll view unable to scroll beyond the value of the boundary in the X axis (by default no boundary) |
555 * | yAxisScrollEnabled | BOOLEAN | No | True if the content can be scrolled in Y axis or false if not. |
556 * | yAxisSnapToInterval | FLOAT | No | When set, causes scroll view to snap to multiples of the value of the interval in the Y axis while flicking. (by default no snapping) |
557 * | yAxisScrollBoundary | FLOAT | No | When set, causes scroll view unable to scroll beyond the value of the boundary in the Y axis (by default no boundary) |
559 * Alternatively, one can use the keys defined in the Dali::Toolkit::ScrollMode::Type enumeration.
564 ///////////////////////////////////////////////////////////////////////////////
565 // Animatable Properties
566 ///////////////////////////////////////////////////////////////////////////////
569 * @brief The current scroll position.
570 * @details Name "scrollPosition", type Property::VECTOR2.
573 SCROLL_POSITION = ANIMATABLE_PROPERTY_START_INDEX,
576 * @brief The position before we set the clamp at scroll boundaries.
577 * @details Name "scrollPrePosition", type Property::VECTOR2.
583 * @brief The X component of SCROLL_PRE_POSITION.
584 * @details Name "scrollPrePositionX", type Property::FLOAT.
587 SCROLL_PRE_POSITION_X,
590 * @brief The Y component of SCROLL_PRE_POSITION.
591 * @details Name "scrollPrePositionY", type Property::VECTOR2.
594 SCROLL_PRE_POSITION_Y,
597 * @brief The maximum value that SCROLL_PRE_POSITION can be.
598 * @details Name "scrollPrePositionMax", type Property::VECTOR2.
601 SCROLL_PRE_POSITION_MAX,
604 * @brief The X component of SCROLL_PRE_POSITION_MAX.
605 * @details Name "scrollPrePositionMaxX", type Property::FLOAT.
608 SCROLL_PRE_POSITION_MAX_X,
611 * @brief The Y component of SCROLL_PRE_POSITION_MAX.
612 * @details Name "scrollPrePositionMaxY", type Property::FLOAT.
615 SCROLL_PRE_POSITION_MAX_Y,
618 * @brief The amount that we can scroll beyond the boundary along the X axis.
619 * @details Name "overshootX", type Property::FLOAT.
625 * @brief The amount that we can scroll beyond the boundary along the Y axis.
626 * @details Name "overshootY", type Property::FLOAT.
632 * @brief The position after the overshoot value has been considered in the calculation.
633 * @details Name "scrollFinal", type Property::VECTOR2.
639 * @brief The X component of SCROLL_FINAL.
640 * @details Name "scrollFinalX", type Property::FLOAT.
646 * @brief The Y component of SCROLL_FINAL.
647 * @details Name "scrollFinalY", type Property::FLOAT.
653 * @brief Whether scrolling wraps.
654 * @details Name "wrap", type Property::BOOLEAN.
660 * @brief Whether we are currently panning.
661 * @details Name "panning", type Property::BOOLEAN.
667 * @brief Whether we are currently scrolling.
668 * @details Name "scrolling", type Property::BOOLEAN.
674 * @brief The size of the scrolling domain.
675 * @details Name "scrollDomainSize", type Property::VECTOR2.
681 * @brief The X component of SCROLL_DOMAIN_SIZE.
682 * @details Name "scrollDomainSizeX", type Property::FLOAT.
685 SCROLL_DOMAIN_SIZE_X,
688 * @brief The Y component of SCROLL_DOMAIN_SIZE.
689 * @details Name "scrollDomainSizeY", type Property::FLOAT.
692 SCROLL_DOMAIN_SIZE_Y,
695 * @brief The offset of the scroll domain.
696 * @details Name "scrollDomainOffset", type Property::VECTOR2.
699 SCROLL_DOMAIN_OFFSET,
702 * @brief The delta in the position when scrolling.
703 * @details Name "scrollPositionDelta", type Property::VECTOR2.
706 SCROLL_POSITION_DELTA,
709 * @brief The starting page position.
710 * @details Name "startPagePosition", type Property::VECTOR3.
719 typedef Signal< void ( const SnapEvent& ) > SnapStartedSignalType; ///< SnapStarted signal type @SINCE_1_0.0
724 * @brief Creates an empty ScrollView handle.
730 * @brief Copy constructor.
732 * Creates another handle that points to the same real object.
735 * @param[in] handle Handle to copy from
737 ScrollView( const ScrollView& handle );
740 * @brief Move constructor
743 * @param[in] rhs A reference to the moved handle
745 ScrollView( ScrollView&& rhs );
748 * @brief Assignment operator.
750 * Changes this handle to point to another real object.
752 * @param[in] handle The handle to copy from
753 * @return A reference to this
755 ScrollView& operator=( const ScrollView& handle );
758 * @brief Move assignment
761 * @param[in] rhs A reference to the moved handle
762 * @return A reference to this
764 ScrollView& operator=( ScrollView&& rhs );
769 * This is non-virtual since derived Handle types must not contain data or virtual methods.
775 * @brief Creates an initialized ScrollView.
778 * @return A handle to a newly allocated Dali resource
780 static ScrollView New();
783 * @brief Downcasts a handle to ScrollView handle.
785 * If handle points to a ScrollView, the downcast produces valid handle.
786 * If not, the returned handle is left uninitialized.
789 * @param[in] handle Handle to an object
790 * @return A handle to a ScrollView or an uninitialized handle
792 static ScrollView DownCast( BaseHandle handle );
797 * @brief Gets snap-animation's AlphaFunction.
800 * @return Current easing alpha function of the snap animation
802 AlphaFunction GetScrollSnapAlphaFunction() const;
805 * @brief Sets snap-animation's AlphaFunction.
808 * @param[in] alpha Easing alpha function of the snap animation
810 void SetScrollSnapAlphaFunction(AlphaFunction alpha);
813 * @brief Gets flick-animation's AlphaFunction.
816 * @return Current easing alpha function of the flick animation
818 AlphaFunction GetScrollFlickAlphaFunction() const;
821 * @brief Sets flick-animation's AlphaFunction.
824 * @param[in] alpha Easing alpha function of the flick animation
826 void SetScrollFlickAlphaFunction(AlphaFunction alpha);
829 * @brief Gets the time for the scroll snap-animation.
831 * This animation occurs when the user drags, and releases.
834 * @return The time in seconds for the animation to take
836 float GetScrollSnapDuration() const;
839 * @brief Sets the time for the scroll snap-animation.
841 * This animation occurs when the user drags, and releases.
844 * @param[in] time The time in seconds for the animation to take
846 void SetScrollSnapDuration(float time);
849 * @brief Gets the time for the scroll flick-animation.
851 * This animation occurs when the user flicks scroll view.
854 * @return The time in seconds for the animation to take
856 float GetScrollFlickDuration() const;
859 * @brief Sets the time for the scroll flick-animation.
861 * This animation occurs when the user flicks scroll view.
864 * @param[in] time The time in seconds for the animation to take
866 void SetScrollFlickDuration(float time);
869 * @brief Sets X axis ruler.
871 * Defines how scrolling horizontally is snapped, and
872 * the boundary (domain) in which the ScrollView can pan.
875 * @param[in] ruler The ruler to be used for the X axis
877 void SetRulerX(RulerPtr ruler);
880 * @brief Sets Y axis ruler.
882 * Defines how scrolling vertically is snapped, and the boundary
883 * (domain) in which the ScrollView can pan.
886 * @param[in] ruler The ruler to be used for the Y axis
888 void SetRulerY(RulerPtr ruler);
891 * @brief Sets scroll sensitivity of pan gesture.
894 * @param[in] sensitive @c true to enable scroll, @c false to disable scrolling
895 * @note Unlike Actor::Property::SENSITIVE, this determines whether this ScrollView
896 * should react (e.g. pan), without disrupting the sensitivity of its children.
899 void SetScrollSensitive(bool sensitive);
902 * @brief Sets maximum overshoot amount.
904 * The final overshoot value is within 0.0f to 1.0f, but the maximum
905 * overshoot is in pixels (e.g. if you scroll 75 pixels beyond the
906 * edge of a scrollable area and the maximum overshoot is 100 then
907 * the final overshoot value will be 0.75f).
910 * @param[in] overshootX The maximum number of horizontally scrolled pixels before overshoot X reaches 1.0f
911 * @param[in] overshootY The maximum number of vertically scrolled pixels before overshoot Y reaches 1.0f
913 void SetMaxOvershoot(float overshootX, float overshootY);
916 * @brief Sets Snap Overshoot animation's AlphaFunction.
919 * @param[in] alpha Easing alpha function of the overshoot snap animation
921 void SetSnapOvershootAlphaFunction(AlphaFunction alpha);
924 * @brief Sets Snap Overshoot animation's Duration.
927 * @param[in] duration The duration of the overshoot snap animation
928 * @note Set duration to 0 seconds to disable Animation.
931 void SetSnapOvershootDuration(float duration);
934 * @brief Enables or Disables Actor Auto-Snap mode.
936 * When Actor Auto-Snap mode has been enabled, ScrollView will automatically
937 * snap to the closest actor (The closest actor will appear in the center of
941 * @param[in] enable Enables (true), or disables (false) Actor AutoSnap
943 void SetActorAutoSnap(bool enable);
946 * @brief Enables or Disables Wrap mode for ScrollView contents.
948 * When enabled, the ScrollView contents are wrapped over the X/Y Domain.
951 * @param[in] enable Enables (true), or disables (false) Wrap Mode
952 * @note You must apply a position constraint that causes Wrapping
956 void SetWrapMode(bool enable);
959 * @brief Gets the current distance needed to scroll for ScrollUpdatedSignal to be emitted.
962 * @return Current scroll update distance
964 int GetScrollUpdateDistance() const;
967 * @brief Sets the distance needed to scroll for ScrollUpdatedSignal to be emitted.
969 * The scroll update distance tells ScrollView how far to move before ScrollUpdatedSignal the informs application.
970 * Each time the ScrollView crosses this distance the signal will be emitted.
973 * @param[in] distance The distance for ScrollView to move before emitting update signal
975 void SetScrollUpdateDistance(int distance);
978 * @brief Returns state of Axis Auto Lock mode.
981 * @return Whether Axis Auto Lock mode has been enabled or not
983 bool GetAxisAutoLock() const;
986 * @brief Enables or Disables Axis Auto Lock mode for panning within the ScrollView.
988 * When enabled, any pan gesture that appears mostly horizontal or mostly
989 * vertical, will be automatically restricted to horizontal only or vertical
990 * only panning, until the pan gesture has completed.
993 * @param[in] enable Enables (true), or disables (false) AxisAutoLock mode
995 void SetAxisAutoLock(bool enable);
998 * @brief Gets the gradient threshold at which a panning gesture
999 * should be locked to the Horizontal or Vertical axis.
1002 * @return The gradient, a value between 0.0 and 1.0f
1004 float GetAxisAutoLockGradient() const;
1007 * @brief Sets the gradient threshold at which a panning gesture should be locked to the
1008 * Horizontal or Vertical axis.
1010 * By default, this is 0.36 (0.36:1) which means angles less than 20
1011 * degrees to an axis will lock to that axis.
1014 * @param[in] gradient A value between 0.0 and 1.0 (auto-lock for all angles)
1015 * @note Specifying a value of 1.0 (the maximum value accepted) indicates that
1016 * all panning gestures will auto-lock either to the horizontal or vertical axis.
1019 void SetAxisAutoLockGradient(float gradient);
1022 * @brief Gets the friction coefficient setting for ScrollView when
1023 * flicking in free panning mode.
1025 * This is a value in stage-diagonals per second^2.
1026 * stage-diagonal = Length( stage.width, stage.height )
1028 * @return Friction coefficient is returned
1030 float GetFrictionCoefficient() const;
1033 * @brief Sets the friction coefficient for ScrollView when flicking
1034 * in free panning mode.
1036 * This is a value in stage-diagonals per second^2.
1037 * stage-diagonal = Length( stage.width, stage.height ).
1039 * A stage 480x800 in size has a diagonal length of 933.
1040 * Friction coefficient of 1.0 means the swipe velocity will
1041 * reduce by 1.0 * 933 pixels/sec^2.
1043 * @param[in] friction Friction coefficient must be greater than 0.0 (default = 1.0)
1045 void SetFrictionCoefficient(float friction);
1048 * @brief Gets the flick speed coefficient for ScrollView when
1049 * flicking in free panning mode.
1051 * This is a constant which multiplies the input touch
1052 * flick velocity to determine the actual velocity at
1053 * which to move the scrolling area.
1055 * @return The flick speed coefficient is returned
1057 float GetFlickSpeedCoefficient() const;
1060 * @brief Sets the flick speed coefficient for ScrollView when
1061 * flicking in free panning mode.
1063 * This is a constant which multiplies the input touch
1064 * flick velocity to determine the actual velocity at
1065 * which to move the scrolling area.
1067 * @param[in] speed The flick speed coefficient (default = 1.0)
1069 void SetFlickSpeedCoefficient(float speed);
1072 * @brief Returns the minimum pan distance required for a flick gesture in pixels.
1075 * @return Minimum pan distance vector with separate x and y distance
1077 Vector2 GetMinimumDistanceForFlick() const;
1080 * @brief Sets the minimum pan distance required for a flick in pixels.
1082 * 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.
1085 * @param[in] distance The minimum pan distance for a flick
1087 void SetMinimumDistanceForFlick( const Vector2& distance );
1090 * @brief Returns the minimum pan speed required for a flick gesture in pixels per second.
1093 * @return Minimum pan speed
1095 float GetMinimumSpeedForFlick() const;
1098 * @brief Sets the minimum pan speed required for a flick in pixels per second.
1101 * @param[in] speed The minimum pan speed for a flick
1103 void SetMinimumSpeedForFlick( float speed );
1106 * @brief Gets the maximum flick speed setting for ScrollView when
1107 * flicking in free panning mode.
1109 * This is a value in stage-diagonals per second.
1110 * stage-diagonal = Length( stage.width, stage.height )
1112 * @return Maximum flick speed is returned
1114 float GetMaxFlickSpeed() const;
1117 * @brief Sets the maximum flick speed for the ScrollView when
1118 * flicking in free panning mode.
1120 * This is a value in stage-diagonals per second.
1121 * stage-diagonal = Length( stage.width, stage.height )
1123 * A stage 480x800 in size has a diagonal length of 933.
1124 * Max Flick speed of 1.0 means the maximum velocity of
1125 * a swipe can be 1.0 * 933 pixels/sec.
1127 * @param[in] speed Maximum flick speed (default = 3.0)
1129 void SetMaxFlickSpeed(float speed);
1132 * @brief Gets the step of scroll distance in actor coordinates for
1133 * each wheel event received in free panning mode.
1136 * @return The step of scroll distance(pixel) in X and Y axes
1138 Vector2 GetWheelScrollDistanceStep() const;
1141 * @brief Sets the step of scroll distance in actor coordinates for
1142 * each wheel event received in free panning mode.
1145 * @param[in] step The step of scroll distance(pixel) in X and Y axes
1147 * @note If snap points are defined in the rulers, it will always
1148 * scroll to the next snap point towards the scroll direction while
1149 * receiving the wheel events.
1152 void SetWheelScrollDistanceStep(Vector2 step);
1155 * @brief Retrieves current scroll position.
1158 * @return The current scroll position
1160 Vector2 GetCurrentScrollPosition() const;
1163 * @brief Retrieves current scroll page based on ScrollView
1164 * dimensions being the size of one page, and all pages laid out in
1165 * a grid fashion, increasing from left to right until the end of
1169 * @note Pages start from 0 as the first page, not 1.
1171 * @return The Current page
1173 unsigned int GetCurrentPage() const;
1176 * @brief Scrolls View to position specified (contents will scroll to this position).
1178 * Position 0,0 is the origin. Increasing X scrolls contents left, while
1179 * increasing Y scrolls contents up.
1180 * - If Rulers have been applied to the axes, then the contents will scroll until
1181 * reaching the domain boundary.
1183 * @param[in] position The position to scroll to
1184 * @note Contents will not snap to ruler snap points.
1187 void ScrollTo(const Vector2& position);
1190 * @brief Scrolls View to position specified (contents will scroll to this position).
1192 * Position 0,0 is the origin. Increasing X scrolls contents left, while
1193 * increasing Y scrolls contents up.
1194 * - If Rulers have been applied to the axes, then the contents will scroll until
1195 * reaching the domain boundary.
1197 * @param[in] position The position to scroll to
1198 * @param[in] duration The duration of the animation in seconds
1199 * @note Contents will not snap to ruler snap points.
1202 void ScrollTo(const Vector2& position, float duration);
1205 * @brief Scrolls View to position specified (contents will scroll to this position).
1207 * Position 0,0 is the origin. Increasing X scrolls contents left, while
1208 * increasing Y scrolls contents up.
1209 * - If Rulers have been applied to the axes, then the contents will scroll until
1210 * reaching the domain boundary.
1212 * @param[in] position The position to scroll to
1213 * @param[in] duration The duration of the animation in seconds
1214 * @param[in] alpha The alpha function to use
1215 * @note Contents will not snap to ruler snap points.
1218 void ScrollTo(const Vector2& position, float duration, AlphaFunction alpha);
1221 * @brief Scrolls View to position specified (contents will scroll to this position).
1223 * Position 0,0 is the origin. Increasing X scrolls contents left, while
1224 * increasing Y scrolls contents up.
1225 * - If Rulers have been applied to the axes, then the contents will scroll until
1226 * reaching the domain boundary.
1228 * @param[in] position The position to scroll to
1229 * @param[in] duration The duration of the animation in seconds
1230 * @param[in] horizontalBias Whether to bias scrolling to left or right
1231 * @param[in] verticalBias Whether to bias scrolling to top or bottom
1232 * @note Contents will not snap to ruler snap points.
1233 * Biasing parameters are provided such that in scenarios with 2 or 2x2 pages in
1234 * wrap mode, the application developer can decide whether to scroll left or right
1235 * to get to the target page.
1238 void ScrollTo(const Vector2& position, float duration,
1239 DirectionBias horizontalBias, DirectionBias verticalBias);
1242 * @brief Scrolls View to position specified (contents will scroll to this position).
1244 * Position 0,0 is the origin. Increasing X scrolls contents left, while
1245 * increasing Y scrolls contents up.
1246 * - If Rulers have been applied to the axes, then the contents will scroll until
1247 * reaching the domain boundary.
1249 * @param[in] position The position to scroll to
1250 * @param[in] duration The duration of the animation in seconds
1251 * @param[in] horizontalBias Whether to bias scrolling to left or right
1252 * @param[in] verticalBias Whether to bias scrolling to top or bottom
1253 * @param[in] alpha Alpha function to use
1254 * @note Contents will not snap to ruler snap points.
1255 * Biasing parameters are provided such that in scenarios with 2 or 2x2 pages in
1256 * wrap mode, the application developer can decide whether to scroll left or right
1257 * to get to the target page.
1260 void ScrollTo(const Vector2& position, float duration, AlphaFunction alpha,
1261 DirectionBias horizontalBias, DirectionBias verticalBias);
1264 * @brief Scrolls View to page currently based on assumption that each page is
1265 * "(page) * ScrollViewSize.width, 0".
1268 * @param[in] page The page to scroll to
1269 * @note Should probably be upgraded so that page is an abstract class, that can be
1270 * a function of ScrollViewSize, ruler domain, ruler snap points etc. as pages may be
1271 * orchestrated in a 2D grid fashion, or variable width.
1274 void ScrollTo(unsigned int page);
1277 * @brief Scrolls View to page currently based on assumption that each page is
1278 * "(page) * ScrollViewSize.width, 0".
1281 * @param[in] page The page to scroll to
1282 * @param[in] duration The duration of the animation in seconds
1283 * @note Should probably be upgraded so that page is an abstract class, that can be
1284 * a function of ScrollViewSize, ruler domain, ruler snap points etc. as pages may be
1285 * orchestrated in a 2D grid fashion, or variable width.
1288 void ScrollTo(unsigned int page, float duration);
1291 * @brief Scrolls View to page currently based on assumption that each page is
1292 * "(page) * ScrollViewSize.width, 0".
1295 * @param[in] page The page to scroll to
1296 * @param[in] duration The duration of the animation in seconds
1297 * @param[in] bias Whether to bias scrolling to left or right
1298 * @note Should probably be upgraded so that page is an abstract class, that can be
1299 * a function of ScrollViewSize, ruler domain, ruler snap points etc. as pages may be
1300 * orchestrated in a 2D grid fashion, or variable width.
1301 * A biasing parameter is provided such that in scenarios with 2 pages in wrap mode,
1302 * the application developer can decide whether to scroll left or right to get to
1306 void ScrollTo(unsigned int page, float duration, DirectionBias bias);
1309 * @brief Scrolls View such that actor appears in the center of the ScrollView.
1312 * @param[in] actor The actor to center in on (via Scrolling)
1313 * @note Actor must be a direct child of ScrollView, otherwise will
1314 * cause an assertion failure.
1316 void ScrollTo(Actor& actor);
1319 * @brief Scrolls View such that actor appears in the center of the ScrollView.
1322 * @param[in] actor The actor to center in on (via Scrolling)
1323 * @param[in] duration The duration of the animation in seconds
1324 * @note Actor must be a direct child of ScrollView, otherwise will
1325 * cause an assertion failure.
1327 void ScrollTo(Actor& actor, float duration);
1330 * @brief Scrolls View to the nearest snap points as specified by the Rulers.
1332 * If already at snap points, then will return false, and not scroll.
1335 * @return True if Snapping necessary
1337 bool ScrollToSnapPoint();
1340 * @brief Applies a constraint that will affect the children of ScrollView.
1343 * @param[in] constraint The constraint to apply
1344 * @note This affects all existing and future Actors that are added to scrollview.
1346 void ApplyConstraintToChildren(Constraint constraint);
1349 * @brief Removes all constraints that will affect the children of ScrollView.
1352 * @note This removes all constraints from actors that have been added
1355 void RemoveConstraintsFromChildren();
1358 * @brief Applies Effect to ScrollView.
1361 * @param[in] effect The effect to apply to scroll view
1363 void ApplyEffect(ScrollViewEffect effect);
1366 * @brief Removes Effect from ScrollView.
1369 * @param[in] effect The effect to remove
1371 void RemoveEffect(ScrollViewEffect effect);
1374 * @brief Remove All Effects from ScrollView.
1377 void RemoveAllEffects();
1380 * @brief Binds actor to this ScrollView.
1382 * Once an actor is bound to a ScrollView, it will be subject to
1383 * that ScrollView's properties.
1386 * @param[in] child The actor to add to this ScrollView
1388 void BindActor(Actor child);
1391 * @brief Unbinds Actor from this ScrollView.
1393 * Once Unbound, this ScrollView will not affect the actor.
1395 * @param[in] child The actor to be unbound
1396 * @note This does not remove the child from the ScrollView container
1399 void UnbindActor(Actor child);
1402 * @brief Allows the user to constrain the scroll view in a particular direction.
1405 * @param[in] direction The axis to constrain the scroll-view to.
1406 * Usually set to PanGestureDetector::DIRECTION_VERTICAL or PanGestureDetector::DIRECTION_HORIZONTAL (but can be any other angle if desired).
1407 * @param[in] threshold The threshold to apply around the axis
1408 * @note If no threshold is specified, then the default threshold of PI * 0.25 radians (or 45 degrees) is used.
1410 void SetScrollingDirection( Radian direction, Radian threshold = PanGestureDetector::DEFAULT_THRESHOLD );
1413 * @brief Removes a direction constraint from the scroll view.
1416 * @param[in] direction The axis to stop constraining to.
1417 * Usually will be PanGestureDetector::DIRECTION_VERTICAL or PanGestureDetector::DIRECTION_HORIZONTAL (but can be any other angle if desired).
1419 void RemoveScrollingDirection( Radian direction );
1424 * @brief Signal emitted when the ScrollView has started to snap or flick (it tells the target
1425 * position, scale, rotation for the snap or flick).
1427 * A callback of the following type may be connected:
1429 * void YourCallbackName(const SnapEvent& event);
1432 * @return The signal to connect to
1433 * @pre The Object has been initialized.
1435 SnapStartedSignalType& SnapStartedSignal();
1437 public: // Not intended for application developers
1441 * @brief Creates a handle using the Toolkit::Internal implementation.
1444 * @param[in] implementation The Control implementation
1446 DALI_INTERNAL ScrollView(Internal::ScrollView& implementation);
1449 * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
1452 * @param[in] internal A pointer to the internal CustomActor
1454 explicit DALI_INTERNAL ScrollView( Dali::Internal::CustomActor* internal );
1461 } // namespace Toolkit
1465 #endif // DALI_TOOLKIT_SCROLL_VIEW_H