Enlightenment CVS committal Author : rephorm Project : e17 Module : libs/esmart
Dir : e17/libs/esmart/src/lib/esmart_container Modified Files: esmart_container.c esmart_container_element.c esmart_container_private.h esmart_container_smart.c esmart_container_util.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/esmart_container.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- esmart_container.c 10 Nov 2004 15:22:38 -0000 1.4 +++ esmart_container.c 8 Jan 2005 15:08:00 -0000 1.5 @@ -110,6 +110,7 @@ if(!(cont = _container_fetch(container))) return; + /* FIXME optimize this */ length = esmart_container_elements_length_get(container); size = cont->direction ? cont->h : cont->w; @@ -121,13 +122,13 @@ cont->padding.l + cont->padding.r; max_scroll = size - length - pad; - cont->scroll_offset += val; + cont->scroll.offset += val; /* don't scroll beyond the top/bottom */ - if (cont->scroll_offset < max_scroll) - cont->scroll_offset = max_scroll; - else if (cont->scroll_offset > 0) - cont->scroll_offset = 0; + if (cont->scroll.offset < max_scroll) + cont->scroll.offset = max_scroll; + else if (cont->scroll.offset > 0) + cont->scroll.offset = 0; _container_elements_changed(cont); _container_elements_fix(cont); @@ -139,8 +140,8 @@ cont = _container_fetch(container); - if (cont->scroll_offset == scroll_offset) return; - cont->scroll_offset = scroll_offset; + if (cont->scroll.offset == scroll_offset) return; + cont->scroll.offset = scroll_offset; _container_elements_changed(cont); _container_elements_fix(cont); @@ -152,7 +153,7 @@ cont = _container_fetch(container); - return cont->scroll_offset; + return cont->scroll.offset; } @@ -276,7 +277,9 @@ if (!cont) return 0; //_container_elements_fix(cont); - + + if (!cont->changed) return cont->length; + for (l = cont->elements; l; l = l->next) { Container_Element *el = l->data; @@ -291,6 +294,8 @@ /* subtract off extra spacing from last element */ length -= cont->spacing; + cont->length = length; + return length; } @@ -405,6 +410,8 @@ _container_elements_changed(Container *cont) { int r, g, b; + + cont->changed = 1; /* this causes length to be recalced */ evas_object_color_get(cont->clipper, &r, &g, &b, NULL); if(evas_list_count(cont->elements) > 0) evas_object_color_set(cont->clipper, r, g, b, cont->clipper_orig_alpha); @@ -602,25 +609,26 @@ int _container_scroll_timer(void *data) { - Scroll_Data *sd = 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; - _container_elements_fix(sd->cont); + _container_elements_fix(cont); return 1; } =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/esmart/src/lib/esmart_container/esmart_container_element.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- esmart_container_element.c 30 Oct 2004 09:09:59 -0000 1.2 +++ esmart_container_element.c 8 Jan 2005 15:08:00 -0000 1.3 @@ -143,7 +143,7 @@ cont->elements = evas_list_remove(cont->elements, el); free(el); } - cont->scroll_offset = 0; + cont->scroll.offset = 0; _container_elements_changed(cont); } =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/esmart/src/lib/esmart_container/esmart_container_private.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- esmart_container_private.h 10 Nov 2004 15:22:38 -0000 1.2 +++ esmart_container_private.h 8 Jan 2005 15:08:00 -0000 1.3 @@ -36,11 +36,20 @@ int move_button; /* which button to move elements with? (0 for none) */ - int scroll_offset; - Ecore_Timer *scroll_timer; + struct + { + int offset; + Ecore_Timer *timer; + double start_time; + double velocity; + } scroll; + + double length; void (*cb_order_change) (void *data); void *data_order_change; + + unsigned char changed : 1; }; struct _Container_Element @@ -60,13 +69,6 @@ int dragging; }; -struct _Scroll_Data -{ - Container *cont; - double start_time; - double velocity; - double length; -}; struct _Container_Layout_Plugin{ void *handle; =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/esmart/src/lib/esmart_container/esmart_container_smart.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- esmart_container_smart.c 30 Oct 2004 09:09:59 -0000 1.2 +++ esmart_container_smart.c 8 Jan 2005 15:08:00 -0000 1.3 @@ -117,7 +117,7 @@ evas_object_del(data->clipper); evas_object_del(data->grabber); - if (data->scroll_timer) ecore_timer_del(data->scroll_timer); + if (data->scroll.timer) ecore_timer_del(data->scroll.timer); free(data); } @@ -262,6 +262,7 @@ _container_elements_changed(data); _container_elements_fix(data); _container_scale_scroll(data, old_length); + data->changed = 1; } void =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/esmart/src/lib/esmart_container/esmart_container_util.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -3 -r1.1.1.1 -r1.2 --- esmart_container_util.c 5 May 2004 05:57:00 -0000 1.1.1.1 +++ esmart_container_util.c 8 Jan 2005 15:08:00 -0000 1.2 @@ -28,7 +28,7 @@ new_scroll = 0; } else - new_scroll = cont->scroll_offset * (new_length / old_length); + new_scroll = cont->scroll.offset * (new_length / old_length); esmart_container_scroll_offset_set(cont->obj, new_scroll); ------------------------------------------------------- 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