raster pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=75bb46a41227c337001a8eee75ae25c5ac1d0e83

commit 75bb46a41227c337001a8eee75ae25c5ac1d0e83
Author: Carsten Haitzler (Rasterman) <ras...@rasterman.com>
Date:   Wed Dec 20 21:49:18 2017 +0900

    elm - scroll manager - fix up momentum animator code to use real consts
    
    use real constnants and remove useless vasriables as well as fix up
    formatting... so we don't get compilers complaining about non-const
    values etc.
    
    @fix
---
 src/lib/elementary/efl_ui_scroll_manager.c | 37 +++++++++++++++---------------
 1 file changed, 19 insertions(+), 18 deletions(-)

diff --git a/src/lib/elementary/efl_ui_scroll_manager.c 
b/src/lib/elementary/efl_ui_scroll_manager.c
index 901d7c12a5..29df43b03c 100644
--- a/src/lib/elementary/efl_ui_scroll_manager.c
+++ b/src/lib/elementary/efl_ui_scroll_manager.c
@@ -1293,34 +1293,35 @@ 
_scroll_manager_hold_animator_del(Efl_Ui_Scroll_Manager_Data *sd)
    return EINA_FALSE;
 }
 
-static void _scroll_manager_momentum_animator_add(Efl_Ui_Scroll_Manager_Data 
*sd, double vx, double vy)
+static void
+_scroll_manager_momentum_animator_add(Efl_Ui_Scroll_Manager_Data *sd, double 
vx, double vy)
 {
-  static const double friction = 5000;
-  static const double inverse_mass = 1;
-  static const double accel = friction * inverse_mass;
-  double dur = 0.0, vel = 0.0;
-  char sdx = 0, sdy = 0;
-  Evas_Coord dstx = 0, dsty = 0;
+#define FRICTION 5000
+#define INVERSE_MASS 1
+#define ACCEL (FRICTION * INVERSE_MASS)
+   double dur = 0.0;
+   char sdx = 0, sdy = 0;
+   Evas_Coord dstx = 0, dsty = 0;
 
 /*
-  if (_scroll_manager_scrollto_animator_del(sd))
-    {
-       restore current veolocity
-       add to vx/vy
-    }
+   if (_scroll_manager_scrollto_animator_del(sd))
+     {
+        restore current veolocity
+        add to vx/vy
+     }
 */
-  Eina_Position2D cur =  efl_ui_pan_position_get(sd->pan_obj);
+   Eina_Position2D cur =  efl_ui_pan_position_get(sd->pan_obj);
 
    sdx = (vx > 0) - (vx < 0);
    sdy = (vy > 0) - (vy < 0);
 
-   dstx = cur.x + sdx * (vx * vx) / (2 * accel);
-   dsty = cur.y + sdy * (vy * vy) / (2 * accel);
+   dstx = cur.x + ((sdx * vx * vx) / (double)(2 * ACCEL));
+   dsty = cur.y + ((sdy * vy * vy) / (double)(2 * ACCEL));
 
-   vel = sqrt(vx*vx + vy*vy);
-   dur = vel / accel;
+   dur = sqrt((vx * vx) + (vy * vy)) / (double)ACCEL;
 
-   _scroll_manager_scrollto_animator_add(sd, cur.x, cur.y, dstx, dsty, dur, 
dur, INTERP_DECEL);
+   _scroll_manager_scrollto_animator_add(sd, cur.x, cur.y, dstx, dsty,
+                                         dur, dur, INTERP_DECEL);
 }
 
 static void

-- 


Reply via email to