Author: cazfi Date: Mon Nov 9 19:44:27 2015 New Revision: 30497 URL: http://svn.gna.org/viewcvs/freeciv?rev=30497&view=rev Log: Added zoom steps API
See patch #6543 Modified: trunk/client/zoom.c trunk/client/zoom.h Modified: trunk/client/zoom.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/client/zoom.c?rev=30497&r1=30496&r2=30497&view=diff ============================================================================== --- trunk/client/zoom.c (original) +++ trunk/client/zoom.c Mon Nov 9 19:44:27 2015 @@ -24,6 +24,10 @@ float map_zoom = 1.0; bool zoom_enabled = FALSE; +static float zoom_steps[] = { + -1.0, 0.10, 0.25, 0.5, 0.75, 1.0, 1.25, 1.5, 2.0, 2.5, 3.0, 4.0, -1.0 +}; + /************************************************************************** Set map zoom level. **************************************************************************/ @@ -45,3 +49,51 @@ map_canvas_resized(mapview.width, mapview.height); } + +/************************************************************************** + Zoom level one step up +**************************************************************************/ +void zoom_step_up(void) +{ + int i; + + /* Even if below previous step, close enough is considered to be in + * previous step so that change is not miniscule */ + for (i = 1 ; + zoom_steps[i] < map_zoom * 1.05 && zoom_steps[i] > 0 ; + i++ ) { + /* empty */ + } + + if (zoom_steps[i] > 0) { + if (zoom_steps[i] > 0.99 && zoom_steps[i] < 1.01) { + zoom_1_0(); + } else { + zoom_set(zoom_steps[i]); + } + } +} + +/************************************************************************** + Zoom level one step down +**************************************************************************/ +void zoom_step_down(void) +{ + int i; + + /* Even if above previous step, close enough is considered to be in + * previous step so that change is not miniscule */ + for (i = ARRAY_SIZE(zoom_steps) - 2 ; + zoom_steps[i] * 1.05 > map_zoom && zoom_steps[i] > 0 ; + i-- ) { + /* empty */ + } + + if (zoom_steps[i] > 0) { + if (zoom_steps[i] > 0.99 && zoom_steps[i] < 1.01) { + zoom_1_0(); + } else { + zoom_set(zoom_steps[i]); + } + } +} Modified: trunk/client/zoom.h URL: http://svn.gna.org/viewcvs/freeciv/trunk/client/zoom.h?rev=30497&r1=30496&r2=30497&view=diff ============================================================================== --- trunk/client/zoom.h (original) +++ trunk/client/zoom.h Mon Nov 9 19:44:27 2015 @@ -23,6 +23,9 @@ #define zoom_get_level() map_zoom #define zoom_is_enabled() zoom_enabled +void zoom_step_up(void); +void zoom_step_down(void); + extern bool zoom_enabled; extern float map_zoom; _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits