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-toolkit/public-api/controls/scrollable/scrollable.h>
30 namespace Internal DALI_INTERNAL
36 * @brief The snap type
45 * @brief DirectionBias types.
49 DirectionBiasLeft = -1, ///< Bias scroll snap to Left
50 DirectionBiasNone = 0, ///< Don't bias scroll snap
51 DirectionBiasRight = 1 ///< Bias scroll snap to Right
55 * @brief Used for specifying minimum/maximum extents of a ruler.
57 class DALI_IMPORT_API RulerDomain
62 * @brief Creates Ruler domain allowing a point to traverse between min and max extents.
64 * @param[in] min Minimum extent (point cannot traverse less than this)
65 * @param[in] max Maximum extent (point cannot traverse greater than this)
66 * @param[in] enabled Whether domain has been enabled or not.
68 explicit RulerDomain(float min, float max, bool enabled = true);
72 float min; ///< Minimum extent (point cannot traverse less than this)
73 float max; ///< Maximum extent (point cannot traverse greater than this)
74 bool enabled; ///< Whether domain has been enabled or not.
77 * @brief Clamps value (x) from (min) to (max).
79 * An optional length parameter can be specified to suggest that the
80 * subject is not a point but a line to that should be clamped.
82 * @param[in] x X point to be clamped between (min) and (max) extents.
83 * @param[in] length (optional) The Length of the line from (x) to (x + length) to be clamped.
84 * @param[in] scale Scaling parameter which treats domain as scaled in calculations.
85 * @return The clamped value.
87 float Clamp(float x, float length = 0.0f, float scale = 1.0f) const;
90 * @brief Clamps value (x) from (min) to (max).
92 * An optional length parameter can be specified to suggest that the
93 * subject is not a point but a line to that should be clamped.
95 * @param[in] x X point to be clamped between (min) and (max) extents.
96 * @param[in] length (optional) The Length of the line from (x) to (x + length) to be clamped.
97 * @param[in] scale Scaling parameter which treats domain as scaled in calculations.
98 * @param[out] clamped Whether clamping occured and which size (None, Min or Max)
99 * @return The clamped value.
101 float Clamp(float x, float length, float scale, ClampState &clamped) const;
104 * @brief Returns (max-min) size of ruler.
106 * @return The size of the ruler from min to max.
108 float GetSize() const;
113 * @brief Abstract class to define scroll axes.
115 * It can specify whether they are traversable, where their snap
116 * points are and their domain.
118 class DALI_IMPORT_API Ruler : public RefObject
121 /// @brief The type of the ruler
123 Fixed, ///< A fixed ruler
124 Free ///< A free ruler
130 * @brief Constructs ruler, default enabled, with limitless domain.
135 * @brief Snaps (x) in accordance to the ruler settings.
137 * @param[in] x The input value on the ruler to be snapped.
138 * @param[in] bias (optional) The biasing employed for snapping
139 * 0 floor input (floor x) "Used for Flick Left"
140 * 0.5 round input (floor x + 0.5) "Used for Release"
141 * 1 ceil input (floor x + 1.0) "Used for Flick Right"
142 * @return The position of the one dimensional point passed in once snapped.
144 virtual float Snap(float x, float bias = 0.5f) const = 0;
147 * @brief Returns position from page, based on whatever the ruler
150 * If (wrap) is true, then will set volume to the number of
151 * times page has exceeded the domain's volume (volume being the
152 * number of pages within the domain), while wrapping the position
155 * @param[in] page The page index
156 * @param[out] volume The overflow volume when the page exceeds the domain (wrap must be enabled)
157 * @param[in] wrap Enable wrap mode
158 * @return The position representing this page point.
160 virtual float GetPositionFromPage(unsigned int page, unsigned int &volume, bool wrap) const = 0;
163 * @brief Returns page from position, based on whatever the ruler
166 * If (wrap) is true, then will return a page wrapped within the domain.
168 * @param[in] position The position on the domain
169 * @param[in] wrap Enable wrap mode
170 * @return The page where this position resides.
172 virtual unsigned int GetPageFromPosition(float position, bool wrap) const = 0;
175 * @brief Returns the total number of pages within this Ruler.
177 * @return The number of pages in the Ruler.
179 virtual unsigned int GetTotalPages() const = 0;
184 * @brief Gets the ruler type.
186 * @return The ruler type.
188 Ruler::RulerType GetType() const;
191 * @brief Returns whether this axis has been enabled or not.
193 * @return true if axis is enabled
195 bool IsEnabled() const;
198 * @brief Enables ruler (ruler must be enabled in order to traverse along it).
203 * @brief Disables ruler.
208 * @brief Sets Domain.
210 * @param[in] domain Ruler domain object.
212 void SetDomain(RulerDomain domain);
215 * @brief Gets Domain.
219 const RulerDomain &GetDomain() const;
222 * @brief Disables Domain (minimum/maximum extents for this axis).
224 void DisableDomain();
227 * @brief Clamps value (x) from (min) to (max).
229 * An optional length parameter can be specified to suggest that the
230 * subject is not a point but a line that should be clamped.
232 * @param[in] x X point to be clamped between (min) and (max) extents.
233 * @param[in] length (optional) The Length of the line from (x) to (x + length) to be clamped.
234 * @param[in] scale Scaling parameter which treats domain as scaled in calculations.
235 * @return The clamped value.
237 float Clamp(float x, float length = 0.0f, float scale = 1.0f) const;
241 * @brief Clamps value (x) from (min) to (max).
243 * An optional length parameter can be specified to suggest that the
244 * subject is not a point but a line to that should be clamped.
246 * @param[in] x X point to be clamped between (min) and (max) extents.
247 * @param[in] length (optional) The Length of the line from (x) to (x + length) to be clamped.
248 * @param[in] scale Scaling parameter which treats domain as scaled in calculations.
249 * @param[out] clamped Whether clamping occured and which size (None, Min or Max)
250 * @return The clamped value.
252 float Clamp(float x, float length, float scale, ClampState &clamped) const;
255 * @brief Snaps and Clamps (x) in accordance to ruler settings.
257 * @param[in] x value to be snapped in accordance to ruler snap value,
258 * and clamped in accordance to the ruler's domain (if set).
259 * @param[in] bias (optional) The biasing employed for snapping
260 * 0 floor input (floor x) "Used for Flick Left"
261 * 0.5 round input (floor x + 0.5) "Used for Release"
262 * 1 ceil input (floor x + 1.0) "Used for Flick Right"
263 * @param[in] length (optional) The Length of the line from (x) to (x + length)
265 * @param[in] scale Scaling parameter which treats domain as scaled in calculations.
266 * @return the clamped value after snapping
268 float SnapAndClamp(float x, float bias = 0.5f, float length = 0.0f, float scale = 1.0f) const;
271 * @brief Snaps and Clamps (x) in accordance to ruler settings.
273 * @param[in] x value to be snapped in accordance to ruler snap value,
274 * and clamped in accordance to the ruler's domain (if set).
275 * @param[in] bias (optional) The biasing employed for snapping
276 * 0 floor input (floor x) "Used for Flick Left"
277 * 0.5 round input (floor x + 0.5) "Used for Release"
278 * 1 ceil input (floor x + 1.0) "Used for Flick Right"
279 * @param[in] length (optional) The Length of the line from (x) to (x + length)
281 * @param[in] scale Scaling parameter which treats domain as scaled in calculations.
282 * @param[out] clamped Whether clamping occured and which size (None, Min or Max)
283 * @return The clamped value after snapping
285 float SnapAndClamp(float x, float bias, float length, float scale, ClampState &clamped) const;
290 * @brief Destructor - A reference counted object may only be deleted by calling Unreference().
296 RulerType mType; ///< Type of Ruler (Fixed or Free).
297 bool mEnabled; ///< If the ruler is enabled.
298 RulerDomain mDomain; ///< The domain of the ruler.
302 typedef IntrusivePtr<Ruler> RulerPtr; ///< Pointer to Dali::Toolkit::Ruler object
305 * @brief Concrete implementation of Ruler that has no snapping and has one single page.
307 class DALI_IMPORT_API DefaultRuler : public Ruler
311 * @brief DefaultRuler constructor.
316 * @copydoc Toolkit::Ruler::Snap
318 virtual float Snap(float x, float bias) const;
321 * @copydoc Toolkit::Ruler::GetPositionFromPage
323 virtual float GetPositionFromPage(unsigned int page, unsigned int &volume, bool wrap) const;
326 * @copydoc Toolkit::Ruler::GetPageFromPosition
328 virtual unsigned int GetPageFromPosition(float position, bool wrap) const;
331 * @copydoc Toolkit::Ruler::GetTotalPages
333 virtual unsigned int GetTotalPages() const;
337 * @brief Concrete implementation of Ruler that has fixed snapping.
339 class DALI_IMPORT_API FixedRuler : public Ruler
345 * @param[in] spacing The spacing between each interval on this ruler.
347 FixedRuler(float spacing = 1.0f);
350 * @copydoc Toolkit::Ruler::Snap
352 virtual float Snap(float x, float bias) const;
355 * @copydoc Toolkit::Ruler::GetPositionFromPage
357 virtual float GetPositionFromPage(unsigned int page, unsigned int &volume, bool wrap) const;
360 * @copydoc Toolkit::Ruler::GetPageFromPosition
362 virtual unsigned int GetPageFromPosition(float position, bool wrap) const;
365 * @copydoc Toolkit::Ruler::GetTotalPages
367 virtual unsigned int GetTotalPages() const;
370 float mSpacing; ///< The spacing between each interval
373 class ScrollViewEffect;
377 * @brief ScrollView contains actors that can be scrolled manually (via touch)
380 class DALI_IMPORT_API ScrollView : public Scrollable
386 static const std::string SCROLL_PAGE_CURRENT; ///< Property, name "scroll-page-current", type INT
387 static const std::string SCROLL_TIME_PROPERTY_NAME; ///< Property, name "scroll-time", type FLOAT
388 static const std::string SCROLL_POSITION_PROPERTY_NAME; ///< Property, name "scroll-position", type VECTOR3
389 static const std::string SCROLL_PRE_POSITION_PROPERTY_NAME; ///< Property, name "scroll-pre-position", type VECTOR3
390 static const std::string SCROLL_OVERSHOOT_X_PROPERTY_NAME; ///< Property, name "scroll-overshoot-x", type float
391 static const std::string SCROLL_OVERSHOOT_Y_PROPERTY_NAME; ///< Property, name "scroll-overshoot-y", type float
392 static const std::string SCROLL_FINAL_PROPERTY_NAME; ///< Property, name "scroll-final", type VECTOR3
393 static const std::string SCROLL_SCALE_PROPERTY_NAME; ///< Property, name "scroll-scale", type VECTOR3
394 static const std::string SCROLL_WRAP_PROPERTY_NAME; ///< Property, name "scroll-wrap", type BOOLEAN
395 static const std::string SCROLL_PANNING_PROPERTY_NAME; ///< Property, name "scroll-panning", type BOOLEAN
396 static const std::string SCROLL_SCROLLING_PROPERTY_NAME; ///< Property, name "scroll-scrolling", type BOOLEAN
397 static const std::string SCROLL_POSITION_DELTA_PROPERTY_NAME; ///< Property, name "scroll-position-delta" type VECTOR3
398 static const std::string SCROLL_START_PAGE_POSITION_PROPERTY_NAME; ///< Property, name "scroll-start-page-position" type VECTOR3
402 static const float DEFAULT_SLOW_SNAP_ANIMATION_DURATION; ///< Default Drag-Release animation time.
403 static const float DEFAULT_FAST_SNAP_ANIMATION_DURATION; ///< Default Drag-Flick animation time.
404 static const float DEFAULT_SNAP_OVERSHOOT_DURATION; ///< Default Overshoot snapping animation time.
405 static const float DEFAULT_MAX_OVERSHOOT; ///< Default maximum allowed overshoot
407 static const float DEFAULT_AXIS_AUTO_LOCK_GRADIENT; ///< Default Axis-AutoLock gradient threshold. default is 0.36:1 (20 degrees)
408 static const float DEFAULT_FRICTION_COEFFICIENT; ///< Default Friction Co-efficient. (in stage diagonals per second)
409 static const float DEFAULT_FLICK_SPEED_COEFFICIENT; ///< Default Flick speed coefficient (multiples input touch velocity)
410 static const float DEFAULT_MAX_FLICK_SPEED; ///< Default Maximum flick speed. (in stage diagonals per second)
413 static const char* const SIGNAL_SNAP_STARTED; ///< Name "snap-started"
415 /// Direction of transitions
418 DirectionFlagLeft = 0x01,
419 DirectionFlagRight = 0x02,
420 DirectionFlagUp = 0x04,
421 DirectionFlagDown = 0x08,
422 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
423 DirectionFlagTransitionOff = 0x20,
424 DirectionFlagMask_Direction = DirectionFlagLeft | DirectionFlagRight | DirectionFlagUp | DirectionFlagDown,
425 DirectionFlagMask_Transition = DirectionFlagTransitionOn | DirectionFlagTransitionOff
431 * @brief Snap signal event's data.
435 SnapType type; ///< Current snap commencing
436 Vector3 position; ///< Target snap position
437 float duration; ///< Duration of snap animation.
440 typedef Signal< void ( const SnapEvent& ) > SnapStartedSignalType; ///< SnapStarted signal type
443 * @brief Signal emitted when the ScrollView has started to snap or flick (it tells the target
444 * position, scale, rotation for the snap or flick)
446 SnapStartedSignalType& SnapStartedSignal();
451 * @brief Creates an empty ScrollView handle.
456 * @brief Copy constructor.
458 * Creates another handle that points to the same real object
460 * @param[in] handle to copy from
462 ScrollView( const ScrollView& handle );
465 * @brief Assignment operator.
467 * Changes this handle to point to another real object
468 * @param[in] handle The handle to copy from
469 * @return A reference to this
471 ScrollView& operator=( const ScrollView& handle );
476 * This is non-virtual since derived Handle types must not contain data or virtual methods.
481 * @brief Create an initialized ScrollView.
483 * @return A handle to a newly allocated Dali resource.
485 static ScrollView New();
488 * @brief Downcast an Object handle to ScrollView.
490 * If handle points to a ScrollView the downcast produces valid
491 * handle. If not the returned handle is left uninitialized.
493 * @param[in] handle Handle to an object
494 * @return handle to a ScrollView or an uninitialized handle
496 static ScrollView DownCast( BaseHandle handle );
501 * @brief Get snap-animation's AlphaFunction.
503 * @return Current easing alpha function of the snap animation.
505 AlphaFunction GetScrollSnapAlphaFunction() const;
508 * @brief Set snap-animation's AlphaFunction.
510 * @param[in] alpha Easing alpha function of the snap animation.
512 void SetScrollSnapAlphaFunction(AlphaFunction alpha);
515 * @brief Get flick-animation's AlphaFunction.
517 * @return Current easing alpha function of the flick animation.
519 AlphaFunction GetScrollFlickAlphaFunction() const;
522 * @brief Set flick-animation's AlphaFunction.
524 * @param[in] alpha Easing alpha function of the flick animation.
526 void SetScrollFlickAlphaFunction(AlphaFunction alpha);
529 * @brief Gets the time for the scroll snap-animation.
531 * This animation occurs when the user drags, and releases.
533 * @return The time in seconds for the animation to take.
535 float GetScrollSnapDuration() const;
538 * @brief Sets the time for the scroll snap-animation.
540 * This animation occurs when the user drags, and releases.
542 * @param[in] time The time in seconds for the animation to take.
544 void SetScrollSnapDuration(float time);
547 * @brief Gets the time for the scroll flick-animation.
549 * This animation occurs when the user flicks scroll view.
551 * @return The time in seconds for the animation to take.
553 float GetScrollFlickDuration() const;
556 * @brief Sets the time for the scroll flick-animation.
558 * This animation occurs when the user flicks scroll view.
560 * @param[in] time The time in seconds for the animation to take.
562 void SetScrollFlickDuration(float time);
565 * @brief Set X axis ruler.
567 * Defines how scrolling horizontally is snapped, and
568 * the boundary (domain) in which the ScrollView can pan.
570 * @param[in] ruler The ruler to be used for the X axis
572 void SetRulerX(RulerPtr ruler);
575 * @brief Set Y axis ruler.
577 * Defines how scrolling vertically is snapped, and the boundary
578 * (domain) in which the ScrollView can pan.
580 * @param[in] ruler The ruler to be used for the Y axis
582 void SetRulerY(RulerPtr ruler);
585 * @brief Set Scroll's touch sensitivity.
587 * @note Unlike SetSensitive(), this determines whether this ScrollView
588 * should react (e.g. pan), without disrupting the sensitivity of it's children.
590 * @param[in] sensitive true to enable scroll, false to disable scrolling
592 void SetScrollSensitive(bool sensitive);
595 * @brief Set maximum overshoot amount.
597 * The final overshoot value is within 0.0f to 1.0f, but the maximum
598 * overshoot is in pixels (e.g. if you scroll 75 pixels beyond the
599 * edge of a scrollable area and the maximum overshoot is 100 then
600 * the final overshoot value will be 0.75f)
602 * @param[in] overshootX the maximum number of horizontally scrolled pixels before overshoot X reaches 1.0f
603 * @param[in] overshootY the maximum number of vertically scrolled pixels before overshoot Y reaches 1.0f
605 void SetMaxOvershoot(float overshootX, float overshootY);
608 * @brief Set Snap Overshoot animation's AlphaFunction.
610 * @param[in] alpha Easing alpha function of the overshoot snap animation.
612 void SetSnapOvershootAlphaFunction(AlphaFunction alpha);
615 * @brief Set Snap Overshoot animation's Duration.
617 * @note Set duration to 0 seconds, to disable Animation.
619 * @param[in] duration The duration of the overshoot snap animation.
621 void SetSnapOvershootDuration(float duration);
624 * @brief Sets Touches required for pan gestures.
626 * Panning requires number of touches to be within (minTouches) and
629 * If (endOutside) is true, then outside this range of touches,
630 * the pan gesture will end and thus will snap.
632 * If (endOutside) is false, then outside this range of touches,
633 * the pan gesture will pause. but will not end until touches = 0.
635 * @param[in] minTouches Minimum touches for panning to occur.
636 * @param[out] maxTouches Maxiumum touches for panning to occur.
637 * @param[in] endOutside Whether to end the panning gesture outside of touch range
639 void SetTouchesRequiredForPanning(unsigned int minTouches = 1, unsigned int maxTouches = 1, bool endOutside = true);
642 * @brief Enables or Disables Actor Auto-Snap mode.
644 * When Actor Auto-Snap mode has been enabled, ScrollView will automatically
645 * snap to the closest actor (The closest actor will appear in the center of
648 * @param[in] enable Enables (true), or disables (false) Actor AutoSnap
650 void SetActorAutoSnap(bool enable);
653 * @brief Enables or Disables Wrap mode for ScrollView contents.
655 * When enabled, the ScrollView contents are wrapped over the X/Y Domain.
657 * @note You must apply a position constraint that causes Wrapping
660 * @param[in] enable Enables (true), or disables (false) Wrap Mode.
662 void SetWrapMode(bool enable);
665 * @brief Gets the current distance needed to scroll for ScrollUpdatedSignal to be emitted
667 * @return Current scroll update distance
669 int GetScrollUpdateDistance() const;
672 * @brief Sets the distance needed to scroll for ScrollUpdatedSignal to be emitted
674 * The scroll update distance tells ScrollView how far to move before ScrollUpdatedSignal the informs application.
675 * Each time the ScrollView crosses this distance the signal will be emitted
677 * @param[in] distance The distance for ScrollView to move before emitting update signal
679 void SetScrollUpdateDistance(int distance);
682 * @brief Returns state of Axis Auto Lock mode.
684 * @return Whether Axis Auto Lock mode has been enabled or not.
686 bool GetAxisAutoLock() const;
689 * @brief Enables or Disables Axis Auto Lock mode for panning within the ScrollView.
691 * When enabled, any pan gesture that appears mostly horizontal or mostly
692 * vertical, will be automatically restricted to horizontal only or vertical
693 * only panning, until the pan gesture has completed.
695 * @param[in] enable Enables (true), or disables (false) AxisAutoLock mode.
697 void SetAxisAutoLock(bool enable);
700 * @brief Gets the gradient threshold at which a panning gesture
701 * should be locked to the Horizontal or Vertical axis.
703 * @return The gradient, a value between 0.0 and 1.0f.
705 float GetAxisAutoLockGradient() const;
708 * @brief Sets the gradient threshold at which a panning gesture should be locked to the
709 * Horizontal or Vertical axis.
711 * By default this is 0.36 (0.36:1) which means angles less than 20
712 * degrees to an axis will lock to that axis.
714 * @note: Specifying a value of 1.0 (the maximum value accepted) indicates that
715 * all panning gestures will auto-lock. Either to the horizontal or vertical axis.
717 * @param[in] gradient A value between 0.0 and 1.0 (auto-lock for all angles)
719 void SetAxisAutoLockGradient(float gradient);
722 * @brief Gets the friction coefficient setting for ScrollView when
723 * flicking in free panning mode.
725 * This is a value in stage-diagonals per second^2.
726 * stage-diagonal = Length( stage.width, stage.height )
727 * @return Friction coefficient is returned.
729 float GetFrictionCoefficient() const;
732 * @brief Sets the friction coefficient for ScrollView when flicking
733 * in free panning mode.
735 * This is a value in stage-diagonals per second^2.
736 * stage-diagonal = Length( stage.width, stage.height ).
738 * A stage 480x800 in size has a diagonal length of 933.
739 * Friction coefficient of 1.0 means the swipe velocity will
740 * reduce by 1.0 * 933 pixels/sec^2.
741 * @param[in] friction Friction coefficient, must be greater than 0.0 (default = 1.0)
743 void SetFrictionCoefficient(float friction);
746 * @brief Gets the flick speed coefficient for ScrollView when
747 * flicking in free panning mode.
749 * This is a constant which multiplies the input touch
750 * flick velocity to determine the actual velocity at
751 * which to move the scrolling area.
752 * @return The flick speed coefficient is returned.
754 float GetFlickSpeedCoefficient() const;
757 * @brief Sets the flick speed coefficient for ScrollView when
758 * flicking in free panning mode.
760 * This is a constant which multiplies the input touch
761 * flick velocity to determine the actual velocity at
762 * which to move the scrolling area.
763 * @param[in] speed The flick speed coefficient (default = 1.0).
765 void SetFlickSpeedCoefficient(float speed);
768 * @brief Returns the minimum pan distance required for a flick gesture in pixels
770 * @return Minimum pan distance vector with separate x and y distance
772 Vector2 GetMinimumDistanceForFlick() const;
775 * @brief Sets the minimum pan distance required for a flick in pixels
777 * 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
779 * @param[in] distance The minimum pan distance for a flick
781 void SetMinimumDistanceForFlick( const Vector2& distance );
784 * @brief Returns the minimum pan speed required for a flick gesture in pixels per second
786 * @return Minimum pan speed
788 float GetMinimumSpeedForFlick() const;
791 * @brief Sets the minimum pan speed required for a flick in pixels per second
793 * @param[in] speed The minimum pan speed for a flick
795 void SetMinimumSpeedForFlick( float speed );
798 * @brief Gets the maximum flick speed setting for ScrollView when
799 * flicking in free panning mode.
801 * This is a value in stage-diagonals per second.
802 * stage-diagonal = Length( stage.width, stage.height )
803 * @return Maximum flick speed is returned
805 float GetMaxFlickSpeed() const;
808 * @brief Sets the maximum flick speed for the ScrollView when
809 * flicking in free panning mode.
811 * This is a value in stage-diagonals per second.
812 * stage-diagonal = Length( stage.width, stage.height )
814 * A stage 480x800 in size has a diagonal length of 933.
815 * Max Flick speed of 1.0 means the maximum velocity of
816 * a swipe can be 1.0 * 933 pixels/sec.
817 * @param[in] speed Maximum flick speed (default = 3.0)
819 void SetMaxFlickSpeed(float speed);
822 * @brief Gets the step of scroll distance in actor coordinates for
823 * each mouse wheel event received in free panning mode.
825 * @return The step of scroll distance(pixel) in X and Y axes.
827 Vector2 GetMouseWheelScrollDistanceStep() const;
830 * @brief Sets the step of scroll distance in actor coordinates for
831 * each mouse wheel event received in free panning mode.
833 * @param[in] step The step of scroll distance(pixel) in X and Y axes.
835 * @note: If snap points are defined in the rulers, it will always
836 * scroll to the next snap point towards the scroll direction while
837 * receiving the mouse wheel events.
840 void SetMouseWheelScrollDistanceStep(Vector2 step);
843 * @brief Retrieves current scroll position.
845 * @returns The current scroll position.
847 Vector3 GetCurrentScrollPosition() const;
850 * @brief Sets the current scroll position, overriding current scroll animations. If panning is currently taking place
851 * SetScrollPosition will have no effect. Try to ensure panning has stopped before calling this function.
853 * @param[in] position The new scroll position to set.
855 void SetScrollPosition(const Vector3& position);
858 * @brief Retrieves current scroll page based on ScrollView
859 * dimensions being the size of one page, and all pages laid out in
860 * a grid fashion, increasing from left to right until the end of
863 * @note: Pages start from 0 as the first page, not 1.
865 * @returns The Current page.
867 unsigned int GetCurrentPage() const;
870 * @brief Scrolls View to position specified (contents will scroll to this position).
872 * Position 0,0 is the origin. Increasing X scrolls contents left, while
873 * increasing Y scrolls contents up.
874 * - If Rulers have been applied to the axes, then the contents will scroll until
875 * reaching the domain boundary.
876 * @note Contents will not snap to ruler snap points.
878 * @param[in] position The position to scroll to.
880 void ScrollTo(const Vector3 &position);
883 * @brief Scrolls View to position specified (contents will scroll to this position).
885 * Position 0,0 is the origin. Increasing X scrolls contents left, while
886 * increasing Y scrolls contents up.
887 * - If Rulers have been applied to the axes, then the contents will scroll until
888 * reaching the domain boundary.
889 * @note Contents will not snap to ruler snap points.
891 * @param[in] position The position to scroll to.
892 * @param[in] duration The duration of the animation in seconds
894 void ScrollTo(const Vector3 &position, float duration);
897 * @brief Scrolls View to position specified (contents will scroll to this position)
899 * Position 0,0 is the origin. Increasing X scrolls contents left, while
900 * increasing Y scrolls contents up.
901 * - If Rulers have been applied to the axes, then the contents will scroll until
902 * reaching the domain boundary.
903 * @note Contents will not snap to ruler snap points.
905 * @param[in] position The position to scroll to.
906 * @param[in] duration The duration of the animation in seconds
907 * @param[in] alpha The alpha function to use
909 void ScrollTo(const Vector3 &position, float duration, AlphaFunction alpha);
912 * @brief Scrolls View to position specified (contents will scroll to this position).
914 * Position 0,0 is the origin. Increasing X scrolls contents left, while
915 * increasing Y scrolls contents up.
916 * - If Rulers have been applied to the axes, then the contents will scroll until
917 * reaching the domain boundary.
918 * @note Contents will not snap to ruler snap points.
919 * Biasing parameters are provided such that in scenarios with 2 or 2x2 pages in
920 * wrap mode, the application developer can decide whether to scroll left or right
921 * to get to the target page
923 * @param[in] position The position to scroll to.
924 * @param[in] duration The duration of the animation in seconds
925 * @param[in] horizontalBias Whether to bias scrolling to left or right.
926 * @param[in] verticalBias Whether to bias scrolling to top or bottom.
928 void ScrollTo(const Vector3 &position, float duration,
929 DirectionBias horizontalBias, DirectionBias verticalBias);
932 * @brief Scrolls View to position specified (contents will scroll to this position)
934 * Position 0,0 is the origin. Increasing X scrolls contents left, while
935 * increasing Y scrolls contents up.
936 * - If Rulers have been applied to the axes, then the contents will scroll until
937 * reaching the domain boundary.
938 * @note Contents will not snap to ruler snap points.
939 * Biasing parameters are provided such that in scenarios with 2 or 2x2 pages in
940 * wrap mode, the application developer can decide whether to scroll left or right
941 * to get to the target page
943 * @param[in] position The position to scroll to.
944 * @param[in] duration The duration of the animation in seconds
945 * @param[in] horizontalBias Whether to bias scrolling to left or right.
946 * @param[in] verticalBias Whether to bias scrolling to top or bottom.
947 * @param[in] alpha Alpha function to use
949 void ScrollTo(const Vector3 &position, float duration, AlphaFunction alpha,
950 DirectionBias horizontalBias, DirectionBias verticalBias);
953 * @brief Scrolls View to page currently based on assumption that each page is
954 * "(page) * ScrollViewSize.width, 0".
956 * @note Should probably be upgraded so that page is an abstract class, that can be
957 * a function of ScrollViewSize, ruler domain, ruler snap points etc. as pages may be
958 * orchestrated in a 2D grid fashion, or variable width.
960 * @param[in] page to scroll to
962 void ScrollTo(unsigned int page);
965 * @brief Scrolls View to page currently based on assumption that each page is
966 * "(page) * ScrollViewSize.width, 0".
968 * @note Should probably be upgraded so that page is an abstract class, that can be
969 * a function of ScrollViewSize, ruler domain, ruler snap points etc. as pages may be
970 * orchestrated in a 2D grid fashion, or variable width.
972 * @param[in] page to scroll to
973 * @param[in] duration The duration of the animation in seconds
975 void ScrollTo(unsigned int page, float duration);
978 * @brief Scrolls View to page currently based on assumption that each page is
979 * "(page) * ScrollViewSize.width, 0".
981 * @note Should probably be upgraded so that page is an abstract class, that can be
982 * a function of ScrollViewSize, ruler domain, ruler snap points etc. as pages may be
983 * orchestrated in a 2D grid fashion, or variable width.
984 * A biasing parameter is provided such that in scenarios with 2 pages in wrap mode,
985 * the application developer can decide whether to scroll left or right to get to
988 * @param[in] page to scroll to
989 * @param[in] duration The duration of the animation in seconds
990 * @param[in] bias Whether to bias scrolling to left or right.
992 void ScrollTo(unsigned int page, float duration, DirectionBias bias);
995 * @brief Scrolls View such that actor appears in the center of the ScrollView.
997 * @note Actor must be a direct child of ScrollView, otherwise will
998 * cause an assertion failure.
999 * @param[in] actor The actor to center in on (via Scrolling).
1001 void ScrollTo(Actor& actor);
1004 * @brief Scrolls View such that actor appears in the center of the ScrollView.
1006 * @note Actor must be a direct child of ScrollView, otherwise will
1007 * cause an assertion failure.
1008 * @param[in] actor The actor to center in on (via Scrolling).
1009 * @param[in] duration The duration of the animation in seconds
1011 void ScrollTo(Actor& actor, float duration);
1014 * @brief Scrolls View to the nearest snap points as specified by the Rulers.
1016 * If already at snap points, then will return false, and not scroll.
1018 * @return True if Snapping necessary.
1020 bool ScrollToSnapPoint();
1023 * @brief Applies a constraint that will affect the children of ScrollView.
1025 * @note this affects all existing and future Actors that are added to scrollview.
1026 * @param[in] constraint The constraint to apply
1028 void ApplyConstraintToChildren(Constraint constraint);
1031 * @brief Removes all constraints that will affect the children of ScrollView.
1033 * @note this removes all constraints from actors that have been added
1036 void RemoveConstraintsFromChildren();
1039 * @brief Apply Effect to ScrollView.
1041 * @param[in] effect The effect to apply to scroll view
1043 void ApplyEffect(ScrollViewEffect effect);
1046 * @brief Remove Effect from ScrollView.
1048 * @param[in] effect The effect to remove.
1050 void RemoveEffect(ScrollViewEffect effect);
1053 * @brief Remove All Effects from ScrollView.
1055 void RemoveAllEffects();
1058 * @brief Binds actor to this ScrollView.
1060 * Once an actor is bound to a ScrollView, it will be subject to
1061 * that ScrollView's properties.
1063 * @param[in] child The actor to add to this ScrollView.
1065 void BindActor(Actor child);
1068 * @brief Unbind Actor from this ScrollView.
1070 * Once Unbound, this ScrollView will not affect the actor.
1071 * @note this does not remove the child from the ScrollView container
1073 * @param[in] child The actor to be unbound.
1075 void UnbindActor(Actor child);
1078 * @brief Allows the user to constrain the scroll view in a particular direction.
1080 * @param[in] direction The axis to constrain the scroll-view to.
1081 * Usually set to PanGestureDetector::DIRECTION_VERTICAL or PanGestureDetector::DIRECTION_HORIZONTAL (but can be any other angle if desired).
1082 * @param[in] threshold The threshold to apply around the axis.
1083 * @note If no threshold is specified, then the default threshold of PI * 0.25 radians (or 45 degrees) is used.
1085 void SetScrollingDirection( Radian direction, Radian threshold = PanGestureDetector::DEFAULT_THRESHOLD );
1088 * @brief Remove a direction constraint from the scroll view.
1090 * @param[in] direction The axis to stop constraining to.
1091 * Usually will be PanGestureDetector::DIRECTION_VERTICAL or PanGestureDetector::DIRECTION_HORIZONTAL (but can be any other angle if desired).
1093 void RemoveScrollingDirection( Radian direction );
1095 public: // Not intended for application developers
1098 * @brief Creates a handle using the Toolkit::Internal implementation.
1100 * @param[in] implementation The Control implementation.
1102 DALI_INTERNAL ScrollView(Internal::ScrollView& implementation);
1105 * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
1107 * @param[in] internal A pointer to the internal CustomActor.
1109 explicit DALI_INTERNAL ScrollView( Dali::Internal::CustomActor* internal );
1112 } // namespace Toolkit
1116 #endif // __DALI_TOOLKIT_SCROLL_VIEW_H__