Dali 3D User Interface Engine
scroll-view.h
Go to the documentation of this file.
1 #ifndef __DALI_TOOLKIT_SCROLL_VIEW_H__
2 #define __DALI_TOOLKIT_SCROLL_VIEW_H__
3 
4 /*
5  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20 
21 // EXTERNAL INCLUDES
23 
24 // INTERNAL INCLUDES
26 
27 namespace Dali
28 {
29 
30 namespace Toolkit
31 {
32 
33 namespace Internal DALI_INTERNAL
34 {
35 class ScrollView;
36 }
47 {
51 };
52 
58 {
61 };
62 
68 {
69  Snap,
71 };
72 
78 {
82 };
83 
89 {
90 public:
91 
100  explicit RulerDomain(float min, float max, bool enabled = true);
101 
102 public:
103 
104  float min;
105  float max;
106  bool enabled;
107 
120  float Clamp(float x, float length = 0.0f, float scale = 1.0f) const;
121 
135  float Clamp(float x, float length, float scale, ClampState &clamped) const;
136 
143  float GetSize() const;
144 
145 };
146 
147 // Forward declare future extension interface
148 class RulerExtension;
149 
158 {
159 public:
161  enum RulerType {
163  Free
164  };
165 
166 public:
167 
172  Ruler();
173 
185  virtual float Snap(float x, float bias = 0.5f) const = 0;
186 
202  virtual float GetPositionFromPage(unsigned int page, unsigned int &volume, bool wrap) const = 0;
203 
215  virtual unsigned int GetPageFromPosition(float position, bool wrap) const = 0;
216 
223  virtual unsigned int GetTotalPages() const = 0;
224 
231  virtual RulerExtension* GetExtension() { return NULL; }
232 
233 public:
234 
241  Ruler::RulerType GetType() const;
242 
249  bool IsEnabled() const;
250 
255  void Enable();
256 
261  void Disable();
262 
269  void SetDomain(RulerDomain domain);
270 
277  const RulerDomain &GetDomain() const;
278 
283  void DisableDomain();
284 
297  float Clamp(float x, float length = 0.0f, float scale = 1.0f) const;
298 
299 
313  float Clamp(float x, float length, float scale, ClampState &clamped) const;
314 
330  float SnapAndClamp(float x, float bias = 0.5f, float length = 0.0f, float scale = 1.0f) const;
331 
348  float SnapAndClamp(float x, float bias, float length, float scale, ClampState &clamped) const;
349 
350 protected:
351 
356  virtual ~Ruler();
357 
358 protected:
359 
361  bool mEnabled;
363 
364 };
365 
367 
373 {
374 public:
379  DefaultRuler();
380 
384  virtual float Snap(float x, float bias) const;
385 
389  virtual float GetPositionFromPage(unsigned int page, unsigned int &volume, bool wrap) const;
390 
394  virtual unsigned int GetPageFromPosition(float position, bool wrap) const;
395 
399  virtual unsigned int GetTotalPages() const;
400 };
401 
407 {
408 public:
415  FixedRuler(float spacing = 1.0f);
416 
420  virtual float Snap(float x, float bias) const;
421 
425  virtual float GetPositionFromPage(unsigned int page, unsigned int &volume, bool wrap) const;
426 
430  virtual unsigned int GetPageFromPosition(float position, bool wrap) const;
431 
435  virtual unsigned int GetTotalPages() const;
436 
437 private:
438  float mSpacing;
439 };
440 
441 class ScrollViewEffect;
442 class ScrollView;
443 
455 {
456 
457 public:
458 
463  struct ClampEvent
464  {
468  };
469 
474  struct SnapEvent
475  {
478  float duration;
479  };
480 
486  {
487  PROPERTY_START_INDEX = Toolkit::Scrollable::PROPERTY_END_INDEX + 1,
488  PROPERTY_END_INDEX = PROPERTY_START_INDEX + 1000,
489 
490  ANIMATABLE_PROPERTY_START_INDEX = Toolkit::Scrollable::ANIMATABLE_PROPERTY_END_INDEX + 1,
491  ANIMATABLE_PROPERTY_END_INDEX = ANIMATABLE_PROPERTY_START_INDEX + 1000
492  };
493 
498  struct Property
499  {
500  enum
501  {
502  // Event side properties
503  WRAP_ENABLED = PROPERTY_START_INDEX,
507 
508  SCROLL_POSITION = ANIMATABLE_PROPERTY_START_INDEX,
528  START_PAGE_POSITION
529  };
530  };
531 
532  // Typedefs
533 
535 
536 public:
537 
542  ScrollView();
543 
552  ScrollView( const ScrollView& handle );
553 
562  ScrollView& operator=( const ScrollView& handle );
563 
570  ~ScrollView();
571 
578  static ScrollView New();
579 
590  static ScrollView DownCast( BaseHandle handle );
591 
592 public:
593 
600  AlphaFunction GetScrollSnapAlphaFunction() const;
601 
608  void SetScrollSnapAlphaFunction(AlphaFunction alpha);
609 
616  AlphaFunction GetScrollFlickAlphaFunction() const;
617 
624  void SetScrollFlickAlphaFunction(AlphaFunction alpha);
625 
634  float GetScrollSnapDuration() const;
635 
644  void SetScrollSnapDuration(float time);
645 
654  float GetScrollFlickDuration() const;
655 
664  void SetScrollFlickDuration(float time);
665 
675  void SetRulerX(RulerPtr ruler);
676 
686  void SetRulerY(RulerPtr ruler);
687 
697  void SetScrollSensitive(bool sensitive);
698 
711  void SetMaxOvershoot(float overshootX, float overshootY);
712 
719  void SetSnapOvershootAlphaFunction(AlphaFunction alpha);
720 
729  void SetSnapOvershootDuration(float duration);
730 
741  void SetActorAutoSnap(bool enable);
742 
754  void SetWrapMode(bool enable);
755 
762  int GetScrollUpdateDistance() const;
763 
773  void SetScrollUpdateDistance(int distance);
774 
781  bool GetAxisAutoLock() const;
782 
793  void SetAxisAutoLock(bool enable);
794 
802  float GetAxisAutoLockGradient() const;
803 
817  void SetAxisAutoLockGradient(float gradient);
818 
828  float GetFrictionCoefficient() const;
829 
843  void SetFrictionCoefficient(float friction);
844 
855  float GetFlickSpeedCoefficient() const;
856 
867  void SetFlickSpeedCoefficient(float speed);
868 
875  Vector2 GetMinimumDistanceForFlick() const;
876 
885  void SetMinimumDistanceForFlick( const Vector2& distance );
886 
893  float GetMinimumSpeedForFlick() const;
894 
901  void SetMinimumSpeedForFlick( float speed );
902 
912  float GetMaxFlickSpeed() const;
913 
927  void SetMaxFlickSpeed(float speed);
928 
936  Vector2 GetWheelScrollDistanceStep() const;
937 
950  void SetWheelScrollDistanceStep(Vector2 step);
951 
958  Vector2 GetCurrentScrollPosition() const;
959 
971  unsigned int GetCurrentPage() const;
972 
985  void ScrollTo(const Vector2& position);
986 
1000  void ScrollTo(const Vector2& position, float duration);
1001 
1016  void ScrollTo(const Vector2& position, float duration, AlphaFunction alpha);
1017 
1036  void ScrollTo(const Vector2& position, float duration,
1037  DirectionBias horizontalBias, DirectionBias verticalBias);
1038 
1058  void ScrollTo(const Vector2& position, float duration, AlphaFunction alpha,
1059  DirectionBias horizontalBias, DirectionBias verticalBias);
1060 
1072  void ScrollTo(unsigned int page);
1073 
1086  void ScrollTo(unsigned int page, float duration);
1087 
1104  void ScrollTo(unsigned int page, float duration, DirectionBias bias);
1105 
1114  void ScrollTo(Actor& actor);
1115 
1125  void ScrollTo(Actor& actor, float duration);
1126 
1135  bool ScrollToSnapPoint();
1136 
1144  void ApplyConstraintToChildren(Constraint constraint);
1145 
1153  void RemoveConstraintsFromChildren();
1154 
1161  void ApplyEffect(ScrollViewEffect effect);
1162 
1169  void RemoveEffect(ScrollViewEffect effect);
1170 
1175  void RemoveAllEffects();
1176 
1186  void BindActor(Actor child);
1187 
1197  void UnbindActor(Actor child);
1198 
1208  void SetScrollingDirection( Radian direction, Radian threshold = PanGestureDetector::DEFAULT_THRESHOLD );
1209 
1217  void RemoveScrollingDirection( Radian direction );
1218 
1219 public: // Signals
1220 
1233  SnapStartedSignalType& SnapStartedSignal();
1234 
1235 public: // Not intended for application developers
1236 
1244 
1252 };
1253 
1257 } // namespace Toolkit
1258 
1259 } // namespace Dali
1260 
1261 #endif // __DALI_TOOLKIT_SCROLL_VIEW_H__
Dali Docs Home
Read more about Dali