Revert "Removed additional acceleration routine."
[framework/uifw/elementary.git] / src / lib / els_scroller.c
index bf0301a..ffa0fa0 100644 (file)
@@ -26,7 +26,8 @@ struct _Smart_Data
 
    Elm_Smart_Scroller_Policy hbar_flags, vbar_flags;
 
-   struct {
+   struct
+     {
         Evas_Coord x, y;
         Evas_Coord sx, sy;
         Evas_Coord dx, dy;
@@ -36,81 +37,89 @@ struct _Smart_Data
         Evas_Coord bx0, by0;
         Evas_Coord b0x, b0y;
         Evas_Coord b2x, b2y;
-        struct {
+        struct
+          {
              Evas_Coord    x, y;
              double        timestamp, localtimestamp;
-        } history[60];
-        struct {
-           double tadd, dxsum, dysum;
-           double est_timestamp_diff;
-        } hist;
-      double anim_start;
-      double anim_start2;
-      double anim_start3;
-      double onhold_vx, onhold_vy, onhold_tlast, onhold_vxe, onhold_vye;
-      double extra_time;
-      Evas_Coord hold_x, hold_y;
-      Ecore_Animator *hold_animator;
-      Ecore_Animator *onhold_animator;
-      Ecore_Animator *momentum_animator;
-      Ecore_Animator *bounce_x_animator;
-      Ecore_Animator *bounce_y_animator;
-      Evas_Coord locked_x, locked_y;
-      int hdir, vdir;
-      unsigned char now : 1;
-      unsigned char cancelled : 1;
-      unsigned char hold : 1;
-      unsigned char hold_parent : 1;
-      unsigned char want_dragged : 1;
-      unsigned char dragged : 1;
-      unsigned char dragged_began : 1;
-      unsigned char dir_x : 1;
-      unsigned char dir_y : 1;
-      unsigned char locked : 1;
-      unsigned char bounce_x_hold : 1;
-      unsigned char bounce_y_hold : 1;
-      unsigned char scroll : 1;
-   } down;
-
-   struct {
-      Evas_Coord w, h;
-      Eina_Bool resized : 1;
-   } child;
-   struct {
-      Evas_Coord x, y;
-   } step, page;
-
-   struct {
-      void (*set) (Evas_Object *obj, Evas_Coord x, Evas_Coord y);
-      void (*get) (Evas_Object *obj, Evas_Coord *x, Evas_Coord *y);
-      void (*max_get) (Evas_Object *obj, Evas_Coord *x, Evas_Coord *y);
-      void (*min_get) (Evas_Object *obj, Evas_Coord *x, Evas_Coord *y);
-      void (*child_size_get) (Evas_Object *obj, Evas_Coord *x, Evas_Coord *y);
-      void (*gravity_set) (Evas_Object *obj, double x, double y);
-      void (*gravity_get) (Evas_Object *obj, double *x, double *y);
-   } pan_func;
-
-   struct {
-      struct {
-         Evas_Coord start, end;
-         double t_start, t_end;
-         Ecore_Animator *animator;
-      } x, y;
-   } scrollto;
+          } history[60];
+        struct
+          {
+             double tadd, dxsum, dysum;
+             double est_timestamp_diff;
+          } hist;
+        double anim_start;
+        double anim_start2;
+        double anim_start3;
+        double onhold_vx, onhold_vy, onhold_tlast, onhold_vxe, onhold_vye;
+        double extra_time;
+        Evas_Coord hold_x, hold_y;
+        Ecore_Animator *hold_animator;
+        Ecore_Animator *onhold_animator;
+        Ecore_Animator *momentum_animator;
+        Ecore_Animator *bounce_x_animator;
+        Ecore_Animator *bounce_y_animator;
+        Evas_Coord locked_x, locked_y;
+        int hdir, vdir;
+        Eina_Bool now : 1;
+        Eina_Bool cancelled : 1;
+        Eina_Bool hold : 1;
+        Eina_Bool hold_parent : 1;
+        Eina_Bool want_dragged : 1;
+        Eina_Bool dragged : 1;
+        Eina_Bool dragged_began : 1;
+        Eina_Bool dir_x : 1;
+        Eina_Bool dir_y : 1;
+        Eina_Bool locked : 1;
+        Eina_Bool bounce_x_hold : 1;
+        Eina_Bool bounce_y_hold : 1;
+        Eina_Bool scroll : 1;
+        Eina_Bool want_reset : 1;
+     } down;
+
+   struct
+     {
+        Evas_Coord w, h;
+        Eina_Bool resized : 1;
+     } child;
+   struct
+     {
+        Evas_Coord x, y;
+     } step, page;
+
+   struct
+     {
+        void (*set) (Evas_Object *obj, Evas_Coord x, Evas_Coord y);
+        void (*get) (Evas_Object *obj, Evas_Coord *x, Evas_Coord *y);
+        void (*max_get) (Evas_Object *obj, Evas_Coord *x, Evas_Coord *y);
+        void (*min_get) (Evas_Object *obj, Evas_Coord *x, Evas_Coord *y);
+        void (*child_size_get) (Evas_Object *obj, Evas_Coord *x, Evas_Coord *y);
+        void (*gravity_set) (Evas_Object *obj, double x, double y);
+        void (*gravity_get) (Evas_Object *obj, double *x, double *y);
+     } pan_func;
+
+   struct
+     {
+        struct
+          {
+             Evas_Coord start, end;
+             double t_start, t_end;
+             Ecore_Animator *animator;
+          } x, y;
+     } scrollto;
 
    double pagerel_h, pagerel_v;
    Evas_Coord pagesize_h, pagesize_v;
 
