1 #ifndef DALI_TOOLKIT_SCROLL_VIEW_H
2 #define DALI_TOOLKIT_SCROLL_VIEW_H
5 * Copyright (c) 2019 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 Assignment operator.
742 * Changes this handle to point to another real object.
744 * @param[in] handle The handle to copy from
745 * @return A reference to this
747 ScrollView& operator=( const ScrollView& handle );
752 * This is non-virtual since derived Handle types must not contain data or virtual methods.
758 * @brief Creates an initialized ScrollView.
761 * @return A handle to a newly allocated Dali resource
763 static ScrollView New();
766 * @brief Downcasts a handle to ScrollView handle.
768 * If handle points to a ScrollView, the downcast produces valid handle.
769 * If not, the returned handle is left uninitialized.
772 * @param[in] handle Handle to an object
773 * @return A handle to a ScrollView or an uninitialized handle
775 static ScrollView DownCast( BaseHandle handle );
780 * @brief Gets snap-animation's AlphaFunction.
783 * @return Current easing alpha function of the snap animation
785 AlphaFunction GetScrollSnapAlphaFunction() const;
788 * @brief Sets snap-animation's AlphaFunction.
791 * @param[in] alpha Easing alpha function of the snap animation
793 void SetScrollSnapAlphaFunction(AlphaFunction alpha);
796 * @brief Gets flick-animation's AlphaFunction.
799 * @return Current easing alpha function of the flick animation
801 AlphaFunction GetScrollFlickAlphaFunction() const;
804 * @brief Sets flick-animation's AlphaFunction.
807 * @param[in] alpha Easing alpha function of the flick animation
809 void SetScrollFlickAlphaFunction(AlphaFunction alpha);
812 * @brief Gets the time for the scroll snap-animation.
814 * This animation occurs when the user drags, and releases.
817 * @return The time in seconds for the animation to take
819 float GetScrollSnapDuration() const;
822 * @brief Sets the time for the scroll snap-animation.
824 * This animation occurs when the user drags, and releases.
827 * @param[in] time The time in seconds for the animation to take
829 void SetScrollSnapDuration(float time);
832 * @brief Gets the time for the scroll flick-animation.
834 * This animation occurs when the user flicks scroll view.
837 * @return The time in seconds for the animation to take
839 float GetScrollFlickDuration() const;
842 * @brief Sets the time for the scroll flick-animation.
844 * This animation occurs when the user flicks scroll view.
847 * @param[in] time The time in seconds for the animation to take
849 void SetScrollFlickDuration(float time);
852 * @brief Sets X axis ruler.
854 * Defines how scrolling horizontally is snapped, and
855 * the boundary (domain) in which the ScrollView can pan.
858 * @param[in] ruler The ruler to be used for the X axis
860 void SetRulerX(RulerPtr ruler);
863 * @brief Sets Y axis ruler.
865 * Defines how scrolling vertically is snapped, and the boundary
866 * (domain) in which the ScrollView can pan.
869 * @param[in] ruler The ruler to be used for the Y axis
871 void SetRulerY(RulerPtr ruler);
874 * @brief Sets scroll sensitivity of pan gesture.
877 * @param[in] sensitive @c true to enable scroll, @c false to disable scrolling
878 * @note Unlike Actor::SetSensitive(), this determines whether this ScrollView
879 * should react (e.g. pan), without disrupting the sensitivity of its children.
882 void SetScrollSensitive(bool sensitive);
885 * @brief Sets maximum overshoot amount.
887 * The final overshoot value is within 0.0f to 1.0f, but the maximum
888 * overshoot is in pixels (e.g. if you scroll 75 pixels beyond the
889 * edge of a scrollable area and the maximum overshoot is 100 then
890 * the final overshoot value will be 0.75f).
893 * @param[in] overshootX The maximum number of horizontally scrolled pixels before overshoot X reaches 1.0f
894 * @param[in] overshootY The maximum number of vertically scrolled pixels before overshoot Y reaches 1.0f
896 void SetMaxOvershoot(float overshootX, float overshootY);
899 * @brief Sets Snap Overshoot animation's AlphaFunction.
902 * @param[in] alpha Easing alpha function of the overshoot snap animation
904 void SetSnapOvershootAlphaFunction(AlphaFunction alpha);
907 * @brief Sets Snap Overshoot animation's Duration.
910 * @param[in] duration The duration of the overshoot snap animation
911 * @note Set duration to 0 seconds to disable Animation.
914 void SetSnapOvershootDuration(float duration);
917 * @brief Enables or Disables Actor Auto-Snap mode.
919 * When Actor Auto-Snap mode has been enabled, ScrollView will automatically
920 * snap to the closest actor (The closest actor will appear in the center of
924 * @param[in] enable Enables (true), or disables (false) Actor AutoSnap
926 void SetActorAutoSnap(bool enable);
929 * @brief Enables or Disables Wrap mode for ScrollView contents.
931 * When enabled, the ScrollView contents are wrapped over the X/Y Domain.
934 * @param[in] enable Enables (true), or disables (false) Wrap Mode
935 * @note You must apply a position constraint that causes Wrapping
939 void SetWrapMode(bool enable);
942 * @brief Gets the current distance needed to scroll for ScrollUpdatedSignal to be emitted.
945 * @return Current scroll update distance
947 int GetScrollUpdateDistance() const;
950 * @brief Sets the distance needed to scroll for ScrollUpdatedSignal to be emitted.
952 * The scroll update distance tells ScrollView how far to move before ScrollUpdatedSignal the informs application.
953 * Each time the ScrollView crosses this distance the signal will be emitted.
956 * @param[in] distance The distance for ScrollView to move before emitting update signal
958 void SetScrollUpdateDistance(int distance);
961 * @brief Returns state of Axis Auto Lock mode.
964 * @return Whether Axis Auto Lock mode has been enabled or not
966 bool GetAxisAutoLock() const;
969 * @brief Enables or Disables Axis Auto Lock mode for panning within the ScrollView.
971 * When enabled, any pan gesture that appears mostly horizontal or mostly
972 * vertical, will be automatically restricted to horizontal only or vertical
973 * only panning, until the pan gesture has completed.
976 * @param[in] enable Enables (true), or disables (false) AxisAutoLock mode
978 void SetAxisAutoLock(bool enable);
981 * @brief Gets the gradient threshold at which a panning gesture
982 * should be locked to the Horizontal or Vertical axis.
985 * @return The gradient, a value between 0.0 and 1.0f
987 float GetAxisAutoLockGradient() const;
990 * @brief Sets the gradient threshold at which a panning gesture should be locked to the
991 * Horizontal or Vertical axis.
993 * By default, this is 0.36 (0.36:1) which means angles less than 20
994 * degrees to an axis will lock to that axis.
997 * @param[in] gradient A value between 0.0 and 1.0 (auto-lock for all angles)
998 * @note Specifying a value of 1.0 (the maximum value accepted) indicates that
999 * all panning gestures will auto-lock either to the horizontal or vertical axis.
1002 void SetAxisAutoLockGradient(float gradient);
1005 * @brief Gets the friction coefficient setting for ScrollView when
1006 * flicking in free panning mode.
1008 * This is a value in stage-diagonals per second^2.
1009 * stage-diagonal = Length( stage.width, stage.height )
1011 * @return Friction coefficient is returned
1013 float GetFrictionCoefficient() const;
1016 * @brief Sets the friction coefficient for ScrollView when flicking
1017 * in free panning mode.
1019 * This is a value in stage-diagonals per second^2.
1020 * stage-diagonal = Length( stage.width, stage.height ).
1022 * A stage 480x800 in size has a diagonal length of 933.
1023 * Friction coefficient of 1.0 means the swipe velocity will
1024 * reduce by 1.0 * 933 pixels/sec^2.
1026 * @param[in] friction Friction coefficient must be greater than 0.0 (default = 1.0)
1028 void SetFrictionCoefficient(float friction);
1031 * @brief Gets the flick speed coefficient for ScrollView when
1032 * flicking in free panning mode.
1034 * This is a constant which multiplies the input touch
1035 * flick velocity to determine the actual velocity at
1036 * which to move the scrolling area.
1038 * @return The flick speed coefficient is returned
1040 float GetFlickSpeedCoefficient() const;
1043 * @brief Sets the flick speed coefficient for ScrollView when
1044 * flicking in free panning mode.
1046 * This is a constant which multiplies the input touch
1047 * flick velocity to determine the actual velocity at
1048 * which to move the scrolling area.
1050 * @param[in] speed The flick speed coefficient (default = 1.0)
1052 void SetFlickSpeedCoefficient(float speed);
1055 * @brief Returns the minimum pan distance required for a flick gesture in pixels.
1058 * @return Minimum pan distance vector with separate x and y distance
1060 Vector2 GetMinimumDistanceForFlick() const;
1063 * @brief Sets the minimum pan distance required for a flick in pixels.
1065 * 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.
1068 * @param[in] distance The minimum pan distance for a flick
1070 void SetMinimumDistanceForFlick( const Vector2& distance );
1073 * @brief Returns the minimum pan speed required for a flick gesture in pixels per second.
1076 * @return Minimum pan speed
1078 float GetMinimumSpeedForFlick() const;
1081 * @brief Sets the minimum pan speed required for a flick in pixels per second.
1084 * @param[in] speed The minimum pan speed for a flick
1086 void SetMinimumSpeedForFlick( float speed );
1089 * @brief Gets the maximum flick speed setting for ScrollView when
1090 * flicking in free panning mode.
1092 * This is a value in stage-diagonals per second.
1093 * stage-diagonal = Length( stage.width, stage.height )
1095 * @return Maximum flick speed is returned
1097 float GetMaxFlickSpeed() const;
1100 * @brief Sets the maximum flick speed for the ScrollView when
1101 * flicking in free panning mode.
1103 * This is a value in stage-diagonals per second.
1104 * stage-diagonal = Length( stage.width, stage.height )
1106 * A stage 480x800 in size has a diagonal length of 933.
1107 * Max Flick speed of 1.0 means the maximum velocity of
1108 * a swipe can be 1.0 * 933 pixels/sec.
1110 * @param[in] speed Maximum flick speed (default = 3.0)
1112 void SetMaxFlickSpeed(float speed);
1115 * @brief Gets the step of scroll distance in actor coordinates for
1116 * each wheel event received in free panning mode.
1119 * @return The step of scroll distance(pixel) in X and Y axes
1121 Vector2 GetWheelScrollDistanceStep() const;
1124 * @brief Sets the step of scroll distance in actor coordinates for
1125 * each wheel event received in free panning mode.
1128 * @param[in] step The step of scroll distance(pixel) in X and Y axes
1130 * @note If snap points are defined in the rulers, it will always
1131 * scroll to the next snap point towards the scroll direction while
1132 * receiving the wheel events.
1135 void SetWheelScrollDistanceStep(Vector2 step);
1138 * @brief Retrieves current scroll position.
1141 * @return The current scroll position
1143 Vector2 GetCurrentScrollPosition() const;
1146 * @brief Retrieves current scroll page based on ScrollView
1147 * dimensions being the size of one page, and all pages laid out in
1148 * a grid fashion, increasing from left to right until the end of
1152 * @note Pages start from 0 as the first page, not 1.
1154 * @return The Current page
1156 unsigned int GetCurrentPage() const;
1159 * @brief Scrolls View to position specified (contents will scroll to this position).
1161 * Position 0,0 is the origin. Increasing X scrolls contents left, while
1162 * increasing Y scrolls contents up.
1163 * - If Rulers have been applied to the axes, then the contents will scroll until
1164 * reaching the domain boundary.
1166 * @param[in] position The position to scroll to
1167 * @note Contents will not snap to ruler snap points.
1170 void ScrollTo(const Vector2& position);
1173 * @brief Scrolls View to position specified (contents will scroll to this position).
1175 * Position 0,0 is the origin. Increasing X scrolls contents left, while
1176 * increasing Y scrolls contents up.
1177 * - If Rulers have been applied to the axes, then the contents will scroll until
1178 * reaching the domain boundary.
1180 * @param[in] position The position to scroll to
1181 * @param[in] duration The duration of the animation in seconds
1182 * @note Contents will not snap to ruler snap points.
1185 void ScrollTo(const Vector2& position, float duration);
1188 * @brief Scrolls View to position specified (contents will scroll to this position).
1190 * Position 0,0 is the origin. Increasing X scrolls contents left, while
1191 * increasing Y scrolls contents up.
1192 * - If Rulers have been applied to the axes, then the contents will scroll until
1193 * reaching the domain boundary.
1195 * @param[in] position The position to scroll to
1196 * @param[in] duration The duration of the animation in seconds
1197 * @param[in] alpha The alpha function to use
1198 * @note Contents will not snap to ruler snap points.
1201 void ScrollTo(const Vector2& position, float duration, AlphaFunction alpha);
1204 * @brief Scrolls View to position specified (contents will scroll to this position).
1206 * Position 0,0 is the origin. Increasing X scrolls contents left, while
1207 * increasing Y scrolls contents up.
1208 * - If Rulers have been applied to the axes, then the contents will scroll until
1209 * reaching the domain boundary.
1211 * @param[in] position The position to scroll to
1212 * @param[in] duration The duration of the animation in seconds
1213 * @param[in] horizontalBias Whether to bias scrolling to left or right
1214 * @param[in] verticalBias Whether to bias scrolling to top or bottom
1215 * @note Contents will not snap to ruler snap points.
1216 * Biasing parameters are provided such that in scenarios with 2 or 2x2 pages in
1217 * wrap mode, the application developer can decide whether to scroll left or right
1218 * to get to the target page.
1221 void ScrollTo(const Vector2& position, float duration,
1222 DirectionBias horizontalBias, DirectionBias verticalBias);
1225 * @brief Scrolls View to position specified (contents will scroll to this position).
1227 * Position 0,0 is the origin. Increasing X scrolls contents left, while
1228 * increasing Y scrolls contents up.
1229 * - If Rulers have been applied to the axes, then the contents will scroll until
1230 * reaching the domain boundary.
1232 * @param[in] position The position to scroll to
1233 * @param[in] duration The duration of the animation in seconds
1234 * @param[in] horizontalBias Whether to bias scrolling to left or right
1235 * @param[in] verticalBias Whether to bias scrolling to top or bottom
1236 * @param[in] alpha Alpha function to use
1237 * @note Contents will not snap to ruler snap points.
1238 * Biasing parameters are provided such that in scenarios with 2 or 2x2 pages in
1239 * wrap mode, the application developer can decide whether to scroll left or right
1240 * to get to the target page.
1243 void ScrollTo(const Vector2& position, float duration, AlphaFunction alpha,
1244 DirectionBias horizontalBias, DirectionBias verticalBias);
1247 * @brief Scrolls View to page currently based on assumption that each page is
1248 * "(page) * ScrollViewSize.width, 0".
1251 * @param[in] page The page to scroll to
1252 * @note Should probably be upgraded so that page is an abstract class, that can be
1253 * a function of ScrollViewSize, ruler domain, ruler snap points etc. as pages may be
1254 * orchestrated in a 2D grid fashion, or variable width.
1257 void ScrollTo(unsigned int page);
1260 * @brief Scrolls View to page currently based on assumption that each page is
1261 * "(page) * ScrollViewSize.width, 0".
1264 * @param[in] page The page to scroll to
1265 * @param[in] duration The duration of the animation in seconds
1266 * @note Should probably be upgraded so that page is an abstract class, that can be
1267 * a function of ScrollViewSize, ruler domain, ruler snap points etc. as pages may be
1268 * orchestrated in a 2D grid fashion, or variable width.
1271 void ScrollTo(unsigned int page, float duration);
1274 * @brief Scrolls View to page currently based on assumption that each page is
1275 * "(page) * ScrollViewSize.width, 0".
1278 * @param[in] page The page to scroll to
1279 * @param[in] duration The duration of the animation in seconds
1280 * @param[in] bias Whether to bias scrolling to left or right
1281 * @note Should probably be upgraded so that page is an abstract class, that can be
1282 * a function of ScrollViewSize, ruler domain, ruler snap points etc. as pages may be
1283 * orchestrated in a 2D grid fashion, or variable width.
1284 * A biasing parameter is provided such that in scenarios with 2 pages in wrap mode,
1285 * the application developer can decide whether to scroll left or right to get to
1289 void ScrollTo(unsigned int page, float duration, DirectionBias bias);
1292 * @brief Scrolls View such that actor appears in the center of the ScrollView.
1295 * @param[in] actor The actor to center in on (via Scrolling)
1296 * @note Actor must be a direct child of ScrollView, otherwise will
1297 * cause an assertion failure.
1299 void ScrollTo(Actor& actor);
1302 * @brief Scrolls View such that actor appears in the center of the ScrollView.
1305 * @param[in] actor The actor to center in on (via Scrolling)
1306 * @param[in] duration The duration of the animation in seconds
1307 * @note Actor must be a direct child of ScrollView, otherwise will
1308 * cause an assertion failure.
1310 void ScrollTo(Actor& actor, float duration);
1313 * @brief Scrolls View to the nearest snap points as specified by the Rulers.
1315 * If already at snap points, then will return false, and not scroll.
1318 * @return True if Snapping necessary
1320 bool ScrollToSnapPoint();
1323 * @brief Applies a constraint that will affect the children of ScrollView.
1326 * @param[in] constraint The constraint to apply
1327 * @note This affects all existing and future Actors that are added to scrollview.
1329 void ApplyConstraintToChildren(Constraint constraint);
1332 * @brief Removes all constraints that will affect the children of ScrollView.
1335 * @note This removes all constraints from actors that have been added
1338 void RemoveConstraintsFromChildren();
1341 * @brief Applies Effect to ScrollView.
1344 * @param[in] effect The effect to apply to scroll view
1346 void ApplyEffect(ScrollViewEffect effect);
1349 * @brief Removes Effect from ScrollView.
1352 * @param[in] effect The effect to remove
1354 void RemoveEffect(ScrollViewEffect effect);
1357 * @brief Remove All Effects from ScrollView.
1360 void RemoveAllEffects();
1363 * @brief Binds actor to this ScrollView.
1365 * Once an actor is bound to a ScrollView, it will be subject to
1366 * that ScrollView's properties.
1369 * @param[in] child The actor to add to this ScrollView
1371 void BindActor(Actor child);
1374 * @brief Unbinds Actor from this ScrollView.
1376 * Once Unbound, this ScrollView will not affect the actor.
1378 * @param[in] child The actor to be unbound
1379 * @note This does not remove the child from the ScrollView container
1382 void UnbindActor(Actor child);
1385 * @brief Allows the user to constrain the scroll view in a particular direction.
1388 * @param[in] direction The axis to constrain the scroll-view to.
1389 * Usually set to PanGestureDetector::DIRECTION_VERTICAL or PanGestureDetector::DIRECTION_HORIZONTAL (but can be any other angle if desired).
1390 * @param[in] threshold The threshold to apply around the axis
1391 * @note If no threshold is specified, then the default threshold of PI * 0.25 radians (or 45 degrees) is used.
1393 void SetScrollingDirection( Radian direction, Radian threshold = PanGestureDetector::DEFAULT_THRESHOLD );
1396 * @brief Removes a direction constraint from the scroll view.
1399 * @param[in] direction The axis to stop constraining to.
1400 * Usually will be PanGestureDetector::DIRECTION_VERTICAL or PanGestureDetector::DIRECTION_HORIZONTAL (but can be any other angle if desired).
1402 void RemoveScrollingDirection( Radian direction );
1407 * @brief Signal emitted when the ScrollView has started to snap or flick (it tells the target
1408 * position, scale, rotation for the snap or flick).
1410 * A callback of the following type may be connected:
1412 * void YourCallbackName(const SnapEvent& event);
1415 * @return The signal to connect to
1416 * @pre The Object has been initialized.
1418 SnapStartedSignalType& SnapStartedSignal();
1420 public: // Not intended for application developers
1424 * @brief Creates a handle using the Toolkit::Internal implementation.
1427 * @param[in] implementation The Control implementation
1429 DALI_INTERNAL ScrollView(Internal::ScrollView& implementation);
1432 * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
1435 * @param[in] internal A pointer to the internal CustomActor
1437 explicit DALI_INTERNAL ScrollView( Dali::Internal::CustomActor* internal );
1444 } // namespace Toolkit
1448 #endif // DALI_TOOLKIT_SCROLL_VIEW_H