Changed all property & signal names to lowerCamelCase
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / public-api / controls / scrollable / scroll-view / scroll-view.h
index 1dcfb85..9a66cfc 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_TOOLKIT_SCROLL_VIEW_H__
 
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,6 +18,9 @@
  *
  */
 
+// EXTERNAL INCLUDES
+#include <dali/public-api/animation/alpha-function.h>
+
 // INTERNAL INCLUDES
 #include <dali-toolkit/public-api/controls/scrollable/scrollable.h>
 
@@ -31,6 +34,29 @@ namespace Internal DALI_INTERNAL
 {
 class ScrollView;
 }
+/**
+ * @addtogroup dali_toolkit_controls_scroll_view
+ * @{
+ */
+
+/**
+ * @brief How axes/rotation or scale are clamped
+ */
+enum ClampState
+{
+  NotClamped,   ///< The quantity isn't clamped
+  ClampedToMin, ///< The quantity is clamped to the min value
+  ClampedToMax  ///< The quantity is clamped to the max value
+};
+
+/**
+ * @brief A 2 dimensional clamp
+ */
+struct ClampState2D
+{
+  ClampState x; ///< The clamp state of the x axis
+  ClampState y; ///< The clamp state of the y axis
+};
 
 /**
  * @brief The snap type
@@ -109,6 +135,9 @@ public:
 
 };
 
+// Forward declare future extension interface
+class RulerExtension;
+
 /**
  * @brief Abstract class to define scroll axes.
  *
@@ -178,6 +207,13 @@ public:
    */
   virtual unsigned int GetTotalPages() const = 0;
 
+  /**
+   * @brief Gets the extension interface of the Ruler.
+   *
+   * @return The extension interface of the Ruler
+   */
+  virtual RulerExtension* GetExtension() { return NULL; }
+
 public:
 
   /**
@@ -384,68 +420,72 @@ class ScrollView;
  */
 class DALI_IMPORT_API ScrollView : public Scrollable
 {
+
 public:
 
-  // Custom properties
-
-  static const std::string SCROLL_PAGE_CURRENT;                         ///< Property, name "scroll-page-current",       type INT
-  static const std::string SCROLL_TIME_PROPERTY_NAME;                   ///< Property, name "scroll-time",               type FLOAT
-  static const std::string SCROLL_POSITION_PROPERTY_NAME;               ///< Property, name "scroll-position",           type VECTOR3
-  static const std::string SCROLL_PRE_POSITION_PROPERTY_NAME;           ///< Property, name "scroll-pre-position",       type VECTOR3
-  static const std::string SCROLL_OVERSHOOT_X_PROPERTY_NAME;            ///< Property, name "scroll-overshoot-x",         type float
-  static const std::string SCROLL_OVERSHOOT_Y_PROPERTY_NAME;            ///< Property, name "scroll-overshoot-y",         type float
-  static const std::string SCROLL_FINAL_PROPERTY_NAME;                  ///< Property, name "scroll-final",              type VECTOR3
-  static const std::string SCROLL_SCALE_PROPERTY_NAME;                  ///< Property, name "scroll-scale",              type VECTOR3
-  static const std::string SCROLL_WRAP_PROPERTY_NAME;                   ///< Property, name "scroll-wrap",               type BOOLEAN
-  static const std::string SCROLL_PANNING_PROPERTY_NAME;                ///< Property, name "scroll-panning",            type BOOLEAN
-  static const std::string SCROLL_SCROLLING_PROPERTY_NAME;              ///< Property, name "scroll-scrolling",          type BOOLEAN
-  static const std::string SCROLL_POSITION_DELTA_PROPERTY_NAME;         ///< Property, name "scroll-position-delta"      type VECTOR3
-  static const std::string SCROLL_START_PAGE_POSITION_PROPERTY_NAME;    ///< Property, name "scroll-start-page-position" type VECTOR3
-
-  // Default settings
-
-  static const float DEFAULT_SLOW_SNAP_ANIMATION_DURATION;              ///< Default Drag-Release animation time.
-  static const float DEFAULT_FAST_SNAP_ANIMATION_DURATION;              ///< Default Drag-Flick animation time.
-  static const float DEFAULT_SNAP_OVERSHOOT_DURATION;                   ///< Default Overshoot snapping animation time.
-  static const float DEFAULT_MAX_OVERSHOOT;                             ///< Default maximum allowed overshoot
-
-  static const float DEFAULT_AXIS_AUTO_LOCK_GRADIENT;                   ///< Default Axis-AutoLock gradient threshold. default is 0.36:1 (20 degrees)
-  static const float DEFAULT_FRICTION_COEFFICIENT;                      ///< Default Friction Co-efficient. (in stage diagonals per second)
-  static const float DEFAULT_FLICK_SPEED_COEFFICIENT;                   ///< Default Flick speed coefficient (multiples input touch velocity)
-  static const float DEFAULT_MAX_FLICK_SPEED;                           ///< Default Maximum flick speed. (in stage diagonals per second)
-
-  /// Direction of transitions
-  enum EDirectionFlag
+  /**
+   * @brief Clamp signal event's data
+   */
+  struct ClampEvent
   {
-    DirectionFlagLeft               = 0x01,
-    DirectionFlagRight              = 0x02,
-    DirectionFlagUp                 = 0x04,
-    DirectionFlagDown               = 0x08,
-    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
-    DirectionFlagTransitionOff      = 0x20,
-    DirectionFlagMask_Direction     = DirectionFlagLeft | DirectionFlagRight | DirectionFlagUp | DirectionFlagDown,
-    DirectionFlagMask_Transition    = DirectionFlagTransitionOn | DirectionFlagTransitionOff
+    ClampState2D scale;       ///< Clamp information for scale axes
+    ClampState2D position;    ///< Clamp information for position axes
+    ClampState   rotation;    ///< Clamp information for rotation
   };
 
-public:
-
   /**
    * @brief Snap signal event's data.
    */
   struct SnapEvent
   {
     SnapType type;    ///< Current snap commencing
-    Vector3 position; ///< Target snap position
+    Vector2 position; ///< Target snap position
     float duration;   ///< Duration of snap animation.
   };
 
-  typedef Signal< void ( const SnapEvent& ) > SnapStartedSignalType; ///< SnapStarted signal type
+  /**
+   * @brief The start and end property ranges for this control.
+   */
+  enum PropertyRange
+  {
+    ANIMATABLE_PROPERTY_START_INDEX = Toolkit::Scrollable::ANIMATABLE_PROPERTY_END_INDEX + 1,
+    ANIMATABLE_PROPERTY_END_INDEX   = ANIMATABLE_PROPERTY_START_INDEX + 1000                   ///< Reserve animatable property indices
+  };
 
   /**
-   * @brief Signal emitted when the ScrollView has started to snap or flick (it tells the target
-   * position, scale, rotation for the snap or flick)
+   * @brief An enumeration of properties belonging to the ScrollView class.
    */
-  SnapStartedSignalType& SnapStartedSignal();
+  struct Property
+  {
+    enum
+    {
+      SCROLL_POSITION = ANIMATABLE_PROPERTY_START_INDEX, ///< Property, name "scrollPosition",            type Vector2
+      SCROLL_PRE_POSITION,                               ///< Property, name "scrollPrePosition",         type Vector2
+      SCROLL_PRE_POSITION_X,                             ///< Property, name "scrollPrePositionX",        type float
+      SCROLL_PRE_POSITION_Y,                             ///< Property, name "scrollPrePositionY",        type float
+      SCROLL_PRE_POSITION_MAX,                           ///< Property, name "scrollPrePositionMax",      type Vector2
+      SCROLL_PRE_POSITION_MAX_X,                         ///< Property, name "scrollPrePositionMaxX",     type float
+      SCROLL_PRE_POSITION_MAX_Y,                         ///< Property, name "scrollPrePositionMaxY",     type float
+      OVERSHOOT_X,                                       ///< Property, name "overshootX",                type float
+      OVERSHOOT_Y,                                       ///< Property, name "overshootY",                type float
+      SCROLL_FINAL,                                      ///< Property, name "scrollFinal",               type Vector2
+      SCROLL_FINAL_X,                                    ///< Property, name "scrollFinalX",              type float
+      SCROLL_FINAL_Y,                                    ///< Property, name "scrollFinalY",              type float
+      WRAP,                                              ///< Property, name "wrap",                      type bool
+      PANNING,                                           ///< Property, name "panning",                   type bool
+      SCROLLING,                                         ///< Property, name "scrolling",                 type bool
+      SCROLL_DOMAIN_SIZE,                                ///< Property, name "scrollDomainSize",          type Vector2
+      SCROLL_DOMAIN_SIZE_X,                              ///< Property, name "scrollDomainSizeX",         type float
+      SCROLL_DOMAIN_SIZE_Y,                              ///< Property, name "scrollDomainSizeY",         type float
+      SCROLL_DOMAIN_OFFSET,                              ///< Property, name "scrollDomainOffset",        type Vector2
+      SCROLL_POSITION_DELTA,                             ///< Property, name "scrollPositionDelta",       type Vector2
+      START_PAGE_POSITION                                ///< Property, name "startPagePosition",         type Vector3
+    };
+  };
+
+  // Typedefs
+
+  typedef Signal< void ( const SnapEvent& ) > SnapStartedSignalType; ///< SnapStarted signal type
 
 public:
 
@@ -623,24 +663,6 @@ public:
   void SetSnapOvershootDuration(float duration);
 
   /**
-   * @brief Sets Touches required for pan gestures.
-   *
-   * Panning requires number of touches to be within (minTouches) and
-   * (maxTouches).
-   *
-   * If (endOutside) is true, then outside this range of touches,
-   * the pan gesture will end and thus will snap.
-   *
-   * If (endOutside) is false, then outside this range of touches,
-   * the pan gesture will pause. but will not end until touches = 0.
-   *
-   * @param[in] minTouches Minimum touches for panning to occur.
-   * @param[out] maxTouches Maxiumum touches for panning to occur.
-   * @param[in] endOutside Whether to end the panning gesture outside of touch range
-   */
-  void SetTouchesRequiredForPanning(unsigned int minTouches = 1, unsigned int maxTouches = 1, bool endOutside = true);
-
-  /**
    * @brief Enables or Disables Actor Auto-Snap mode.
    *
    * When Actor Auto-Snap mode has been enabled, ScrollView will automatically
@@ -822,39 +844,31 @@ public:
 
   /**
    * @brief Gets the step of scroll distance in actor coordinates for
-   * each mouse wheel event received in free panning mode.
+   * each wheel event received in free panning mode.
    *
    * @return The step of scroll distance(pixel) in X and Y axes.
    */
-  Vector2 GetMouseWheelScrollDistanceStep() const;
+  Vector2 GetWheelScrollDistanceStep() const;
 
   /**
    * @brief Sets the step of scroll distance in actor coordinates for
-   * each mouse wheel event received in free panning mode.
+   * each wheel event received in free panning mode.
    *
    * @param[in] step The step of scroll distance(pixel) in X and Y axes.
    *
    * @note: If snap points are defined in the rulers, it will always
    * scroll to the next snap point towards the scroll direction while
-   * receiving the mouse wheel events.
+   * receiving the wheel events.
    *
    */
-  void SetMouseWheelScrollDistanceStep(Vector2 step);
+  void SetWheelScrollDistanceStep(Vector2 step);
 
   /**
    * @brief Retrieves current scroll position.
    *
    * @returns The current scroll position.
    */
-  Vector3 GetCurrentScrollPosition() const;
-
-  /**
-   * @brief Sets the current scroll position, overriding current scroll animations. If panning is currently taking place
-   *        SetScrollPosition will have no effect. Try to ensure panning has stopped before calling this function.
-   *
-   * @param[in] position The new scroll position to set.
-   */
-  void SetScrollPosition(const Vector3& position);
+  Vector2 GetCurrentScrollPosition() const;
 
   /**
    * @brief Retrieves current scroll page based on ScrollView
@@ -879,7 +893,7 @@ public:
    *
    * @param[in] position The position to scroll to.
    */
-  void ScrollTo(const Vector3 &position);
+  void ScrollTo(const Vector2& position);
 
   /**
    * @brief Scrolls View to position specified (contents will scroll to this position).
@@ -893,7 +907,7 @@ public:
    * @param[in] position The position to scroll to.
    * @param[in] duration The duration of the animation in seconds
    */
-  void ScrollTo(const Vector3 &position, float duration);
+  void ScrollTo(const Vector2& position, float duration);
 
   /**
    * @brief Scrolls View to position specified (contents will scroll to this position)
@@ -908,7 +922,7 @@ public:
    * @param[in] duration The duration of the animation in seconds
    * @param[in] alpha The alpha function to use
    */
-  void ScrollTo(const Vector3 &position, float duration, AlphaFunction alpha);
+  void ScrollTo(const Vector2& position, float duration, AlphaFunction alpha);
 
   /**
    * @brief Scrolls View to position specified (contents will scroll to this position).
@@ -927,7 +941,7 @@ public:
    * @param[in] horizontalBias Whether to bias scrolling to left or right.
    * @param[in] verticalBias Whether to bias scrolling to top or bottom.
    */
-  void ScrollTo(const Vector3 &position, float duration,
+  void ScrollTo(const Vector2& position, float duration,
                 DirectionBias horizontalBias, DirectionBias verticalBias);
 
   /**
@@ -948,7 +962,7 @@ public:
    * @param[in] verticalBias Whether to bias scrolling to top or bottom.
    * @param[in] alpha Alpha function to use
    */
-  void ScrollTo(const Vector3 &position, float duration, AlphaFunction alpha,
+  void ScrollTo(const Vector2& position, float duration, AlphaFunction alpha,
                 DirectionBias horizontalBias, DirectionBias verticalBias);
 
   /**
@@ -1094,6 +1108,21 @@ public:
    */
   void RemoveScrollingDirection( Radian direction );
 
+public: // Signals
+
+  /**
+   * @brief Signal emitted when the ScrollView has started to snap or flick (it tells the target
+   * position, scale, rotation for the snap or flick)
+   *
+   * A callback of the following type may be connected:
+   * @code
+   *   void YourCallbackName(const SnapEvent& event);
+   * @endcode
+   * @pre The Object has been initialized.
+   * @return The signal to connect to.
+   */
+  SnapStartedSignalType& SnapStartedSignal();
+
 public: // Not intended for application developers
 
   /**
@@ -1111,6 +1140,9 @@ public: // Not intended for application developers
   explicit DALI_INTERNAL ScrollView( Dali::Internal::CustomActor* internal );
 };
 
+/**
+ * @}
+ */
 } // namespace Toolkit
 
 } // namespace Dali