(TextController/ScrollView) Reduced LOC
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / scrollable / scroll-view / scroll-view-impl.h
index aee050e..4061727 100644 (file)
@@ -30,6 +30,7 @@
 #include <dali-toolkit/public-api/controls/control-impl.h>
 #include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view-effect.h>
 #include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view.h>
+#include <dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl-constraints.h>
 
 namespace Dali
 {
@@ -46,6 +47,8 @@ typedef IntrusivePtr<ScrollInternalConstraints> ScrollInternalConstraintsPtr;
 class ScrollOvershootIndicator;
 typedef IntrusivePtr<ScrollOvershootIndicator> ScrollOvershootIndicatorPtr;
 
+class ScrollViewPropertyHandler;
+
 /**
  * @copydoc Toolkit::ScrollView
  */
@@ -103,42 +106,66 @@ public:
   /**
    * @copydoc Toolkit::ScrollView::GetScrollSnapAlphaFunction
    */
-  AlphaFunction GetScrollSnapAlphaFunction() const;
+  AlphaFunction GetScrollSnapAlphaFunction() const
+  {
+    return mSnapAlphaFunction;
+  }
 
   /**
    * @copydoc Toolkit::ScrollView::SetScrollSnapAlphaFunction
    */
-  void SetScrollSnapAlphaFunction(AlphaFunction alpha);
+  void SetScrollSnapAlphaFunction(AlphaFunction alpha)
+  {
+    mSnapAlphaFunction = alpha;
+  }
 
   /**
    * @copydoc Toolkit::ScrollView::GetScrollFlickAlphaFunction
    */
-  AlphaFunction GetScrollFlickAlphaFunction() const;
+  AlphaFunction GetScrollFlickAlphaFunction() const
+  {
+    return mFlickAlphaFunction;
+  }
 
   /**
    * @copydoc Toolkit::ScrollView::SetScrollFlickAlphaFunction
    */
-  void SetScrollFlickAlphaFunction(AlphaFunction alpha);
+  void SetScrollFlickAlphaFunction(AlphaFunction alpha)
+  {
+    mFlickAlphaFunction = alpha;
+  }
 
   /**
    * @copydoc Toolkit::ScrollView::GetScrollSnapDuration
    */
-  float GetScrollSnapDuration() const;
+  float GetScrollSnapDuration() const
+  {
+    return mSnapDuration;
+  }
 
   /**
    * @copydoc Toolkit::ScrollView::SetScrollSnapDuration
    */
-  void SetScrollSnapDuration(float time);
+  void SetScrollSnapDuration(float time)
+  {
+    mSnapDuration = time;
+  }
 
   /**
    * @copydoc Toolkit::ScrollView::GetScrollFlickDuration
    */
-  float GetScrollFlickDuration() const;
+  float GetScrollFlickDuration() const
+  {
+    return mFlickDuration;
+  }
 
   /**
    * @copydoc Toolkit::ScrollView::SetScrollFlickDuration
    */
-  void SetScrollFlickDuration(float time);
+  void SetScrollFlickDuration(float time)
+  {
+    mFlickDuration = time;
+  }
 
   /**
    * @copydoc Toolkit::ScrollView::ApplyEffect
@@ -168,12 +195,18 @@ public:
   /**
    * @copydoc Toolkit::ScrollView::GetRulerX
    */
-  const RulerPtr GetRulerX() const;
+  const RulerPtr GetRulerX() const
+  {
+    return mRulerX;
+  }
 
   /**
    * @copydoc Toolkit::ScrollView::GetRulerY
    */
-  const RulerPtr GetRulerY() const;
+  const RulerPtr GetRulerY() const
+  {
+    return mRulerY;
+  }
 
   /**
    * @copydoc Toolkit::ScrollView::SetRulerX
@@ -190,7 +223,10 @@ public:
    *
    * @return whether the touch sensitivity is true or false.
    */
-  bool GetScrollSensitive();
+  bool GetScrollSensitive()
+  {
+    return mSensitive;
+  }
 
   /**
    * @copydoc Toolkit::ScrollView::SetScrollSensitive
@@ -205,19 +241,28 @@ public:
   /**
    * @copydoc Toolkit::ScrollView::SetSnapOvershootAlphaFunction
    */
-  void SetSnapOvershootAlphaFunction(AlphaFunction alpha);
+  void SetSnapOvershootAlphaFunction(AlphaFunction alpha)
+  {
+    mSnapOvershootAlphaFunction = alpha;
+  }
 
   /**
    * Retrieve the duartion of Snap Overshoot animation
    *
    * @return the duration.
    */
-  float GetSnapOvershootDuration();
+  float GetSnapOvershootDuration()
+  {
+    return mSnapOvershootDuration;
+  }
 
   /**
    * @copydoc Toolkit::ScrollView::SetSnapOvershootDuration
    */
-  void SetSnapOvershootDuration(float duration);
+  void SetSnapOvershootDuration(float duration)
+  {
+    mSnapOvershootDuration = duration;
+  }
 
   /**
    * Retrieve whether Actor Auto-Snap mode is enabled or not.
@@ -229,7 +274,10 @@ public:
   /**
    * @copydoc Toolkit::ScrollView::SetActorAutoSnap
    */
-  void SetActorAutoSnap(bool enable);
+  void SetActorAutoSnap(bool enable)
+  {
+    mActorAutoSnapEnabled = enable;
+  }
 
   /**
    * Enables or Disables Auto Resizing mode for ScrollView contents.
@@ -251,7 +299,10 @@ public:
    *
    * @return Wrap Mode Enabled flag.
    */
-  bool GetWrapMode() const;
+  bool GetWrapMode() const
+  {
+    return mWrapMode;
+  }
 
   /**
    * @copydoc Toolkit::ScrollView::SetWrapMode
@@ -261,17 +312,26 @@ public:
   /**
    * @copydoc Toolkit::ScrollView::GetScrollupdateDistance
    */
-  int GetScrollUpdateDistance() const;
+  int GetScrollUpdateDistance() const
+  {
+    return mScrollUpdateDistance;
+  }
 
   /**
    * @copydoc Toolkit::ScrollView::SetScrollUpdateDistance
    */
-  void SetScrollUpdateDistance(int distance);
+  void SetScrollUpdateDistance(int distance)
+  {
+    mScrollUpdateDistance = distance;
+  }
 
   /**
    * @copydoc Toolkit::ScrollView::GetAxisAutoLock
    */
-  bool GetAxisAutoLock() const;
+  bool GetAxisAutoLock() const
+  {
+    return mAxisAutoLock;
+  }
 
   /**
    * @copydoc Toolkit::ScrollView::SetAxisAutoLock
@@ -281,7 +341,10 @@ public:
   /**
    * @copydoc Toolkit::ScrollView::GetAxisAutoLockGradient
    */
-  float GetAxisAutoLockGradient() const;
+  float GetAxisAutoLockGradient() const
+  {
+    return mAxisAutoLockGradient;
+  }
 
   /**
    * @copydoc Toolkit::ScrollView::SetAxisAutoLockGradient
@@ -291,7 +354,10 @@ public:
   /**
    * @copydoc Toolkit::ScrollView::GetFrictionCoefficient
    */
-  float GetFrictionCoefficient() const;
+  float GetFrictionCoefficient() const
+  {
+    return mFrictionCoefficient;
+  }
 
   /**
    * @copydoc Toolkit::ScrollView::SetFrictionCoefficient
@@ -301,52 +367,82 @@ public:
   /**
    * @copydoc Toolkit::ScrollView::GetFlickSpeedCoefficient
    */
-  float GetFlickSpeedCoefficient() const;
+  float GetFlickSpeedCoefficient() const
+  {
+    return mFlickSpeedCoefficient;
+  }
 
   /**
    * @copydoc Toolkit::ScrollView::SetFlickSpeedCoefficient
    */
-  void SetFlickSpeedCoefficient(float speed);
+  void SetFlickSpeedCoefficient(float speed)
+  {
+    mFlickSpeedCoefficient = speed;
+  }
 
   /**
    * @copydoc Toolkit::ScrollView::GetMinimumDistanceForFlick
    */
-  Vector2 GetMinimumDistanceForFlick() const;
+  Vector2 GetMinimumDistanceForFlick() const
+  {
+    return mMinFlickDistance;
+  }
 
   /**
    * @copydoc Toolkit::ScrollView::SetMinimumDistanceForFlick
    */
-  void SetMinimumDistanceForFlick(const Vector2& distance);
+  void SetMinimumDistanceForFlick(const Vector2& distance)
+  {
+    mMinFlickDistance = distance;
+  }
 
   /**
    * @copydoc Toolkit::ScrollView::GetMinimumSpeedForFlick
    */
-  float GetMinimumSpeedForFlick() const;
+  float GetMinimumSpeedForFlick() const
+  {
+    return mFlickSpeedThreshold;
+  }
 
   /**
    * @copydoc Toolkit::ScrollView::SetMinimumSpeedForFlick
    */
-  void SetMinimumSpeedForFlick(float speed);
+  void SetMinimumSpeedForFlick(float speed)
+  {
+    mFlickSpeedThreshold = speed;
+  }
 
   /**
    * @copydoc Toolkit::ScrollView::GetMaxFlickSpeed
    */
-  float GetMaxFlickSpeed() const;
+  float GetMaxFlickSpeed() const
+  {
+    return mMaxFlickSpeed;
+  }
 
   /**
    * @copydoc Toolkit::ScrollView::SetMaxFlickSpeed
    */
-  void SetMaxFlickSpeed(float speed);
+  void SetMaxFlickSpeed(float speed)
+  {
+    mMaxFlickSpeed = speed;
+  }
 
   /**
    * @copydoc Toolkit::ScrollView::GetWheelScrollDistanceStep
    */
-  Vector2 GetWheelScrollDistanceStep() const;
+  Vector2 GetWheelScrollDistanceStep() const
+  {
+    return mWheelScrollDistanceStep;
+  }
 
   /**
    * @copydoc Toolkit::ScrollView::SetWheelScrollDistanceStep
    */
-  void SetWheelScrollDistanceStep(Vector2 step);
+  void SetWheelScrollDistanceStep(Vector2 step)
+  {
+    mWheelScrollDistanceStep = step;
+  }
 
   /**
    * @copydoc Toolkit::ScrollView::GetCurrentPage
@@ -680,13 +776,6 @@ private:
   void SnapInternalYTo(float position);
 
   /**
-   * This is called internally whenever the Scroll Rulers are
-   * modified. This will update the properties: 'scrollPositionMin'
-   * and 'scrollPositionMax' to reflect the changes.
-   */
-  void UpdatePropertyDomain();
-
-  /**
    * Called when the gesture starts.
    */
   void GestureStarted();
@@ -727,20 +816,6 @@ private:
   void FinishTransform();
 
   /**
-   * Returns overshoot vector based on current position
-   *
-   * Overshoot vector is defined as how far outside of bounds
-   * the viewport is trying to view (prior to being clamped).
-   *
-   * an overshoot of (100,50), means user is in bottom right corner,
-   * trying to pan +100 to the right, and +50 below. This can be used
-   * to determine an effect, such as stretching.
-   *
-   * @param[in] position The position for which you wish to obtain overshoot vector
-   */
-  Vector2 GetOvershoot(Vector2& position) const;
-
-  /**
    * Clamps position within the domain set up by X/Y Rulers
    *
    * @param[in,out] position The position you wish to clamp
@@ -765,26 +840,6 @@ private:
    */
   void WrapPosition(Vector2& position) const;
 
-  /**
-   * Updates the main internal scroll constraints with new ruler and domain
-   * values
-   */
-  void UpdateMainInternalConstraint();
-
-  /**
-   * Enables/disables the overshoot constraints
-   *
-   * @param[in] enabled whether to enable or disable the overshoot constraints
-   */
-  void SetOvershootConstraintsEnabled(bool enabled);
-
-  /**
-   * Sets internal constraints for this ScrollView.
-   * Many of these internal constraints are based on properties within
-   * ScrollView.
-   */
-  void SetInternalConstraints();
-
 protected:
   struct AccessibleImpl : public Scrollable::AccessibleImpl
   {
@@ -850,13 +905,6 @@ private:
    */
   void OnScrollUpdateNotification(Dali::PropertyNotification& source);
 
-  /**
-   * Set up default rulers using a property map
-   * @param[in] scrollModeMap A map defining the characteristics of X and Y scrolling
-   * using either FixedRuler or DefaultRuler.
-   */
-  void SetScrollMode(const Property::Map& scrollModeMap);
-
 private:
   // Undefined
   ScrollView(const ScrollView&);
@@ -865,6 +913,8 @@ private:
   ScrollView& operator=(const ScrollView& rhs);
 
 private:
+  ScrollViewConstraints mConstraints;
+
   unsigned long mTouchDownTime; ///< The touch down time
 
   int     mGestureStackDepth; ///< How many gestures are currently occuring.
@@ -922,17 +972,6 @@ private:
 
   Vector2 mWheelScrollDistanceStep; ///< The step of scroll distance in actor coordinates in X and Y axes for each wheel event received.
 
-  //ScrollInternalConstraintsPtr mScrollInternalConstraints;
-  Constraint mScrollMainInternalPrePositionConstraint;
-  Constraint mScrollMainInternalPositionConstraint;
-  Constraint mScrollMainInternalOvershootXConstraint;
-  Constraint mScrollMainInternalOvershootYConstraint;
-  Constraint mScrollMainInternalDeltaConstraint;
-  Constraint mScrollMainInternalFinalConstraint;
-  Constraint mScrollMainInternalRelativeConstraint;
-  Constraint mScrollMainInternalDomainConstraint;
-  Constraint mScrollMainInternalPrePositionMaxConstraint;
-
   ScrollOvershootIndicatorPtr    mOvershootIndicator;
   WeakHandle<Toolkit::ScrollBar> mScrollBar;
 
@@ -953,8 +992,22 @@ private:
   bool mCanScrollHorizontal : 1;        ///< Local value of our property to check against
   bool mCanScrollVertical : 1;          ///< Local value of our property to check against
   bool mTransientScrollBar : 1;         ///< True if scroll-bar should be automatically show/hidden during/after panning
+
+  friend ScrollViewConstraints;
+  friend ScrollViewPropertyHandler;
 };
 
+/**
+ * Returns whether to lock scrolling to a particular axis
+ *
+ * @param[in] panDelta Distance panned since gesture started
+ * @param[in] currentLockAxis The current lock axis value
+ * @param[in] lockGradient How quickly to lock to a particular axis
+ *
+ * @return The new axis lock state
+ */
+ScrollView::LockAxis GetLockAxis(const Vector2& panDelta, ScrollView::LockAxis currentLockAxis, float lockGradient);
+
 } // namespace Internal
 
 // Helpers for public-api forwarding methods