Enlightenment CVS committal Author : rephorm Project : e17 Module : libs/esmart
Dir : e17/libs/esmart/src/lib/esmart_container/layout/entice Modified Files: entice.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/entice/entice.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- entice.c 10 Nov 2004 15:22:39 -0000 1.2 +++ entice.c 8 Jan 2005 15:08:01 -0000 1.3 @@ -217,27 +217,20 @@ void _entice_scroll_start (Container * cont, double velocity) { - Scroll_Data *data; - double length; + cont->scroll.velocity = velocity; + cont->scroll.start_time = ecore_time_get(); - length = esmart_container_elements_length_get (cont->obj); - data = calloc (1, sizeof (Scroll_Data)); - data->velocity = velocity; - data->start_time = ecore_time_get (); - data->cont = cont; - data->length = length; - - cont->scroll_timer = ecore_timer_add (.02, _entice_scroll_timer, data); + cont->scroll.timer = ecore_timer_add (.02, _entice_scroll_timer, cont); } void _entice_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; } } @@ -280,32 +273,31 @@ int _entice_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; + size = cont->direction ? cont->h : cont->w; + pad = cont->direction ? cont->padding.t + cont->padding.b : + cont->padding.l + cont->padding.r; max_scroll = 48; - // size - sd->length - pad; - if (sd->cont->scroll_offset > max_scroll) + if (cont->scroll.offset > max_scroll) { - sd->cont->scroll_offset = 0; + cont->scroll.offset = 0; _entice_current--; } - else if (sd->cont->scroll_offset < -max_scroll) + else if (cont->scroll.offset < -max_scroll) { - sd->cont->scroll_offset = 0; + cont->scroll.offset = 0; _entice_current++; } - _entice_layout (sd->cont); + _entice_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