[Scroller] The momentum animation time is changed as the amount of scroll.
authorJaehwan Kim <jae.hwan.kim@samsung.com>
Thu, 25 Apr 2013 16:24:58 +0000 (01:24 +0900)
committerSungho Kwak <sungho1.kwak@samsung.com>
Wed, 12 Jun 2013 04:30:41 +0000 (13:30 +0900)
Change-Id: I706e62c9ac6524b7f2733283e51cbd1da0d9be9c

config/default/base.src
config/desktop/base.src
config/illume/base.src
config/mobile/base.src
src/lib/elm_config.c
src/lib/elm_config.h
src/lib/elm_interface_scrollable.c
src/lib/elm_priv.h

index 5deec8e..af84256 100644 (file)
@@ -7,6 +7,8 @@ group "Elm_Config" struct {
   value "thumbscroll_hold_threshold" int: 24;
   value "thumbscroll_momentum_threshold" double: 100.0;
   value "thumbscroll_friction" double: 1.0;
+  value "thumbscroll_min_friction" double: 1.0;
+  value "thumbscroll_friction_standard" int: 2000;
   value "thumbscroll_bounce_friction" double: 0.5;
   value "thumbscroll_bounce_enable" uchar: 1;
   value "page_scroll_friction" double: 0.5;
index 2437d32..fb66a14 100644 (file)
@@ -6,6 +6,8 @@ group "Elm_Config" struct {
   value "thumbscroll_threshold" int: 24;
   value "thumbscroll_momentum_threshold" double: 100.0;
   value "thumbscroll_friction" double: 1.0;
+  value "thumbscroll_min_friction" double: 1.0;
+  value "thumbscroll_friction_standard" int: 2000;
   value "thumbscroll_bounce_friction" double: 0.5;
   value "thumbscroll_bounce_enable" uchar: 0;
   value "page_scroll_friction" double: 0.5;
index bfba60a..bc51b2f 100644 (file)
@@ -6,6 +6,8 @@ group "Elm_Config" struct {
   value "thumbscroll_threshold" int: 24;
   value "thumbscroll_momentum_threshold" double: 100.0;
   value "thumbscroll_friction" double: 1.0;
+  value "thumbscroll_min_friction" double: 1.0;
+  value "thumbscroll_friction_standard" int: 2000;
   value "thumbscroll_bounce_friction" double: 0.5;
   value "thumbscroll_bounce_enable" uchar: 1;
   value "page_scroll_friction" double: 0.5;
index 5358f8d..dcb7ff0 100644 (file)
@@ -7,6 +7,8 @@ group "Elm_Config" struct {
   value "thumbscroll_hold_threshold" int: 100;
   value "thumbscroll_momentum_threshold" double: 100.0;
   value "thumbscroll_friction" double: 1.0;
+  value "thumbscroll_min_friction" double: 0.3;
+  value "thumbscroll_friction_standard" int: 3000;
   value "thumbscroll_bounce_friction" double: 0.5;
   value "thumbscroll_bounce_enable" uchar: 0;
   value "page_scroll_friction" double: 0.5;
index 71ae2ae..3c1976c 100644 (file)
@@ -332,6 +332,8 @@ _desc_init(void)
    ELM_CONFIG_VAL(D, T, thumbscroll_hold_threshold, T_INT);
    ELM_CONFIG_VAL(D, T, thumbscroll_momentum_threshold, T_DOUBLE);
    ELM_CONFIG_VAL(D, T, thumbscroll_friction, T_DOUBLE);
+   ELM_CONFIG_VAL(D, T, thumbscroll_min_friction, T_DOUBLE);
+   ELM_CONFIG_VAL(D, T, thumbscroll_friction_standard, T_INT);
    ELM_CONFIG_VAL(D, T, thumbscroll_bounce_friction, T_DOUBLE);
    ELM_CONFIG_VAL(D, T, thumbscroll_border_friction, T_DOUBLE);
    ELM_CONFIG_VAL(D, T, thumbscroll_sensitivity_friction, T_DOUBLE);
@@ -1029,6 +1031,8 @@ _config_load(void)
    _elm_config->thumbscroll_hold_threshold = 24;
    _elm_config->thumbscroll_momentum_threshold = 100.0;
    _elm_config->thumbscroll_friction = 1.0;
+   _elm_config->thumbscroll_min_friction = 0.5;
+   _elm_config->thumbscroll_friction_standard = 1000;
    _elm_config->thumbscroll_bounce_friction = 0.5;
    _elm_config->thumbscroll_bounce_enable = EINA_TRUE;
    _elm_config->page_scroll_friction = 0.5;
@@ -1422,6 +1426,10 @@ _env_get(void)
    if (s) _elm_config->thumbscroll_momentum_threshold = _elm_atof(s);
    s = getenv("ELM_THUMBSCROLL_FRICTION");
    if (s) _elm_config->thumbscroll_friction = _elm_atof(s);
+   s = getenv("ELM_THUMBSCROLL_MIN_FRICTION");
+   if (s) _elm_config->thumbscroll_min_friction = _elm_atof(s);
+   s = getenv("ELM_THUMBSCROLL_FRICTION_STANDARD");
+   if (s) _elm_config->thumbscroll_friction_standard = atoi(s);
    s = getenv("ELM_THUMBSCROLL_BOUNCE_ENABLE");
    if (s) _elm_config->thumbscroll_bounce_enable = !!atoi(s);
    s = getenv("ELM_THUMBSCROLL_BOUNCE_FRICTION");
@@ -2118,6 +2126,30 @@ elm_config_scroll_thumbscroll_friction_set(double friction)
 }
 
 EAPI double
+elm_config_scroll_thumbscroll_min_friction_get(void)
+{
+   return _elm_config->thumbscroll_min_friction;
+}
+
+EAPI void
+elm_config_scroll_thumbscroll_min_friction_set(double friction)
+{
+   _elm_config->thumbscroll_min_friction = friction;
+}
+
+EAPI int
+elm_config_scroll_thumbscroll_friction_standard_get(void)
+{
+   return _elm_config->thumbscroll_friction_standard;
+}
+
+EAPI void
+elm_config_scroll_thumbscroll_friction_standard_set(int standard)
+{
+   _elm_config->thumbscroll_friction_standard = standard;
+}
+
+EAPI double
 elm_config_scroll_thumbscroll_border_friction_get(void)
 {
    return _elm_config->thumbscroll_border_friction;
index 2caf9e3..6aef84a 100644 (file)
@@ -381,6 +381,50 @@ EAPI double       elm_config_scroll_thumbscroll_friction_get(void);
 EAPI void         elm_config_scroll_thumbscroll_friction_set(double friction);
 
 /**
+ * Get the min amount of inertia a scroller will impose at self scrolling
+ * animations.
+ *
+ * @return the thumb scroll min friction
+ *
+ * @ingroup Scrolling
+ */
+EAPI double       elm_config_scroll_thumbscroll_min_friction_get(void);
+
+/**
+ * Set the min amount of inertia a scroller will impose at self scrolling
+ * animations.
+ *
+ * @param friction the thumb scroll min friction
+ *
+ * @see elm_config_thumbscroll_min_friction_get()
+ * @ingroup Scrolling
+ */
+EAPI void         elm_config_scroll_thumbscroll_min_friction_set(double friction);
+
+/**
+ * Get the standard velocity of the scroller. The scroll animation time is
+ * same with thumbscroll friction, if the velocity is same with standard
+ * velocity.
+ *
+ * @return the thumb scroll friction
+ *
+ * @ingroup Scrolling
+ */
+EAPI int          elm_config_scroll_thumbscroll_friction_standard_get(void);
+
+/**
+ * Set the standard velocity of the scroller. The scroll animation time is
+ * same with thumbscroll friction, if the velocity is same with standard
+ * velocity.
+ *
+ * @param friction the thumb scroll friction standard
+ *
+ * @see elm_config_thumbscroll_friction_standard_get()
+ * @ingroup Scrolling
+ */
+EAPI void         elm_config_scroll_thumbscroll_friction_standard_set(int standard);
+
+/**
  * Get the amount of lag between your actual mouse cursor dragging
  * movement and a scroller's view movement itself, while pushing it
  * into bounce state manually.
index d951828..205dbd8 100644 (file)
@@ -1829,7 +1829,7 @@ _paging_is_enabled(Elm_Scrollable_Smart_Interface_Data *sid)
 static Eina_Bool
 _elm_scroll_momentum_animator(void *data)
 {
-   double t, dt, p;
+   double t, at, dt, p, r;
    Elm_Scrollable_Smart_Interface_Data *sid = data;
    Evas_Coord x, y, dx, dy, px, py, maxx, maxy, minx, miny;
    Eina_Bool no_bounce_x_end = EINA_FALSE, no_bounce_y_end = EINA_FALSE;
@@ -1842,7 +1842,14 @@ _elm_scroll_momentum_animator(void *data)
    dt = t - sid->down.anim_start;
    if (dt >= 0.0)
      {
-        dt = dt / (_elm_config->thumbscroll_friction + sid->down.extra_time);
+        r = _elm_config->thumbscroll_min_friction / _elm_config->thumbscroll_friction;
+        at = (double)sqrt(
+           (sid->down.dx * sid->down.dx) + (sid->down.dy * sid->down.dy));
+        at = at < ((1.0 - r) * _elm_config->thumbscroll_friction_standard) ?
+           at : (1.0 - r) * _elm_config->thumbscroll_friction_standard;
+        at = ((at / _elm_config->thumbscroll_friction_standard) + r) *
+           (_elm_config->thumbscroll_friction + sid->down.extra_time);
+        dt = dt / at;
         if (dt > 1.0) dt = 1.0;
         p = 1.0 - ((1.0 - dt) * (1.0 - dt));
         dx = (sid->down.dx * (_elm_config->thumbscroll_friction +
index 448bf5e..f29cab6 100644 (file)
@@ -162,6 +162,8 @@ struct _Elm_Config
    int           thumbscroll_hold_threshold;
    double        thumbscroll_momentum_threshold;
    double        thumbscroll_friction;
+   double        thumbscroll_min_friction;
+   int           thumbscroll_friction_standard;
    double        thumbscroll_bounce_friction;
    double        page_scroll_friction;
    double        bring_in_scroll_friction;