(svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
authorDarkvater
Tue, 07 Nov 2006 13:01:36 +0000
changeset 5044 7e70387677e5
parent 5043 d567abc96b5d
child 5045 3e734e178dae
(svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
a bit more sensibly.
gui.h
main_gui.c
viewport.h
--- a/gui.h	Tue Nov 07 12:51:34 2006 +0000
+++ b/gui.h	Tue Nov 07 13:01:36 2006 +0000
@@ -124,13 +124,6 @@
 /* bridge_gui.c */
 void ShowBuildBridgeWindow(uint start, uint end, byte type);
 
-enum {
-	ZOOM_IN   = 0,
-	ZOOM_OUT  = 1,
-	ZOOM_NONE = 2, // hack, used to update the button status
-};
-
-bool DoZoomInOutWindow(int how, Window *w);
 void ShowBuildIndustryWindow(void);
 void ShowQueryString(StringID str, StringID caption, uint maxlen, uint maxwidth, WindowClass window_class, WindowNumber window_number, CharSetFilter afilter);
 void ShowQuery(StringID caption, StringID message, void (*ok_cancel_callback)(bool ok_clicked), WindowClass window_class, WindowNumber window_number);
--- a/main_gui.c	Tue Nov 07 12:51:34 2006 +0000
+++ b/main_gui.c	Tue Nov 07 13:01:36 2006 +0000
@@ -866,29 +866,31 @@
 	assert(w);
 	vp = w->viewport;
 
-	if (how == ZOOM_IN) {
-		if (vp->zoom == 0) return false;
-		vp->zoom--;
-		vp->virtual_width >>= 1;
-		vp->virtual_height >>= 1;
-
-		WP(w,vp_d).scrollpos_x += vp->virtual_width >> 1;
-		WP(w,vp_d).scrollpos_y += vp->virtual_height >> 1;
-
-		SetWindowDirty(w);
-	} else if (how == ZOOM_OUT) {
-		if (vp->zoom == 2) return false;
-		vp->zoom++;
-
-		WP(w,vp_d).scrollpos_x -= vp->virtual_width >> 1;
-		WP(w,vp_d).scrollpos_y -= vp->virtual_height >> 1;
-
-		vp->virtual_width <<= 1;
-		vp->virtual_height <<= 1;
-
-		SetWindowDirty(w);
+	switch (how) {
+		case ZOOM_IN:
+			if (vp->zoom == 0) return false;
+			vp->zoom--;
+			vp->virtual_width >>= 1;
+			vp->virtual_height >>= 1;
+
+			WP(w,vp_d).scrollpos_x += vp->virtual_width >> 1;
+			WP(w,vp_d).scrollpos_y += vp->virtual_height >> 1;
+			break;
+		case ZOOM_OUT:
+			if (vp->zoom == 2) return false;
+			vp->zoom++;
+
+			WP(w,vp_d).scrollpos_x -= vp->virtual_width >> 1;
+			WP(w,vp_d).scrollpos_y -= vp->virtual_height >> 1;
+
+			vp->virtual_width <<= 1;
+			vp->virtual_height <<= 1;
+			break;
+		default: return false;
 	}
 
+	SetWindowDirty(w);
+
 	// routine to disable/enable the zoom buttons. Didn't know where to place these otherwise
 	{
 		Window *wt = NULL;
--- a/viewport.h	Tue Nov 07 12:51:34 2006 +0000
+++ b/viewport.h	Tue Nov 07 13:01:36 2006 +0000
@@ -20,9 +20,17 @@
 	int width, int height, uint32 follow_flags, byte zoom);
 ViewPort *IsPtInWindowViewport(const Window *w, int x, int y);
 Point GetTileBelowCursor(void);
+void UpdateViewportPosition(Window *w);
+
+enum {
+	ZOOM_IN   = 0,
+	ZOOM_OUT  = 1,
+	ZOOM_NONE = 2, // hack, used to update the button status
+};
+
+bool DoZoomInOutWindow(int how, Window *w);
 void ZoomInOrOutToCursorWindow(bool in, Window * w);
 Point GetTileZoomCenterWindow(bool in, Window * w);
-void UpdateViewportPosition(Window *w);
 
 void OffsetGroundSprite(int x, int y);