-   unsigned char hbar_visible : 1;
-   unsigned char vbar_visible : 1;
-   unsigned char extern_pan : 1;
-   unsigned char one_dir_at_a_time : 1;
-   unsigned char hold : 1;
-   unsigned char freeze : 1;
-   unsigned char bouncemex : 1;
-   unsigned char bouncemey : 1;
-   unsigned char bounce_horiz : 1;
-   unsigned char bounce_vert : 1;
+   Eina_Bool hbar_visible : 1;
+   Eina_Bool vbar_visible : 1;
+   Eina_Bool extern_pan : 1;
+   Eina_Bool one_dir_at_a_time : 1;
+   Eina_Bool hold : 1;
+   Eina_Bool freeze : 1;
+   Eina_Bool bouncemex : 1;
+   Eina_Bool bouncemey : 1;
+   Eina_Bool bounce_horiz : 1;
+   Eina_Bool bounce_vert : 1;
    Eina_Bool momentum_animator_disabled :1;
    Eina_Bool bounce_animator_disabled :1;
    Eina_Bool is_mirrored : 1;
@@ -120,7 +129,6 @@ struct _Smart_Data
 /* local subsystem functions */
 static void _smart_child_del_hook(void *data, Evas *e, Evas_Object *obj, void *event_info);
 static void _smart_pan_changed_hook(void *data, Evas_Object *obj, void *event_info);
-static void _smart_pan_pan_changed_hook(void *data, Evas_Object *obj, void *event_info);
 static void _smart_event_wheel(void *data, Evas *e, Evas_Object *obj, void *event_info);
 static void _smart_event_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info);
 static Eina_Bool  _smart_hold_animator(void *data);
@@ -220,7 +228,6 @@ elm_smart_scroller_child_set(Evas_Object *obj, Evas_Object *child)
         o = _elm_smart_pan_add(evas_object_evas_get(obj));
         sd->pan_obj = o;
         evas_object_smart_callback_add(o, "changed", _smart_pan_changed_hook, sd);
-        evas_object_smart_callback_add(o, "pan_changed", _smart_pan_pan_changed_hook, sd);
         edje_object_part_swallow(sd->edje_obj, "elm.swallow.content", o);
      }
 
@@ -256,7 +263,6 @@ elm_smart_scroller_extern_pan_set(Evas_Object *obj, Evas_Object *pan,
    if (sd->pan_obj)
      {
         evas_object_smart_callback_del(sd->pan_obj, "changed", _smart_pan_changed_hook);
-        evas_object_smart_callback_del(sd->pan_obj, "pan_changed", _smart_pan_pan_changed_hook);
      }
 
    if (sd->extern_pan)
@@ -277,7 +283,7 @@ elm_smart_scroller_extern_pan_set(Evas_Object *obj, Evas_Object *pan,
      }
    if (!pan)
      {
-        sd->extern_pan = 0;
+        sd->extern_pan = EINA_FALSE;
         return;
      }
 
@@ -289,9 +295,8 @@ elm_smart_scroller_extern_pan_set(Evas_Object *obj, Evas_Object *pan,
    sd->pan_func.child_size_get = pan_child_size_get;
    sd->pan_func.gravity_set = _elm_smart_pan_gravity_set;
    sd->pan_func.gravity_get = _elm_smart_pan_gravity_get;
-   sd->extern_pan = 1;
+   sd->extern_pan = EINA_TRUE;
    evas_object_smart_callback_add(sd->pan_obj, "changed", _smart_pan_changed_hook, sd);
-   evas_object_smart_callback_add(sd->pan_obj, "pan_changed", _smart_pan_pan_changed_hook, sd);
    edje_object_part_swallow(sd->edje_obj, "elm.swallow.content", sd->pan_obj);
    evas_object_show(sd->pan_obj);
 }
@@ -458,6 +463,8 @@ _smart_scrollto_x_animator(void *data)
      {
         px = sd->scrollto.x.end;
         elm_smart_scroller_child_pos_set(sd->smart_obj, px, py);
+        sd->down.sx = px;
+        sd->down.x = sd->down.history[0].x;
         _update_wanted_coordinates(sd, px, py);
         sd->scrollto.x.animator = NULL;
         if ((!sd->scrollto.y.animator) && (!sd->down.bounce_y_animator))
@@ -481,8 +488,8 @@ _smart_momentum_end(Smart_Data *sd)
 
         ecore_animator_del(sd->down.momentum_animator);
         sd->down.momentum_animator = NULL;
-        sd->down.bounce_x_hold = 0;
-        sd->down.bounce_y_hold = 0;
+        sd->down.bounce_x_hold = EINA_FALSE;
+        sd->down.bounce_y_hold = EINA_FALSE;
         sd->down.ax = 0;
         sd->down.ay = 0;
         sd->down.dx = 0;
@@ -529,7 +536,7 @@ _smart_scrollto_x(Smart_Data *sd, double t_in, Evas_Coord pos_x)
         if (sd->child.resized)
           _elm_smart_scroller_wanted_region_set(sd->smart_obj);
      }
-   sd->bouncemex = 0;
+   sd->bouncemex = EINA_FALSE;
 }
 
 static Eina_Bool
@@ -550,6 +557,8 @@ _smart_scrollto_y_animator(void *data)
      {
         py = sd->scrollto.y.end;
         elm_smart_scroller_child_pos_set(sd->smart_obj, px, py);
+        sd->down.sy = py;
+        sd->down.y = sd->down.history[0].y;
         _update_wanted_coordinates(sd, px, py);
         sd->scrollto.y.animator = NULL;
         if ((!sd->scrollto.x.animator) && (!sd->down.bounce_x_animator))
@@ -597,7 +606,7 @@ _smart_scrollto_y(Smart_Data *sd, double t_in, Evas_Coord pos_y)
         if (sd->child.resized)
           _elm_smart_scroller_wanted_region_set(sd->smart_obj);
      }
