Enlightenment CVS committal

Author  : rephorm
Project : e17
Module  : libs/esmart

Dir     : e17/libs/esmart/src/lib/esmart_container/layout/engage


Modified Files:
        engage.c 


Log Message:


begin optimizing things a little.
only recalc length if we really need to.
most Scroll_Data into Container struct.

===================================================================
RCS file: 
/cvsroot/enlightenment/e17/libs/esmart/src/lib/esmart_container/layout/engage/engage.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- engage.c    10 Nov 2004 15:22:38 -0000      1.2
+++ engage.c    8 Jan 2005 15:08:00 -0000       1.3
@@ -102,9 +102,9 @@
   iy = ay;
 
   if (cont->direction)
-    iy += cont->scroll_offset;
+    iy += cont->scroll.offset;
   else
-    ix += cont->scroll_offset;
+    ix += cont->scroll.offset;
 
   L = esmart_container_elements_orig_length_get (cont->obj);
   num = evas_list_count (cont->elements);
@@ -290,7 +290,6 @@
 void
 _engage_scroll_start (Container * cont, double velocity)
 {
-  Scroll_Data *data;
   double length, size;
 
   length = esmart_container_elements_length_get (cont->obj);
@@ -302,23 +301,20 @@
       printf (" length smaller than size\n");
       return;
     }
-  data = calloc (1, sizeof (Scroll_Data));
-  data->velocity = velocity;
-  data->start_time = ecore_time_get ();
-  data->cont = cont;
-  data->length = length;
+  cont->scroll.velocity = velocity;
+  cont->scroll.start_time = ecore_time_get ();
 
-  cont->scroll_timer = ecore_timer_add (.02, _container_scroll_timer, data);
+  cont->scroll.timer = ecore_timer_add (.02, _container_scroll_timer, cont);
 }
 
 void
 _engage_scroll_stop (Container * cont)
 {
   /* FIXME: decelerate on stop? */
-  if (cont->scroll_timer)
+  if (cont->scroll.timer)
     {
-      ecore_timer_del (cont->scroll_timer);
-      cont->scroll_timer = NULL;
+      ecore_timer_del (cont->scroll.timer);
+      cont->scroll.timer = NULL;
     }
 }
 
@@ -339,26 +335,26 @@
 int
 _container_scroll_timer (void *data)
 {
-  Scroll_Data *sd = data;
+  Container *cont = data;
   double dt, dx, size, pad, max_scroll;
 
-  dt = ecore_time_get () - sd->start_time;
+  dt = ecore_time_get () - cont->scroll.start_time;
   dx = 10 * (1 - exp (-dt));
 
-  sd->cont->scroll_offset += dx * sd->velocity;
+  cont->scroll.offset += dx * cont->scroll.velocity;
 
-  size = sd->cont->direction ? sd->cont->h : sd->cont->w;
-  pad = sd->cont->direction ? sd->cont->padding.t + sd->cont->padding.b :
-    sd->cont->padding.l + sd->cont->padding.r;
-  max_scroll = size - sd->length - pad;
+  size = cont->direction ? cont->h : cont->w;
+  pad = cont->direction ? cont->padding.t + cont->padding.b :
+    cont->padding.l + cont->padding.r;
+  max_scroll = size - cont->length - pad;
 
-  if (sd->cont->scroll_offset < max_scroll)
-    sd->cont->scroll_offset = max_scroll;
+  if (cont->scroll.offset < max_scroll)
+    cont->scroll.offset = max_scroll;
 
-  else if (sd->cont->scroll_offset > 0)
-    sd->cont->scroll_offset = 0;
+  else if (cont->scroll.offset > 0)
+    cont->scroll.offset = 0;
 
-  _engage_layout (sd->cont);
+  _engage_layout (cont);
   return 1;
 }
 




-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to