1 #ifndef __DALI_TOOLKIT_SCROLL_VIEW_H__
2 #define __DALI_TOOLKIT_SCROLL_VIEW_H__
5 * Copyright (c) 2014 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-functions.h>
25 #include <dali-toolkit/public-api/controls/scrollable/scrollable.h>
33 namespace Internal DALI_INTERNAL
39 * @brief The snap type
48 * @brief DirectionBias types.
52 DirectionBiasLeft = -1, ///< Bias scroll snap to Left
53 DirectionBiasNone = 0, ///< Don't bias scroll snap
54 DirectionBiasRight = 1 ///< Bias scroll snap to Right
58 * @brief Used for specifying minimum/maximum extents of a ruler.
60 class DALI_IMPORT_API RulerDomain
65 * @brief Creates Ruler domain allowing a point to traverse between min and max extents.
67 * @param[in] min Minimum extent (point cannot traverse less than this)
68 * @param[in] max Maximum extent (point cannot traverse greater than this)
69 * @param[in] enabled Whether domain has been enabled or not.
71 explicit RulerDomain(float min, float max, bool enabled = true);
75 float min; ///< Minimum extent (point cannot traverse less than this)
76 float max; ///< Maximum extent (point cannot traverse greater than this)
77 bool enabled; ///< Whether domain has been enabled or not.
80 * @brief Clamps value (x) from (min) to (max).
82 * An optional length parameter can be specified to suggest that the
83 * subject is not a point but a line to that should be clamped.
85 * @param[in] x X point to be clamped between (min) and (max) extents.
86 * @param[in] length (optional) The Length of the line from (x) to (x + length) to be clamped.
87 * @param[in] scale Scaling parameter which treats domain as scaled in calculations.
88 * @return The clamped value.
90 float Clamp(float x, float length = 0.0f, float scale = 1.0f) const;
93 * @brief Clamps value (x) from (min) to (max).
95 * An optional length parameter can be specified to suggest that the
96 * subject is not a point but a line to that should be clamped.
98 * @param[in] x X point to be clamped between (min) and (max) extents.
99 * @param[in] length (optional) The Length of the line from (x) to (x + length) to be clamped.
100 * @param[in] scale Scaling parameter which treats domain as scaled in calculations.
101 * @param[out] clamped Whether clamping occured and which size (None, Min or Max)
102 * @return The clamped value.
104 float Clamp(float x, float length, float scale, ClampState &clamped) const;
107 * @brief Returns (max-min) size of ruler.
109 * @return The size of the ruler from min to max.
111 float GetSize() const;
116 * @brief Abstract class to define scroll axes.
118 * It can specify whether they are traversable, where their snap
119 * points are and their domain.
121 class DALI_IMPORT_API Ruler : public RefObject
124 /// @brief The type of the ruler
126 Fixed, ///< A fixed ruler
127 Free ///< A free ruler
133 * @brief Constructs ruler, default enabled, with limitless domain.
138 * @brief Snaps (x) in accordance to the ruler settings.
140 * @param[in] x The input value on the ruler to be snapped.
141 * @param[in] bias (optional) The biasing employed for snapping
142 * 0 floor input (floor x) "Used for Flick Left"
143 * 0.5 round input (floor x + 0.5) "Used for Release"
144 * 1 ceil input (floor x + 1.0) "Used for Flick Right"
145 * @return The position of the one dimensional point passed in once snapped.
147 virtual float Snap(float x, float bias = 0.5f) const = 0;
150 * @brief Returns position from page, based on whatever the ruler
153 * If (wrap) is true, then will set volume to the number of
154 * times page has exceeded the domain's volume (volume being the
155 * number of pages within the domain), while wrapping the position
158 * @param[in] page The page index
159 * @param[out] volume The overflow volume when the page exceeds the domain (wrap must be enabled)
160 * @param[in] wrap Enable wrap mode
161 * @return The position representing this page point.
163 virtual float GetPositionFromPage(unsigned int page, unsigned int &volume, bool wrap) const = 0;
166 * @brief Returns page from position, based on whatever the ruler
169 * If (wrap) is true, then will return a page wrapped within the domain.
171 * @param[in] position The position on the domain
172 * @param[in] wrap Enable wrap mode
173 * @return The page where this position resides.
175 virtual unsigned int GetPageFromPosition(float position, bool wrap) const = 0;
178 * @brief Returns the total number of pages within this Ruler.
180 * @return The number of pages in the Ruler.
182 virtual unsigned int GetTotalPages() const = 0;
187 * @brief Gets the ruler type.
189 * @return The ruler type.
191 Ruler::RulerType GetType() const;
194 * @brief Returns whether this axis has been enabled or not.
196 * @return true if axis is enabled
198 bool IsEnabled() const;
201 * @brief Enables ruler (ruler must be enabled in order to traverse along it).
206 * @brief Disables ruler.
211 * @brief Sets Domain.
213 * @param[in] domain Ruler domain object.
215 void SetDomain(RulerDomain domain);
218 * @brief Gets Domain.
222 const RulerDomain &GetDomain() const;
225 * @brief Disables Domain (minimum/maximum extents for this axis).
227 void DisableDomain();
230 * @brief Clamps value (x) from (min) to (max).
232 * An optional length parameter can be specified to suggest that the
233 * subject is not a point but a line that should be clamped.
235 * @param[in] x X point to be clamped between (min) and (max) extents.
236 * @param[in] length (optional) The Length of the line from (x) to (x + length) to be clamped.
237 * @param[in] scale Scaling parameter which treats domain as scaled in calculations.
238 * @return The clamped value.
240 float Clamp(float x, float length = 0.0f, float scale = 1.0f) const;
244 * @brief Clamps value (x) from (min) to (max).
246 * An optional length parameter can be specified to suggest that the
247 * subject is not a point but a line to that should be clamped.
249 * @param[in] x X point to be clamped between (min) and (max) extents.
250 * @param[in] length (optional) The Length of the line from (x) to (x + length) to be clamped.
251 * @param[in] scale Scaling parameter which treats domain as scaled in calculations.
252 * @param[out] clamped Whether clamping occured and which size (None, Min or Max)
253 * @return The clamped value.
255 float Clamp(float x, float length, float scale, ClampState &clamped) const;
258 * @brief Snaps and Clamps (x) in accordance to ruler settings.
260 * @param[in] x value to be snapped in accordance to ruler snap value,
261 * and clamped in accordance to the ruler's domain (if set).
262 * @param[in] bias (optional) The biasing employed for snapping
263 * 0 floor input (floor x) "Used for Flick Left"
264 * 0.5 round input (floor x + 0.5) "Used for Release"
265 * 1 ceil input (floor x + 1.0) "Used for Flick Right"
266 * @param[in] length (optional) The Length of the line from (x) to (x + length)
268 * @param[in] scale Scaling parameter which treats domain as scaled in calculations.
269 * @return the clamped value after snapping
271 float SnapAndClamp(float x, float bias = 0.5f, float length = 0.0f, float scale = 1.0f) const;
274 * @brief Snaps and Clamps (x) in accordance to ruler settings.
276 * @param[in] x value to be snapped in accordance to ruler snap value,
277 * and clamped in accordance to the ruler's domain (if set).
278 * @param[in] bias (optional) The biasing employed for snapping
279 * 0 floor input (floor x) "Used for Flick Left"
280 * 0.5 round input (floor x + 0.5) "Used for Release"
281 * 1 ceil input (floor x + 1.0) "Used for Flick Right"
282 * @param[in] length (optional) The Length of the line from (x) to (x + length)
284 * @param[in] scale Scaling parameter which treats domain as scaled in calculations.
285 * @param[out] clamped Whether clamping occured and which size (None, Min or Max)
286 * @return The clamped value after snapping
288 float SnapAndClamp(float x, float bias, float length, float scale, ClampState &clamped) const;
293 * @brief Destructor - A reference counted object may only be deleted by calling Unreference().
299 RulerType mType; ///< Type of Ruler (Fixed or Free).
300 bool mEnabled; ///< If the ruler is enabled.
301 RulerDomain mDomain; ///< The domain of the ruler.
305 typedef IntrusivePtr<Ruler> RulerPtr; ///< Pointer to Dali::Toolkit::Ruler object
308 * @brief Concrete implementation of Ruler that has no snapping and has one single page.
310 class DALI_IMPORT_API DefaultRuler : public Ruler
314 * @brief DefaultRuler constructor.
319 * @copydoc Toolkit::Ruler::Snap
321 virtual float Snap(float x, float bias) const;
324 * @copydoc Toolkit::Ruler::GetPositionFromPage
326 virtual float GetPositionFromPage(unsigned int page, unsigned int &volume, bool wrap) const;
329 * @copydoc Toolkit::Ruler::GetPageFromPosition
331 virtual unsigned int GetPageFromPosition(float position, bool wrap) const;
334 * @copydoc Toolkit::Ruler::GetTotalPages
336 virtual unsigned int GetTotalPages() const;
340 * @brief Concrete implementation of Ruler that has fixed snapping.
342 class DALI_IMPORT_API FixedRuler : public Ruler
348 * @param[in] spacing The spacing between each interval on this ruler.
350 FixedRuler(float spacing = 1.0f);
353 * @copydoc Toolkit::Ruler::Snap
355 virtual float Snap(float x, float bias) const;
358 * @copydoc Toolkit::Ruler::GetPositionFromPage
360 virtual float GetPositionFromPage(unsigned int page, unsigned int &volume, bool wrap) const;
363 * @copydoc Toolkit::Ruler::GetPageFromPosition
365 virtual unsigned int GetPageFromPosition(float position, bool wrap) const;
368 * @copydoc Toolkit::Ruler::GetTotalPages
370 virtual unsigned int GetTotalPages() const;
373 float mSpacing; ///< The spacing between each interval
376 class ScrollViewEffect;
380 * @brief ScrollView contains actors that can be scrolled manually (via touch)
384 * | %Signal Name | Method |
385 * |-------------------|----------------------------|
386 * | snap-started | @ref SnapStartedSignal() |
388 class DALI_IMPORT_API ScrollView : public Scrollable
394 static const std::string SCROLL_PAGE_CURRENT; ///< Property, name "scroll-page-current", type INT
395 static const std::string SCROLL_TIME_PROPERTY_NAME; ///< Property, name "scroll-time", type FLOAT
396 static const std::string SCROLL_POSITION_PROPERTY_NAME; ///< Property, name "scroll-position", type VECTOR3
397 static const std::string SCROLL_PRE_POSITION_PROPERTY_NAME; ///< Property, name "scroll-pre-position", type VECTOR3
398 static const std::string SCROLL_OVERSHOOT_X_PROPERTY_NAME; ///< Property, name "scroll-overshoot-x", type float
399 static const std::string SCROLL_OVERSHOOT_Y_PROPERTY_NAME; ///< Property, name "scroll-overshoot-y", type float
400 static const std::string SCROLL_FINAL_PROPERTY_NAME; ///< Property, name "scroll-final", type VECTOR3
401 static const std::string SCROLL_SCALE_PROPERTY_NAME; ///< Property, name "scroll-scale", type VECTOR3
402 static const std::string SCROLL_WRAP_PROPERTY_NAME; ///< Property, name "scroll-wrap", type BOOLEAN
403 static const std::string SCROLL_PANNING_PROPERTY_NAME; ///< Property, name "scroll-panning", type BOOLEAN
404 static const std::string SCROLL_SCROLLING_PROPERTY_NAME; ///< Property, name "scroll-scrolling", type BOOLEAN
405 static const std::string SCROLL_POSITION_DELTA_PROPERTY_NAME; ///< Property, name "scroll-position-delta" type VECTOR3
406 static const std::string SCROLL_START_PAGE_POSITION_PROPERTY_NAME; ///< Property, name "scroll-start-page-position" type VECTOR3
410 static const float DEFAULT_SLOW_SNAP_ANIMATION_DURATION; ///< Default Drag-Release animation time.
411 static const float DEFAULT_FAST_SNAP_ANIMATION_DURATION; ///< Default Drag-Flick animation time.
412 static const float DEFAULT_SNAP_OVERSHOOT_DURATION; ///< Default Overshoot snapping animation time.
413 static const float DEFAULT_MAX_OVERSHOOT; ///< Default maximum allowed overshoot
415 static const float DEFAULT_AXIS_AUTO_LOCK_GRADIENT; ///< Default Axis-AutoLock gradient threshold. default is 0.36:1 (20 degrees)
416 static const float DEFAULT_FRICTION_COEFFICIENT; ///< Default Friction Co-efficient. (in stage diagonals per second)
417 static const float DEFAULT_FLICK_SPEED_COEFFICIENT; ///< Default Flick speed coefficient (multiples input touch velocity)
418 static const float DEFAULT_MAX_FLICK_SPEED; ///< Default Maximum flick speed. (in stage diagonals per second)
420 /// Direction of transitions
423 DirectionFlagLeft = 0x01,
424 DirectionFlagRight = 0x02,
425 DirectionFlagUp = 0x04,
426 DirectionFlagDown = 0x08,
427 DirectionFlagTransitionOn = 0x10, ///< doesnt mean a page is moving towards centre, it affects whether the current page is using values for moving onto screen or off screen, if the user changes scroll direction we dont want things to flip over when in view
428 DirectionFlagTransitionOff = 0x20,
429 DirectionFlagMask_Direction = DirectionFlagLeft | DirectionFlagRight | DirectionFlagUp | DirectionFlagDown,
430 DirectionFlagMask_Transition = DirectionFlagTransitionOn | DirectionFlagTransitionOff
436 * @brief Snap signal event's data.
440 SnapType type; ///< Current snap commencing
441 Vector3 position; ///< Target snap position
442 float duration; ///< Duration of snap animation.
445 typedef Signal< void ( const SnapEvent& ) > SnapStartedSignalType; ///< SnapStarted signal type
448 * @brief Signal emitted when the ScrollView has started to snap or flick (it tells the target
449 * position, scale, rotation for the snap or flick)
451 SnapStartedSignalType& SnapStartedSignal();
456 * @brief Creates an empty ScrollView handle.
461 * @brief Copy constructor.
463 * Creates another handle that points to the same real object
465 * @param[in] handle to copy from
467 ScrollView( const ScrollView& handle );
470 * @brief Assignment operator.
472 * Changes this handle to point to another real object
473 * @param[in] handle The handle to copy from
474 * @return A reference to this
476 ScrollView& operator=( const ScrollView& handle );
481 * This is non-virtual since derived Handle types must not contain data or virtual methods.
486 * @brief Create an initialized ScrollView.
488 * @return A handle to a newly allocated Dali resource.
490 static ScrollView New();
493 * @brief Downcast an Object handle to ScrollView.
495 * If handle points to a ScrollView the downcast produces valid
496 * handle. If not the returned handle is left uninitialized.
498 * @param[in] handle Handle to an object
499 * @return handle to a ScrollView or an uninitialized handle
501 static ScrollView DownCast( BaseHandle handle );
506 * @brief Get snap-animation's AlphaFunction.
508 * @return Current easing alpha function of the snap animation.
510 AlphaFunction GetScrollSnapAlphaFunction() const;
513 * @brief Set snap-animation's AlphaFunction.
515 * @param[in] alpha Easing alpha function of the snap animation.
517 void SetScrollSnapAlphaFunction(AlphaFunction alpha);
520 * @brief Get flick-animation's AlphaFunction.
522 * @return Current easing alpha function of the flick animation.
524 AlphaFunction GetScrollFlickAlphaFunction() const;
527 * @brief Set flick-animation's AlphaFunction.
529 * @param[in] alpha Easing alpha function of the flick animation.
531 void SetScrollFlickAlphaFunction(AlphaFunction alpha);
534 * @brief Gets the time for the scroll snap-animation.
536 * This animation occurs when the user drags, and releases.
538 * @return The time in seconds for the animation to take.
540 float GetScrollSnapDuration() const;
543 * @brief Sets the time for the scroll snap-animation.
545 * This animation occurs when the user drags, and releases.
547 * @param[in] time The time in seconds for the animation to take.
549 void SetScrollSnapDuration(float time);
552 * @brief Gets the time for the scroll flick-animation.
554 * This animation occurs when the user flicks scroll view.
556 * @return The time in seconds for the animation to take.
558 float GetScrollFlickDuration() const;
561 * @brief Sets the time for the scroll flick-animation.
563 * This animation occurs when the user flicks scroll view.
565 * @param[in] time The time in seconds for the animation to take.
567 void SetScrollFlickDuration(float time);
570 * @brief Set X axis ruler.
572 * Defines how scrolling horizontally is snapped, and
573 * the boundary (domain) in which the ScrollView can pan.
575 * @param[in] ruler The ruler to be used for the X axis
577 void SetRulerX(RulerPtr ruler);
580 * @brief Set Y axis ruler.
582 * Defines how scrolling vertically is snapped, and the boundary
583 * (domain) in which the ScrollView can pan.
585 * @param[in] ruler The ruler to be used for the Y axis
587 void SetRulerY(RulerPtr ruler);
590 * @brief Set Scroll's touch sensitivity.
592 * @note Unlike SetSensitive(), this determines whether this ScrollView
593 * should react (e.g. pan), without disrupting the sensitivity of it's children.
595 * @param[in] sensitive true to enable scroll, false to disable scrolling
597 void SetScrollSensitive(bool sensitive);
600 * @brief Set maximum overshoot amount.
602 * The final overshoot value is within 0.0f to 1.0f, but the maximum
603 * overshoot is in pixels (e.g. if you scroll 75 pixels beyond the
604 * edge of a scrollable area and the maximum overshoot is 100 then
605 * the final overshoot value will be 0.75f)
607 * @param[in] overshootX the maximum number of horizontally scrolled pixels before overshoot X reaches 1.0f
608 * @param[in] overshootY the maximum number of vertically scrolled pixels before overshoot Y reaches 1.0f
610 void SetMaxOvershoot(float overshootX, float overshootY);
613 * @brief Set Snap Overshoot animation's AlphaFunction.
615 * @param[in] alpha Easing alpha function of the overshoot snap animation.
617 void SetSnapOvershootAlphaFunction(AlphaFunction alpha);
620 * @brief Set Snap Overshoot animation's Duration.
622 * @note Set duration to 0 seconds, to disable Animation.
624 * @param[in] duration The duration of the overshoot snap animation.
626 void SetSnapOvershootDuration(float duration);
629 * @brief Sets Touches required for pan gestures.
631 * Panning requires number of touches to be within (minTouches) and
634 * If (endOutside) is true, then outside this range of touches,
635 * the pan gesture will end and thus will snap.
637 * If (endOutside) is false, then outside this range of touches,
638 * the pan gesture will pause. but will not end until touches = 0.
640 * @param[in] minTouches Minimum touches for panning to occur.
641 * @param[out] maxTouches Maxiumum touches for panning to occur.
642 * @param[in] endOutside Whether to end the panning gesture outside of touch range
644 void SetTouchesRequiredForPanning(unsigned int minTouches = 1, unsigned int maxTouches = 1, bool endOutside = true);
647 * @brief Enables or Disables Actor Auto-Snap mode.
649 * When Actor Auto-Snap mode has been enabled, ScrollView will automatically
650 * snap to the closest actor (The closest actor will appear in the center of
653 * @param[in] enable Enables (true), or disables (false) Actor AutoSnap
655 void SetActorAutoSnap(bool enable);
658 * @brief Enables or Disables Wrap mode for ScrollView contents.
660 * When enabled, the ScrollView contents are wrapped over the X/Y Domain.
662 * @note You must apply a position constraint that causes Wrapping
665 * @param[in] enable Enables (true), or disables (false) Wrap Mode.
667 void SetWrapMode(bool enable);
670 * @brief Gets the current distance needed to scroll for ScrollUpdatedSignal to be emitted
672 * @return Current scroll update distance
674 int GetScrollUpdateDistance() const;
677 * @brief Sets the distance needed to scroll for ScrollUpdatedSignal to be emitted
679 * The scroll update distance tells ScrollView how far to move before ScrollUpdatedSignal the informs application.
680 * Each time the ScrollView crosses this distance the signal will be emitted
682 * @param[in] distance The distance for ScrollView to move before emitting update signal
684 void SetScrollUpdateDistance(int distance);
687 * @brief Returns state of Axis Auto Lock mode.
689 * @return Whether Axis Auto Lock mode has been enabled or not.
691 bool GetAxisAutoLock() const;
694 * @brief Enables or Disables Axis Auto Lock mode for panning within the ScrollView.
696 * When enabled, any pan gesture that appears mostly horizontal or mostly
697 * vertical, will be automatically restricted to horizontal only or vertical
698 * only panning, until the pan gesture has completed.
700 * @param[in] enable Enables (true), or disables (false) AxisAutoLock mode.
702 void SetAxisAutoLock(bool enable);
705 * @brief Gets the gradient threshold at which a panning gesture
706 * should be locked to the Horizontal or Vertical axis.
708 * @return The gradient, a value between 0.0 and 1.0f.
710 float GetAxisAutoLockGradient() const;
713 * @brief Sets the gradient threshold at which a panning gesture should be locked to the
714 * Horizontal or Vertical axis.
716 * By default this is 0.36 (0.36:1) which means angles less than 20
717 * degrees to an axis will lock to that axis.
719 * @note: Specifying a value of 1.0 (the maximum value accepted) indicates that
720 * all panning gestures will auto-lock. Either to the horizontal or vertical axis.
722 * @param[in] gradient A value between 0.0 and 1.0 (auto-lock for all angles)
724 void SetAxisAutoLockGradient(float gradient);
727 * @brief Gets the friction coefficient setting for ScrollView when
728 * flicking in free panning mode.
730 * This is a value in stage-diagonals per second^2.
731 * stage-diagonal = Length( stage.width, stage.height )
732 * @return Friction coefficient is returned.
734 float GetFrictionCoefficient() const;
737 * @brief Sets the friction coefficient for ScrollView when flicking
738 * in free panning mode.
740 * This is a value in stage-diagonals per second^2.
741 * stage-diagonal = Length( stage.width, stage.height ).
743 * A stage 480x800 in size has a diagonal length of 933.
744 * Friction coefficient of 1.0 means the swipe velocity will
745 * reduce by 1.0 * 933 pixels/sec^2.
746 * @param[in] friction Friction coefficient, must be greater than 0.0 (default = 1.0)
748 void SetFrictionCoefficient(float friction);
751 * @brief Gets the flick speed coefficient for ScrollView when
752 * flicking in free panning mode.
754 * This is a constant which multiplies the input touch
755 * flick velocity to determine the actual velocity at
756 * which to move the scrolling area.
757 * @return The flick speed coefficient is returned.
759 float GetFlickSpeedCoefficient() const;
762 * @brief Sets the flick speed coefficient for ScrollView when
763 * flicking in free panning mode.
765 * This is a constant which multiplies the input touch
766 * flick velocity to determine the actual velocity at
767 * which to move the scrolling area.
768 * @param[in] speed The flick speed coefficient (default = 1.0).
770 void SetFlickSpeedCoefficient(float speed);
773 * @brief Returns the minimum pan distance required for a flick gesture in pixels
775 * @return Minimum pan distance vector with separate x and y distance
777 Vector2 GetMinimumDistanceForFlick() const;
780 * @brief Sets the minimum pan distance required for a flick in pixels
782 * 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
784 * @param[in] distance The minimum pan distance for a flick
786 void SetMinimumDistanceForFlick( const Vector2& distance );
789 * @brief Returns the minimum pan speed required for a flick gesture in pixels per second
791 * @return Minimum pan speed
793 float GetMinimumSpeedForFlick() const;
796 * @brief Sets the minimum pan speed required for a flick in pixels per second
798 * @param[in] speed The minimum pan speed for a flick
800 void SetMinimumSpeedForFlick( float speed );
803 * @brief Gets the maximum flick speed setting for ScrollView when
804 * flicking in free panning mode.
806 * This is a value in stage-diagonals per second.
807 * stage-diagonal = Length( stage.width, stage.height )
808 * @return Maximum flick speed is returned
810 float GetMaxFlickSpeed() const;
813 * @brief Sets the maximum flick speed for the ScrollView when
814 * flicking in free panning mode.
816 * This is a value in stage-diagonals per second.
817 * stage-diagonal = Length( stage.width, stage.height )
819 * A stage 480x800 in size has a diagonal length of 933.
820 * Max Flick speed of 1.0 means the maximum velocity of
821 * a swipe can be 1.0 * 933 pixels/sec.
822 * @param[in] speed Maximum flick speed (default = 3.0)
824 void SetMaxFlickSpeed(float speed);
827 * @brief Gets the step of scroll distance in actor coordinates for
828 * each mouse wheel event received in free panning mode.
830 * @return The step of scroll distance(pixel) in X and Y axes.
832 Vector2 GetMouseWheelScrollDistanceStep() const;
835 * @brief Sets the step of scroll distance in actor coordinates for
836 * each mouse wheel event received in free panning mode.
838 * @param[in] step The step of scroll distance(pixel) in X and Y axes.
840 * @note: If snap points are defined in the rulers, it will always
841 * scroll to the next snap point towards the scroll direction while
842 * receiving the mouse wheel events.
845 void SetMouseWheelScrollDistanceStep(Vector2 step);
848 * @brief Retrieves current scroll position.
850 * @returns The current scroll position.
852 Vector3 GetCurrentScrollPosition() const;
855 * @brief Sets the current scroll position, overriding current scroll animations. If panning is currently taking place
856 * SetScrollPosition will have no effect. Try to ensure panning has stopped before calling this function.
858 * @param[in] position The new scroll position to set.
860 void SetScrollPosition(const Vector3& position);
863 * @brief Retrieves current scroll page based on ScrollView
864 * dimensions being the size of one page, and all pages laid out in
865 * a grid fashion, increasing from left to right until the end of
868 * @note: Pages start from 0 as the first page, not 1.
870 * @returns The Current page.
872 unsigned int GetCurrentPage() const;
875 * @brief Scrolls View to position specified (contents will scroll to this position).
877 * Position 0,0 is the origin. Increasing X scrolls contents left, while
878 * increasing Y scrolls contents up.
879 * - If Rulers have been applied to the axes, then the contents will scroll until
880 * reaching the domain boundary.
881 * @note Contents will not snap to ruler snap points.
883 * @param[in] position The position to scroll to.
885 void ScrollTo(const Vector3 &position);
888 * @brief Scrolls View to position specified (contents will scroll to this position).
890 * Position 0,0 is the origin. Increasing X scrolls contents left, while
891 * increasing Y scrolls contents up.
892 * - If Rulers have been applied to the axes, then the contents will scroll until
893 * reaching the domain boundary.
894 * @note Contents will not snap to ruler snap points.
896 * @param[in] position The position to scroll to.
897 * @param[in] duration The duration of the animation in seconds
899 void ScrollTo(const Vector3 &position, float duration);
902 * @brief Scrolls View to position specified (contents will scroll to this position)
904 * Position 0,0 is the origin. Increasing X scrolls contents left, while
905 * increasing Y scrolls contents up.
906 * - If Rulers have been applied to the axes, then the contents will scroll until
907 * reaching the domain boundary.
908 * @note Contents will not snap to ruler snap points.
910 * @param[in] position The position to scroll to.
911 * @param[in] duration The duration of the animation in seconds
912 * @param[in] alpha The alpha function to use
914 void ScrollTo(const Vector3 &position, float duration, AlphaFunction alpha);
917 * @brief Scrolls View to position specified (contents will scroll to this position).
919 * Position 0,0 is the origin. Increasing X scrolls contents left, while
920 * increasing Y scrolls contents up.
921 * - If Rulers have been applied to the axes, then the contents will scroll until
922 * reaching the domain boundary.
923 * @note Contents will not snap to ruler snap points.
924 * Biasing parameters are provided such that in scenarios with 2 or 2x2 pages in
925 * wrap mode, the application developer can decide whether to scroll left or right
926 * to get to the target page
928 * @param[in] position The position to scroll to.
929 * @param[in] duration The duration of the animation in seconds
930 * @param[in] horizontalBias Whether to bias scrolling to left or right.
931 * @param[in] verticalBias Whether to bias scrolling to top or bottom.
933 void ScrollTo(const Vector3 &position, float duration,
934 DirectionBias horizontalBias, DirectionBias verticalBias);
937 * @brief Scrolls View to position specified (contents will scroll to this position)
939 * Position 0,0 is the origin. Increasing X scrolls contents left, while
940 * increasing Y scrolls contents up.
941 * - If Rulers have been applied to the axes, then the contents will scroll until
942 * reaching the domain boundary.
943 * @note Contents will not snap to ruler snap points.
944 * Biasing parameters are provided such that in scenarios with 2 or 2x2 pages in
945 * wrap mode, the application developer can decide whether to scroll left or right
946 * to get to the target page
948 * @param[in] position The position to scroll to.
949 * @param[in] duration The duration of the animation in seconds
950 * @param[in] horizontalBias Whether to bias scrolling to left or right.
951 * @param[in] verticalBias Whether to bias scrolling to top or bottom.
952 * @param[in] alpha Alpha function to use
954 void ScrollTo(const Vector3 &position, float duration, AlphaFunction alpha,
955 DirectionBias horizontalBias, DirectionBias verticalBias);
958 * @brief Scrolls View to page currently based on assumption that each page is
959 * "(page) * ScrollViewSize.width, 0".
961 * @note Should probably be upgraded so that page is an abstract class, that can be
962 * a function of ScrollViewSize, ruler domain, ruler snap points etc. as pages may be
963 * orchestrated in a 2D grid fashion, or variable width.
965 * @param[in] page to scroll to
967 void ScrollTo(unsigned int page);
970 * @brief Scrolls View to page currently based on assumption that each page is
971 * "(page) * ScrollViewSize.width, 0".
973 * @note Should probably be upgraded so that page is an abstract class, that can be
974 * a function of ScrollViewSize, ruler domain, ruler snap points etc. as pages may be
975 * orchestrated in a 2D grid fashion, or variable width.
977 * @param[in] page to scroll to
978 * @param[in] duration The duration of the animation in seconds
980 void ScrollTo(unsigned int page, float duration);
983 * @brief Scrolls View to page currently based on assumption that each page is
984 * "(page) * ScrollViewSize.width, 0".
986 * @note Should probably be upgraded so that page is an abstract class, that can be
987 * a function of ScrollViewSize, ruler domain, ruler snap points etc. as pages may be
988 * orchestrated in a 2D grid fashion, or variable width.
989 * A biasing parameter is provided such that in scenarios with 2 pages in wrap mode,
990 * the application developer can decide whether to scroll left or right to get to
993 * @param[in] page to scroll to
994 * @param[in] duration The duration of the animation in seconds
995 * @param[in] bias Whether to bias scrolling to left or right.
997 void ScrollTo(unsigned int page, float duration, DirectionBias bias);
1000 * @brief Scrolls View such that actor appears in the center of the ScrollView.
1002 * @note Actor must be a direct child of ScrollView, otherwise will
1003 * cause an assertion failure.
1004 * @param[in] actor The actor to center in on (via Scrolling).
1006 void ScrollTo(Actor& actor);
1009 * @brief Scrolls View such that actor appears in the center of the ScrollView.
1011 * @note Actor must be a direct child of ScrollView, otherwise will
1012 * cause an assertion failure.
1013 * @param[in] actor The actor to center in on (via Scrolling).
1014 * @param[in] duration The duration of the animation in seconds
1016 void ScrollTo(Actor& actor, float duration);
1019 * @brief Scrolls View to the nearest snap points as specified by the Rulers.
1021 * If already at snap points, then will return false, and not scroll.
1023 * @return True if Snapping necessary.
1025 bool ScrollToSnapPoint();
1028 * @brief Applies a constraint that will affect the children of ScrollView.
1030 * @note this affects all existing and future Actors that are added to scrollview.
1031 * @param[in] constraint The constraint to apply
1033 void ApplyConstraintToChildren(Constraint constraint);
1036 * @brief Removes all constraints that will affect the children of ScrollView.
1038 * @note this removes all constraints from actors that have been added
1041 void RemoveConstraintsFromChildren();
1044 * @brief Apply Effect to ScrollView.
1046 * @param[in] effect The effect to apply to scroll view
1048 void ApplyEffect(ScrollViewEffect effect);
1051 * @brief Remove Effect from ScrollView.
1053 * @param[in] effect The effect to remove.
1055 void RemoveEffect(ScrollViewEffect effect);
1058 * @brief Remove All Effects from ScrollView.
1060 void RemoveAllEffects();
1063 * @brief Binds actor to this ScrollView.
1065 * Once an actor is bound to a ScrollView, it will be subject to
1066 * that ScrollView's properties.
1068 * @param[in] child The actor to add to this ScrollView.
1070 void BindActor(Actor child);
1073 * @brief Unbind Actor from this ScrollView.
1075 * Once Unbound, this ScrollView will not affect the actor.
1076 * @note this does not remove the child from the ScrollView container
1078 * @param[in] child The actor to be unbound.
1080 void UnbindActor(Actor child);
1083 * @brief Allows the user to constrain the scroll view in a particular direction.
1085 * @param[in] direction The axis to constrain the scroll-view to.
1086 * Usually set to PanGestureDetector::DIRECTION_VERTICAL or PanGestureDetector::DIRECTION_HORIZONTAL (but can be any other angle if desired).
1087 * @param[in] threshold The threshold to apply around the axis.
1088 * @note If no threshold is specified, then the default threshold of PI * 0.25 radians (or 45 degrees) is used.
1090 void SetScrollingDirection( Radian direction, Radian threshold = PanGestureDetector::DEFAULT_THRESHOLD );
1093 * @brief Remove a direction constraint from the scroll view.
1095 * @param[in] direction The axis to stop constraining to.
1096 * Usually will be PanGestureDetector::DIRECTION_VERTICAL or PanGestureDetector::DIRECTION_HORIZONTAL (but can be any other angle if desired).
1098 void RemoveScrollingDirection( Radian direction );
1100 public: // Not intended for application developers
1103 * @brief Creates a handle using the Toolkit::Internal implementation.
1105 * @param[in] implementation The Control implementation.
1107 DALI_INTERNAL ScrollView(Internal::ScrollView& implementation);
1110 * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
1112 * @param[in] internal A pointer to the internal CustomActor.
1114 explicit DALI_INTERNAL ScrollView( Dali::Internal::CustomActor* internal );
1117 } // namespace Toolkit
1121 #endif // __DALI_TOOLKIT_SCROLL_VIEW_H__