-   sd->bouncemey = 0;
+   sd->bouncemey = EINA_FALSE;
 }
 
 static Eina_Bool
@@ -713,13 +722,13 @@ _smart_bounce_x_animator(void *data)
         if (dt >= 1.0)
           {
              if (sd->down.momentum_animator)
-               sd->down.bounce_x_hold = 1;
+               sd->down.bounce_x_hold = EINA_TRUE;
              if ((!sd->down.bounce_y_animator) &&
                  (!sd->scrollto.y.animator))
                _smart_anim_stop(sd->smart_obj);
              sd->down.bounce_x_animator = NULL;
              sd->down.pdx = 0;
-             sd->bouncemex = 0;
+             sd->bouncemex = EINA_FALSE;
              _smart_momentum_end(sd);
              if (sd->child.resized)
                _elm_smart_scroller_wanted_region_set(sd->smart_obj);
@@ -768,13 +777,13 @@ _smart_bounce_y_animator(void *data)
         if (dt >= 1.0)
           {
              if (sd->down.momentum_animator)
-               sd->down.bounce_y_hold = 1;
+               sd->down.bounce_y_hold = EINA_TRUE;
              if ((!sd->down.bounce_x_animator) &&
                  (!sd->scrollto.y.animator))
                _smart_anim_stop(sd->smart_obj);
              sd->down.bounce_y_animator = NULL;
              sd->down.pdy = 0;
-             sd->bouncemey = 0;
+             sd->bouncemey = EINA_FALSE;
              _smart_momentum_end(sd);
              if (sd->child.resized)
                _elm_smart_scroller_wanted_region_set(sd->smart_obj);
@@ -889,8 +898,8 @@ _smart_momentum_animator(void *data)
              _smart_anim_stop(sd->smart_obj);
 
              sd->down.momentum_animator = NULL;
-             sd->down.bounce_x_hold = 0;
-             sd->down.bounce_y_hold = 0;
+             sd->down.bounce_x_hold = EINA_FALSE;
+             sd->down.bounce_y_hold = EINA_FALSE;
              sd->down.ax = 0;
              sd->down.ay = 0;
              sd->down.pdx = 0;
@@ -1030,22 +1039,22 @@ elm_smart_scroller_child_pos_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
         if (((x < minx) && (0 <= sd->down.dx)) ||
             ((x > (mx + minx)) && (0 >= sd->down.dx)))
           {
-             sd->bouncemex = 1;
+             sd->bouncemex = EINA_TRUE;
              bounce_eval(sd);
           }
         else
-          sd->bouncemex = 0;
+          sd->bouncemex = EINA_FALSE;
      }
    if (!sd->down.bounce_y_animator)
      {
         if (((y < miny) && (0 <= sd->down.dy)) ||
             ((y > (my + miny)) && (0 >= sd->down.dy)))
           {
-             sd->bouncemey = 1;
+             sd->bouncemey = EINA_TRUE;
              bounce_eval(sd);
           }
         else
-          sd->bouncemey = 0;
+          sd->bouncemey = EINA_FALSE;
      }
    if ((x != px) || (y != py))
      {
@@ -1114,7 +1123,7 @@ _elm_smart_scroller_child_region_show_internal(Evas_Object *obj, Evas_Coord *_x,
      {
         ecore_animator_del(sd->down.bounce_x_animator);
         sd->down.bounce_x_animator = NULL;
-        sd->bouncemex = 0;
+        sd->bouncemex = EINA_FALSE;
         if (sd->child.resized)
           _elm_smart_scroller_wanted_region_set(sd->smart_obj);
      }
@@ -1122,7 +1131,7 @@ _elm_smart_scroller_child_region_show_internal(Evas_Object *obj, Evas_Coord *_x,
      {
         ecore_animator_del(sd->down.bounce_y_animator);
         sd->down.bounce_y_animator = NULL;
-        sd->bouncemey = 0;
+        sd->bouncemey = EINA_FALSE;
         if (sd->child.resized)
           _elm_smart_scroller_wanted_region_set(sd->smart_obj);
      }
@@ -1138,8 +1147,8 @@ _elm_smart_scroller_child_region_show_internal(Evas_Object *obj, Evas_Coord *_x,
      {
         ecore_animator_del(sd->down.momentum_animator);
         sd->down.momentum_animator = NULL;
-        sd->down.bounce_x_hold = 0;
-        sd->down.bounce_y_hold = 0;
+        sd->down.bounce_x_hold = EINA_FALSE;
+        sd->down.bounce_y_hold = EINA_FALSE;
         sd->down.ax = 0;
         sd->down.ay = 0;
         sd->down.pdx = 0;
@@ -1167,8 +1176,15 @@ _elm_smart_scroller_child_region_show_internal(Evas_Object *obj, Evas_Coord *_x,
 void
 elm_smart_scroller_child_region_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
 {
+   API_ENTRY return;
    if (_elm_smart_scroller_child_region_show_internal(obj, &x, &y, w, h))
-     elm_smart_scroller_child_pos_set(obj, x, y);
+     {
+        elm_smart_scroller_child_pos_set(obj, x, y);
+        sd->down.sx = x;
+        sd->down.sy = y;
+        sd->down.x = sd->down.history[0].x;
+        sd->down.y = sd->down.history[0].y;
+     }
 }
 
 /* Set should be used for setting the wanted position, for example a user scroll
@@ -1182,7 +1198,13 @@ elm_smart_scroller_child_region_show(Evas_Object *obj, Evas_Coord x, Evas_Coord
    sd->ww = w;
    sd->wh = h;
    if (_elm_smart_scroller_child_region_show_internal(obj, &x, &y, w, h))
-     elm_smart_scroller_child_pos_set(obj, x, y);
+     {
+        elm_smart_scroller_child_pos_set(obj, x, y);
+        sd->down.sx = x;
+        sd->down.sy = y;
+        sd->down.x = sd->down.history[0].x;
+        sd->down.y = sd->down.history[0].y;
+     }
 }
 
 void
@@ -1342,8 +1364,8 @@ void
 elm_smart_scroller_bounce_allow_set(Evas_Object *obj, Eina_Bool horiz, Eina_Bool vert)
 {
    API_ENTRY return;
-   sd->bounce_horiz = horiz;
-   sd->bounce_vert = vert;
+   sd->bounce_horiz = !!horiz;
+   sd->bounce_vert = !!vert;
 }
 
 void
@@ -1587,46 +1609,6 @@ _smart_pan_changed_hook(void *data, Evas_Object *obj __UNUSED__, void *event_inf
      }
 }
 
-static void
-_smart_pan_pan_changed_hook(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
-{
-   Smart_Data *sd;
-
-   sd = data;
-   if ((sd->down.bounce_x_animator) || (sd->down.bounce_y_animator) ||
-       (sd->scrollto.x.animator) || (sd->scrollto.y.animator))
-     {
-        _smart_anim_stop(sd->smart_obj);
-     }
-   if (sd->scrollto.x.animator)
-     {
-        ecore_animator_del(sd->scrollto.x.animator);
-        sd->scrollto.x.animator = NULL;
-     }
-   if (sd->scrollto.y.animator)
-     {
-        ecore_animator_del(sd->scrollto.y.animator);
-        sd->scrollto.y.animator = NULL;
-     }
-   if (sd->down.bounce_x_animator)
-     {
-        ecore_animator_del(sd->down.bounce_x_animator);
-        sd->down.bounce_x_animator = NULL;
-        sd->bouncemex = 0;
-        if (sd->child.resized)
-          _elm_smart_scroller_wanted_region_set(sd->smart_obj);
-     }
-   if (sd->down.bounce_y_animator)
-     {
-        ecore_animator_del(sd->down.bounce_y_animator);
-        sd->down.bounce_y_animator = NULL;
-        sd->bouncemey = 0;
-        if (sd->child.resized)
-          _elm_smart_scroller_wanted_region_set(sd->smart_obj);
-     }
-   _elm_smart_scroller_wanted_region_set(sd->smart_obj);
-}
-
 void
 elm_smart_scroller_gravity_set(Evas_Object *obj, double x, double y)
 {
@@ -1649,17 +1631,20 @@ _smart_event_wheel(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__,
    Evas_Event_Mouse_Wheel *ev;
    Smart_Data *sd;
    Evas_Coord x = 0, y = 0;
+   int direction = 0;
 
    sd = data;
    ev = event_info;
+   direction = ev->direction;
    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return ;
    if ((evas_key_modifier_is_set(ev->modifiers, "Control")) ||
        (evas_key_modifier_is_set(ev->modifiers, "Alt")) ||
-       (evas_key_modifier_is_set(ev->modifiers, "Shift")) ||
        (evas_key_modifier_is_set(ev->modifiers, "Meta")) ||
        (evas_key_modifier_is_set(ev->modifiers, "Hyper")) ||
        (evas_key_modifier_is_set(ev->modifiers, "Super")))
      return;
+   else if (evas_key_modifier_is_set(ev->modifiers, "Shift"))
+     direction = 1;
    elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y);
    if ((sd->down.bounce_x_animator) || (sd->down.bounce_y_animator) ||
        (sd->scrollto.x.animator) || (sd->scrollto.y.animator))
@@ -1680,7 +1665,7 @@ _smart_event_wheel(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__,
      {
         ecore_animator_del(sd->down.bounce_x_animator);
         sd->down.bounce_x_animator = NULL;
-        sd->bouncemex = 0;
+        sd->bouncemex = EINA_FALSE;
         if (sd->child.resized)
           _elm_smart_scroller_wanted_region_set(sd->smart_obj);
      }
@@ -1688,13 +1673,13 @@ _smart_event_wheel(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__,
      {
         ecore_animator_del(sd->down.bounce_y_animator);
         sd->down.bounce_y_animator = NULL;
-        sd->bouncemey = 0;
+        sd->bouncemey = EINA_FALSE;
         if (sd->child.resized)
           _elm_smart_scroller_wanted_region_set(sd->smart_obj);
      }
-   if (!ev->direction)
+   if (!direction)
      y += ev->z * sd->step.y;
-   else if (ev->direction == 1)
+   else if (direction == 1)
      x += ev->z * sd->step.x;
 
    if ((!sd->hold) && (!sd->freeze))
@@ -1716,14 +1701,14 @@ _smart_event_mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSE
    //   if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return ;
    if (_elm_config->thumbscroll_enable)
      {
-        sd->down.hold = 0;
+        sd->down.hold = EINA_FALSE;
         if ((sd->down.bounce_x_animator) || (sd->down.bounce_y_animator) ||
             (sd->down.momentum_animator) || (sd->scrollto.x.animator) ||
             (sd->scrollto.y.animator))
           {
              ev->event_flags |= EVAS_EVENT_FLAG_ON_SCROLL | EVAS_EVENT_FLAG_ON_HOLD;
-             sd->down.scroll = 1;
-             sd->down.hold = 1;
+             sd->down.scroll = EINA_TRUE;
+             sd->down.hold = EINA_TRUE;
              _smart_anim_stop(sd->smart_obj);
           }
         if (sd->scrollto.x.animator)
@@ -1740,7 +1725,7 @@ _smart_event_mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSE
           {
              ecore_animator_del(sd->down.bounce_x_animator);
              sd->down.bounce_x_animator = NULL;
-             sd->bouncemex = 0;
+             sd->bouncemex = EINA_FALSE;
              if (sd->child.resized)
                _elm_smart_scroller_wanted_region_set(sd->smart_obj);
           }
@@ -1748,7 +1733,7 @@ _smart_event_mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSE
           {
              ecore_animator_del(sd->down.bounce_y_animator);
              sd->down.bounce_y_animator = NULL;
-             sd->bouncemey = 0;
+             sd->bouncemey = EINA_FALSE;
              if (sd->child.resized)
                _elm_smart_scroller_wanted_region_set(sd->smart_obj);
           }
@@ -1764,8 +1749,8 @@ _smart_event_mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSE
           {
              ecore_animator_del(sd->down.momentum_animator);
              sd->down.momentum_animator = NULL;
-             sd->down.bounce_x_hold = 0;
-             sd->down.bounce_y_hold = 0;
+             sd->down.bounce_x_hold = EINA_FALSE;
+             sd->down.bounce_y_hold = EINA_FALSE;
              sd->down.ax = 0;
              sd->down.ay = 0;
              if (sd->child.resized)
@@ -1778,16 +1763,16 @@ _smart_event_mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSE
              sd->down.hist.tadd = 0.0;
              sd->down.hist.dxsum = 0.0;
              sd->down.hist.dysum = 0.0;
-             sd->down.now = 1;
-             sd->down.dragged = 0;
-             sd->down.dir_x = 0;
-             sd->down.dir_y = 0;
+             sd->down.now = EINA_TRUE;
+             sd->down.dragged = EINA_FALSE;
+             sd->down.dir_x = EINA_FALSE;
+             sd->down.dir_y = EINA_FALSE;
              sd->down.x = ev->canvas.x;
              sd->down.y = ev->canvas.y;
              elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y);
              sd->down.sx = x;
              sd->down.sy = y;
-             sd->down.locked = 0;
+             sd->down.locked = EINA_FALSE;
              memset(&(sd->down.history[0]), 0, sizeof(sd->down.history[0]) * 60);
 #ifdef EVTIME
              sd->down.history[0].timestamp = ev->timestamp / 1000.0;
@@ -1798,9 +1783,13 @@ _smart_event_mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSE
              sd->down.history[0].x = ev->canvas.x;
              sd->down.history[0].y = ev->canvas.y;
           }
-        sd->down.dragged_began = 0;
-        sd->down.hold_parent = 0;
-        sd->down.cancelled = 0;
+        sd->down.dragged_began = EINA_FALSE;
+        sd->down.hold_parent = EINA_FALSE;
+        sd->down.cancelled = EINA_FALSE;
+        if (sd->hold || sd->freeze)
+           sd->down.want_reset = EINA_TRUE;
+        else
+           sd->down.want_reset = EINA_FALSE;
      }
 }
 
@@ -1850,83 +1839,6 @@ _smart_hold_animator(void *data)
 
    fx = sd->down.hold_x;
    fy = sd->down.hold_y;
-   if (_elm_config->scroll_smooth_amount > 0.0)
-     {
-        int i, count = 0;
-        Evas_Coord basex = 0, basey = 0, x, y;
-        double dt, t, tdiff, tnow, twin;
-        struct {
-             Evas_Coord x, y, dx, dy;
-             double t, dt;
-        } pos[60];
-
-        tdiff = sd->down.hist.est_timestamp_diff;
-        tnow = ecore_time_get() - tdiff;
-        t = tnow;
-        twin = _elm_config->scroll_smooth_time_window;
-        for (i = 0; i < 60; i++)
-          {
-             // oldest point is sd->down.history[i]
-             // newset is sd->down.history[0]
-             dt = t - sd->down.history[i].timestamp;
-             if (dt > twin)
-               {
-                  i--;
-                  break;
-               }
-             x = sd->down.history[i].x;
-             y = sd->down.history[i].y;
-             _down_coord_eval(sd, &x, &y);
-             if (i == 0)
-               {
-                  basex = x;
-                  basey = y;
-               }
-             pos[i].x = x - basex;
-             pos[i].y = y - basey;
-             pos[i].t =
-                sd->down.history[i].timestamp - sd->down.history[0].timestamp;
-             count++;
-          }
-        count = i;
-        if (count >= 2)
-          {
-             double dtsum = 0.0, tadd, maxdt;
-             double dxsum = 0.0, dysum = 0.0, xsum = 0.0, ysum = 0.0;
-
-             for (i = 0; i < (count - 1); i++)
-               {
-                  pos[i].dx = pos[i].x - pos[i + 1].x;
-                  pos[i].dy = pos[i].y - pos[i + 1].y;
-                  pos[i].dt = pos[i].t - pos[i + 1].t;
-                  dxsum += pos[i].dx;
-                  dysum += pos[i].dy;
-                  dtsum += pos[i].dt;
-                  xsum += pos[i].x;
-                  ysum += pos[i].y;
-               }
-             maxdt = pos[i].t;
-             dxsum /= (double)i;
-             dysum /= (double)i;
-             dtsum /= (double)i;
-             xsum /= (double)i;
-             ysum /= (double)i;
-             tadd = tnow - sd->down.history[0].timestamp + _elm_config->scroll_smooth_future_time;
-             tadd = tadd - (maxdt / 2);
-#define WEIGHT(n, o, v) n = (((double)o * (1.0 - v)) + ((double)n * v))
-             WEIGHT(tadd, sd->down.hist.tadd, _elm_config->scroll_smooth_history_weight);
-             WEIGHT(dxsum, sd->down.hist.dxsum, _elm_config->scroll_smooth_history_weight);
-             WEIGHT(dysum, sd->down.hist.dysum, _elm_config->scroll_smooth_history_weight);
-             fx = basex + xsum + ((dxsum * tadd) / dtsum);
-             fy = basey + ysum + ((dysum * tadd) / dtsum);
-             sd->down.hist.tadd = tadd;
-             sd->down.hist.dxsum = dxsum;
-             sd->down.hist.dysum = dysum;
-             WEIGHT(fx, sd->down.hold_x, _elm_config->scroll_smooth_amount);
-             WEIGHT(fy, sd->down.hold_y, _elm_config->scroll_smooth_amount);
-          }
-        //        printf("%3.5f %i %i\n", ecore_time_get(), sd->down.hold_y, fy);
-     }
 
    elm_smart_scroller_child_pos_get(sd->smart_obj, &ox, &oy);
    if (sd->down.dir_x)
@@ -1967,10 +1879,11 @@ _smart_event_mouse_up(void *data, Evas *e, Evas_Object *obj __UNUSED__, void *ev
    Evas_Event_Mouse_Down *ev;
    Smart_Data *sd;
    Evas_Coord x = 0, y = 0, ox = 0, oy = 0;
+   Evas_Coord vw, vh, aw, ah;
 
    sd = data;
    ev = event_info;
-   sd->down.hold_parent = 0;
+   sd->down.hold_parent = EINA_FALSE;
    sd->down.dx = 0;
    sd->down.dy = 0;
    //   if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return ;
@@ -2054,16 +1967,29 @@ _smart_event_mouse_up(void *data, Evas *e, Evas_Object *obj __UNUSED__, void *ev
                                      ((sd->down.dy > 0) && (sd->down.pdy > 0)) ||
                                      ((sd->down.dy < 0) && (sd->down.pdy < 0)))
                                    {
-                                      double t = ecore_loop_time_get();
-                                      double dt = t - sd->down.anim_start;
+                                      double tt = ecore_loop_time_get();
+                                      double dtt = tt - sd->down.anim_start;
 
-                                      if (dt < 0.0) dt = 0.0;
-                                      else if (dt > _elm_config->thumbscroll_friction)
-                                        dt = _elm_config->thumbscroll_friction;
-                                      sd->down.extra_time = _elm_config->thumbscroll_friction - dt;
+                                      if (dtt < 0.0) dtt = 0.0;
+                                      else if (dtt > _elm_config->thumbscroll_friction)
+                                        dtt = _elm_config->thumbscroll_friction;
+                                      sd->down.extra_time = _elm_config->thumbscroll_friction - dtt;
                                    }
                                  else
                                    sd->down.extra_time = 0.0;
+                                 elm_smart_scroller_child_viewport_size_get(sd->smart_obj, &vw, &vh);
+                                 aw = abs(sd->down.dx);
+                                 if (aw  > vw*3)
+                                   {
+                                      if (sd->down.dx > 0) sd->down.dx = vw*3;
+                                      else sd->down.dx = -(vw*3);
+                                   }
+                                 ah = abs(sd->down.dy);
+                                 if (ah  > vh*3)
+                                   {
+                                      if (sd->down.dy > 0) sd->down.dy = vh*3;
+                                      else sd->down.dy = -(vh*3);
+                                   }
                                  sd->down.pdx = sd->down.dx;
                                  sd->down.pdy = sd->down.dy;
                                  ox = -sd->down.dx;
@@ -2152,19 +2078,19 @@ _smart_event_mouse_up(void *data, Evas *e, Evas_Object *obj __UNUSED__, void *ev
              if (sd->down.scroll)
                {
                   ev->event_flags |= EVAS_EVENT_FLAG_ON_SCROLL;
-                  sd->down.scroll = 0;
+                  sd->down.scroll = EINA_FALSE;
                }
              if (sd->down.hold)
                {
                   ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
-                  sd->down.hold = 0;
+                  sd->down.hold = EINA_FALSE;
                }
-             sd->down.dragged_began = 0;
-             sd->down.dir_x = 0;
-             sd->down.dir_y = 0;
-             sd->down.want_dragged = 0;
-             sd->down.dragged = 0;
-             sd->down.now = 0;
+             sd->down.dragged_began = EINA_FALSE;
+             sd->down.dir_x = EINA_FALSE;
+             sd->down.dir_y = EINA_FALSE;
+             sd->down.want_dragged = EINA_FALSE;
+             sd->down.dragged = EINA_FALSE;
+             sd->down.now = EINA_FALSE;
              elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y);
              elm_smart_scroller_child_pos_set(sd->smart_obj, x, y);
              _update_wanted_coordinates(sd, x, y);
@@ -2238,11 +2164,11 @@ _smart_event_post_move(void *data, Evas *e __UNUSED__)
           {
              if ((sd->down.dir_x) && !can_scroll(sd, sd->down.hdir))
                {
-                  sd->down.dir_x = 0;
+                  sd->down.dir_x = EINA_FALSE;
                }
              if ((sd->down.dir_y) && !can_scroll(sd, sd->down.vdir))
                {
-                  sd->down.dir_y = 0;
+                  sd->down.dir_y = EINA_FALSE;
                }
           }
         if (sd->down.dir_x)
@@ -2250,8 +2176,8 @@ _smart_event_post_move(void *data, Evas *e __UNUSED__)
              if ((!sd->widget) ||
                  (!elm_widget_drag_child_locked_x_get(sd->widget)))
                {
-                  sd->down.want_dragged = 0;
-                  sd->down.dragged = 1;
+                  sd->down.want_dragged = EINA_FALSE;
+                  sd->down.dragged = EINA_TRUE;
                   if (sd->widget)
                     {
                        elm_widget_drag_lock_x_set(sd->widget, 1);
@@ -2259,15 +2185,15 @@ _smart_event_post_move(void *data, Evas *e __UNUSED__)
                   start = 1;
                }
              else
-               sd->down.dir_x = 0;
+               sd->down.dir_x = EINA_FALSE;
           }
         if (sd->down.dir_y)
           {
              if ((!sd->widget) ||
                  (!elm_widget_drag_child_locked_y_get(sd->widget)))
                {
-                  sd->down.want_dragged = 0;
-                  sd->down.dragged = 1;
+                  sd->down.want_dragged = EINA_FALSE;
+                  sd->down.dragged = EINA_TRUE;
                   if (sd->widget)
                     {
                        elm_widget_drag_lock_y_set(sd->widget, 1);
@@ -2275,11 +2201,11 @@ _smart_event_post_move(void *data, Evas *e __UNUSED__)
                   start = 1;
                }
              else
-               sd->down.dir_y = 0;
+               sd->down.dir_y = EINA_FALSE;
           }
         if ((!sd->down.dir_x) && (!sd->down.dir_y))
           {
-             sd->down.cancelled = 1;
+             sd->down.cancelled = EINA_TRUE;
           }
         if (start) _smart_drag_start(sd->smart_obj);
      }
@@ -2296,8 +2222,10 @@ _smart_event_mouse_move(void *data, Evas *e, Evas_Object *obj __UNUSED__, void *
    sd = data;
    ev = event_info;
    //   if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return ;
-   if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) sd->down.hold_parent = 1;
+   if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
+     sd->down.hold_parent = EINA_TRUE;
    evas_post_event_callback_push(e, _smart_event_post_move, sd);
+
    // FIXME: respect elm_widget_scroll_hold_get of parent container
    if (_elm_config->thumbscroll_enable)
      {
@@ -2305,6 +2233,26 @@ _smart_event_mouse_move(void *data, Evas *e, Evas_Object *obj __UNUSED__, void *
           {
              int dodir = 0;
 
+             if ((sd->scrollto.x.animator) && (!sd->hold) && (!sd->freeze))
+               {
+                  Evas_Coord px;
+                  ecore_animator_del(sd->scrollto.x.animator);
+                  sd->scrollto.x.animator = NULL;
+                  sd->pan_func.get(sd->pan_obj, &px, NULL);
+                  sd->down.sx = px;
+                  sd->down.x = sd->down.history[0].x;
+               }
+
+             if ((sd->scrollto.y.animator) && (!sd->hold) && (!sd->freeze))
+               {
+                  Evas_Coord py;
+                  ecore_animator_del(sd->scrollto.y.animator);
+                  sd->scrollto.y.animator = NULL;
+                  sd->pan_func.get(sd->pan_obj, NULL, &py);
+                  sd->down.sy = py;
+                  sd->down.y = sd->down.history[0].y;
+               }
+
 #ifdef SCROLLDBG
              printf("::: %i %i\n", ev->cur.canvas.x, ev->cur.canvas.y);
 #endif
@@ -2342,8 +2290,8 @@ _smart_event_mouse_move(void *data, Evas *e, Evas_Object *obj __UNUSED__, void *
                          {
                             if (x > (y * 2))
                               {
-                                 sd->down.dir_x = 1;
-                                 sd->down.dir_y = 0;
+                                 sd->down.dir_x = EINA_TRUE;
+                                 sd->down.dir_y = EINA_FALSE;
                                  dodir++;
                               }
                          }
@@ -2351,25 +2299,21 @@ _smart_event_mouse_move(void *data, Evas *e, Evas_Object *obj __UNUSED__, void *
                          {
                             if (y > (x * 2))
                               {
-                                 sd->down.dir_x = 0;
-                                 sd->down.dir_y = 1;
+                                 sd->down.dir_x = EINA_FALSE;
+                                 sd->down.dir_y = EINA_TRUE;
                                  dodir++;
                               }
                          }
                        if (!dodir)
                          {
-                            sd->down.dir_x = 1;
-                            sd->down.dir_y = 1;
+                            sd->down.dir_x = EINA_TRUE;
+                            sd->down.dir_y = EINA_TRUE;
                          }
                     }
                   else
                     {
-                       //                       can_scroll(sd, LEFT);
-                       //                       can_scroll(sd, RIGHT);
-                       //                       can_scroll(sd, UP);
-                       //                       can_scroll(sd, DOWN);
-                       sd->down.dir_x = 1;
-                       sd->down.dir_y = 1;
+                       sd->down.dir_x = EINA_TRUE;
+                       sd->down.dir_y = EINA_TRUE;
                     }
                }
              if ((!sd->hold) && (!sd->freeze))
@@ -2379,10 +2323,10 @@ _smart_event_mouse_move(void *data, Evas *e, Evas_Object *obj __UNUSED__, void *
                        (_elm_config->thumbscroll_threshold *
                         _elm_config->thumbscroll_threshold)))
                     {
-                       sd->down.dragged_began = 1;
+                       sd->down.dragged_began = EINA_TRUE;
                        if (!sd->down.dragged)
                          {
-                            sd->down.want_dragged = 1;
+                            sd->down.want_dragged = EINA_TRUE;
                             ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
                             //                            evas_event_feed_hold(e, 1, ev->timestamp, ev->data);
                             //                            _smart_drag_start(sd->smart_obj);
@@ -2401,13 +2345,19 @@ _smart_event_mouse_move(void *data, Evas *e, Evas_Object *obj __UNUSED__, void *
                          y = sd->down.sy - (ev->cur.canvas.y - sd->down.y);
                        else
                          y = sd->down.sy;
+                       if (sd->down.want_reset)
+                         {
+                            sd->down.x = ev->cur.canvas.x;
+                            sd->down.y = ev->cur.canvas.y;
+                            sd->down.want_reset = EINA_FALSE;
+                         }
                        if ((sd->down.dir_x) || (sd->down.dir_y))
                          {
                             if (!sd->down.locked)
                               {
                                  sd->down.locked_x = x;
                                  sd->down.locked_y = y;
-                                 sd->down.locked = 1;
+                                 sd->down.locked = EINA_TRUE;
                               }
                             if (!((sd->down.dir_x) && (sd->down.dir_y)))
                               {
@@ -2454,7 +2404,7 @@ _smart_event_mouse_move(void *data, Evas *e, Evas_Object *obj __UNUSED__, void *
                             ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
                             if (!sd->down.hold)
                               {
-                                 sd->down.hold = 1;
+                                 sd->down.hold = EINA_TRUE;
                                  evas_event_feed_hold(e, 1, ev->timestamp, ev->data);
                               }
                          }
@@ -2590,19 +2540,19 @@ _smart_scrollbar_bar_v_visibility_adjust(Smart_Data *sd)
                   if (h <= vh)
                     {
                        scroll_v_vis_change = 1;
-                       sd->vbar_visible = 0;
+                       sd->vbar_visible = EINA_FALSE;
                     }
                }
              else
                {
                   scroll_v_vis_change = 1;
-                  sd->vbar_visible = 0;
+                  sd->vbar_visible = EINA_FALSE;
                }
           }
         else if (sd->vbar_flags == ELM_SMART_SCROLLER_POLICY_OFF)
           {
              scroll_v_vis_change = 1;
-             sd->vbar_visible = 0;
+             sd->vbar_visible = EINA_FALSE;
           }
      }
    else
@@ -2614,14 +2564,14 @@ _smart_scrollbar_bar_v_visibility_adjust(Smart_Data *sd)
                   if (h > vh)
                     {
                        scroll_v_vis_change = 1;
-                       sd->vbar_visible = 1;
+                       sd->vbar_visible = EINA_TRUE;
                     }
                }
           }
         else if (sd->vbar_flags == ELM_SMART_SCROLLER_POLICY_ON)
           {
              scroll_v_vis_change = 1;
-             sd->vbar_visible = 1;
+             sd->vbar_visible = EINA_TRUE;
           }
      }
    if (scroll_v_vis_change)
@@ -2659,19 +2609,19 @@ _smart_scrollbar_bar_h_visibility_adjust(Smart_Data *sd)
                   if (w <= vw)
                     {
                        scroll_h_vis_change = 1;
-                       sd->hbar_visible = 0;
+                       sd->hbar_visible = EINA_FALSE;
                     }
                }
              else
                {
                   scroll_h_vis_change = 1;
-                  sd->hbar_visible = 0;
+                  sd->hbar_visible = EINA_FALSE;
                }
           }
         else if (sd->hbar_flags == ELM_SMART_SCROLLER_POLICY_OFF)
           {
              scroll_h_vis_change = 1;
-             sd->hbar_visible = 0;
+             sd->hbar_visible = EINA_FALSE;
           }
      }
    else
@@ -2683,14 +2633,14 @@ _smart_scrollbar_bar_h_visibility_adjust(Smart_Data *sd)
                   if (w > vw)
                     {
                        scroll_h_vis_change = 1;
-                       sd->hbar_visible = 1;
+                       sd->hbar_visible = EINA_TRUE;
                     }
                }
           }
         else if (sd->hbar_flags == ELM_SMART_SCROLLER_POLICY_ON)
           {
              scroll_h_vis_change = 1;
-             sd->hbar_visible = 1;
+             sd->hbar_visible = EINA_TRUE;
           }
      }
    if (scroll_h_vis_change)
@@ -2827,13 +2777,13 @@ _smart_add(Evas_Object *obj)
    sd->page.y = -50;
    sd->hbar_flags = ELM_SMART_SCROLLER_POLICY_AUTO;
    sd->vbar_flags = ELM_SMART_SCROLLER_POLICY_AUTO;
-   sd->hbar_visible = 1;
-   sd->vbar_visible = 1;
+   sd->hbar_visible = EINA_TRUE;
+   sd->vbar_visible = EINA_TRUE;
 
-   sd->bounce_horiz = 1;
-   sd->bounce_vert = 1;
+   sd->bounce_horiz = EINA_TRUE;
+   sd->bounce_vert = EINA_TRUE;
 
-   sd->one_dir_at_a_time = 1;
+   sd->one_dir_at_a_time = EINA_TRUE;
    sd->momentum_animator_disabled = EINA_FALSE;
    sd->bounce_animator_disabled = EINA_FALSE;
 
@@ -2870,6 +2820,8 @@ _smart_add(Evas_Object *obj)
    sd->pan_func.max_get = _elm_smart_pan_max_get;
    sd->pan_func.min_get = _elm_smart_pan_min_get;
    sd->pan_func.child_size_get = _elm_smart_pan_child_size_get;
+   sd->pan_func.gravity_set = _elm_smart_pan_gravity_set;
+   sd->pan_func.gravity_get = _elm_smart_pan_gravity_get;
 
    _smart_scrollbar_reset(sd);
 }