From: <enl...@li...> - 2005-12-11 14:45:37
|
Enlightenment CVS committal Author : handyande Project : misc Module : engage Dir : misc/engage/src/module Modified Files: e_mod_main.c e_mod_main.h Log Message: Fix zoom calculations so we can interrupt an in with an out etc =================================================================== RCS file: /cvsroot/enlightenment/misc/engage/src/module/e_mod_main.c,v retrieving revision 1.88 retrieving revision 1.89 diff -u -3 -r1.88 -r1.89 --- e_mod_main.c 11 Dec 2005 03:25:45 -0000 1.88 +++ e_mod_main.c 11 Dec 2005 14:45:24 -0000 1.89 @@ -147,7 +147,6 @@ static int _engage_zoom_out_slave(void *data); E_App *_engage_unmatched_app; -Ecore_Timer *_engage_zoom_timer; /* public module routines. all modules must have these */ E_Module_Api e_modapi = @@ -601,7 +600,9 @@ eb->x = eb->y = eb->w = eb->h = -1; eb->zoom = 1.0; eb->zoom_start_time = 0.0; - eb->zooming = 0; + eb->cancel_zoom_in = 0; + eb->cancel_zoom_out = 0; + eb->state = ENGAGE_NORMAL; eb->mouse_out = -1; evas_event_freeze(eb->evas); @@ -2206,11 +2207,10 @@ ev = event_info; eb = data; - if (_engage_zoom_timer) - ecore_timer_del(_engage_zoom_timer); - if (eb->zoom_start_time) - eb->zoom_start_time = 0; - _engage_zoom_timer = ecore_timer_add(0.05, _engage_zoom_in_slave, eb); + if (eb->state == ENGAGE_ZOOMING) + return; + _engage_zoom_in_slave(eb); + ecore_timer_add(0.05, _engage_zoom_in_slave, eb); evas_object_geometry_get(eb->box_object, &x, &y, &w, &h); edge = e_gadman_client_edge_get(eb->gmc); @@ -2249,11 +2249,10 @@ ev = event_info; eb = data; - if (_engage_zoom_timer) - ecore_timer_del(_engage_zoom_timer); - if (eb->zoom_start_time) - eb->zoom_start_time = 0; - _engage_zoom_timer = ecore_timer_add(0.05, _engage_zoom_out_slave, eb); + if (eb->state == ENGAGE_UNZOOMING) + return; + _engage_zoom_out_slave(eb); + ecore_timer_add(0.05, _engage_zoom_out_slave, eb); eb->mouse_out = -1; _engage_bar_motion_handle(eb, ev->canvas.x, ev->canvas.y); } @@ -2265,12 +2264,23 @@ Engage_Bar *eb; eb = data; - if (eb->zoom_start_time == 0) + if (eb->cancel_zoom_in) + { + eb->cancel_zoom_in = 0; + return 0; + } + if (eb->state == ENGAGE_NORMAL) { - eb->zooming = 1; + eb->state = ENGAGE_ZOOMING; eb->zoom_start_time = ecore_time_get(); } - + else if (eb->state == ENGAGE_UNZOOMING) + { + eb->cancel_zoom_out = 1; + eb->zoom_start_time = ecore_time_get() - (eb->zoom - 1.0) / + (eb->conf->zoom_factor - 1.0) * eb->conf->zoom_duration; + } +eb->state = ENGAGE_ZOOMING; eb->zoom = (eb->conf->zoom_factor - 1.0) * ((ecore_time_get() - eb->zoom_start_time) / eb->conf->zoom_duration) + 1.0; @@ -2279,8 +2289,7 @@ if (eb->zoom >= eb->conf->zoom_factor) { eb->zoom = eb->conf->zoom_factor; - _engage_zoom_timer = NULL; - eb->zoom_start_time = 0; + eb->state = ENGAGE_ZOOMED; _engage_bar_motion_handle(eb, x, y); return 0; } @@ -2295,9 +2304,23 @@ Engage_Bar *eb; eb = data; - if (eb->zoom_start_time == 0) - eb->zoom_start_time = ecore_time_get(); - + if (eb->cancel_zoom_out) + { + eb->cancel_zoom_out = 0; + return 0; + } + if (eb->state == ENGAGE_ZOOMED) + { + eb->state = ENGAGE_UNZOOMING; + eb->zoom_start_time = ecore_time_get(); + } + else if (eb->state == ENGAGE_ZOOMING) + { + eb->cancel_zoom_in = 1; + eb->zoom_start_time = ecore_time_get() - (eb->conf->zoom_factor - eb->zoom) / + (eb->conf->zoom_factor - 1.0) * eb->conf->zoom_duration; + } +eb->state = ENGAGE_UNZOOMING; eb->zoom = (eb->conf->zoom_factor - 1.0) * (1.0 - (ecore_time_get() - eb->zoom_start_time) / eb->conf->zoom_duration) + 1.0; @@ -2306,13 +2329,12 @@ if (eb->zoom <= 1.0) { eb->zoom = 1.0; - _engage_zoom_timer = NULL; eb->zoom_start_time = 0; evas_object_geometry_get(eb->box_object, &bx, &by, &bw, &bh); evas_object_move(eb->event_object, bx, by); evas_object_resize(eb->event_object, bw, bh); - eb->zooming = 0; + eb->state = ENGAGE_NORMAL; _engage_bar_motion_handle(eb, x, y); return 0; } @@ -2630,7 +2652,10 @@ { double range, f, x; double ff, sqrt_ffxx, sqrt_ff_1; + int zooming; + zooming = (eb->state == ENGAGE_ZOOMING || eb->state == ENGAGE_UNZOOMING + || eb->state == ENGAGE_ZOOMED); if (eb->conf->zoom_stretch) { range = 2.5; @@ -2647,11 +2672,11 @@ sqrt_ffxx = sqrt(ff - x * x); sqrt_ff_1 = sqrt(ff - 1.0); - if (!eb->zooming || !eb->conf->zoom) + if (!zooming || !eb->conf->zoom) { *disp = d * eb->conf->iconsize; *zoom = 1.0; - return eb->zooming; + return zooming; } if (d > -range && d < range) =================================================================== RCS file: /cvsroot/enlightenment/misc/engage/src/module/e_mod_main.h,v retrieving revision 1.24 retrieving revision 1.25 diff -u -3 -r1.24 -r1.25 --- e_mod_main.h 10 Dec 2005 18:44:50 -0000 1.24 +++ e_mod_main.h 11 Dec 2005 14:45:24 -0000 1.25 @@ -78,9 +78,10 @@ Evas_Coord x, y, w, h; double zoom; - int zooming; + int cancel_zoom_in:1, cancel_zoom_out:1; double zoom_start_time; - + enum {ENGAGE_NORMAL, ENGAGE_ZOOMING, ENGAGE_ZOOMED, ENGAGE_UNZOOMING} state; + E_Gadman_Client *gmc; Config_Bar *conf; |