Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2003:
[Freeciv-Dev] (PR#6316) y-scrolling for overview window
Home

[Freeciv-Dev] (PR#6316) y-scrolling for overview window

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#6316) y-scrolling for overview window
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 28 Sep 2003 20:53:59 -0700
Reply-to: rt@xxxxxxxxxxxxxx

The attached patch changes the overview window to scroll in the Y 
direction as well as the X direction.  This is good for any non-standard 
topology that wraps in this direction.

jason

? diff
? client/diff
Index: client/mapview_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.c,v
retrieving revision 1.61
diff -u -r1.61 mapview_common.c
--- client/mapview_common.c     2003/09/29 03:28:43     1.61
+++ client/mapview_common.c     2003/09/29 03:52:19
@@ -38,8 +38,8 @@
 
 struct canvas mapview_canvas;
 
-/* Coordinates of the upper left corner of the map overview. */
-int map_overview_x0;
+/* Overview oordinates of the upper left corner of the map overview. */
+int map_overview_x0, map_overview_y0;
 
 static void center_tile_overviewcanvas(int map_x, int map_y);
 
@@ -1332,7 +1332,11 @@
   } else {
     map_overview_x0 = 0;
   }
-  /* TODO: Y-wrapping of overview */
+  if (topo_has_flag(TF_WRAPY)) {
+    map_overview_y0 = WRAP(map_y - map.ysize / 2, map.ysize);
+  } else {
+    map_overview_y0 = 0;
+  }
 }
 
 /**************************************************************************
@@ -1349,10 +1353,13 @@
    * NOTE: this embeds the map wrapping in the overview code. */
   map_to_native_pos(&gui_x, &gui_y, map_x, map_y);
   gui_x -= map_overview_x0;
+  gui_y -= map_overview_y0;
   if (topo_has_flag(TF_WRAPX)) {
     gui_x = WRAP(gui_x, map.xsize);
+  }
+  if (topo_has_flag(TF_WRAPY)) {
+    gui_y = WRAP(gui_y, map.ysize);
   }
-  /* TODO: Y-wrapping of overview */
   *overview_x = OVERVIEW_TILE_WIDTH * gui_x;
   *overview_y = OVERVIEW_TILE_HEIGHT * gui_y;
 }
@@ -1364,8 +1371,7 @@
                         int overview_x, int overview_y)
 {
   int nat_x = overview_x / OVERVIEW_TILE_WIDTH + map_overview_x0;
-  int nat_y = overview_y / OVERVIEW_TILE_HEIGHT;
-  /* TODO: Y-wrapping of overview */
+  int nat_y = overview_y / OVERVIEW_TILE_HEIGHT + map_overview_y0;
 
   native_to_map_pos(map_x, map_y, nat_x, nat_y);
   if (!normalize_map_pos(map_x, map_y)) {
Index: client/mapview_common.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.h,v
retrieving revision 1.38
diff -u -r1.38 mapview_common.h
--- client/mapview_common.h     2003/09/29 03:28:43     1.38
+++ client/mapview_common.h     2003/09/29 03:52:19
@@ -196,6 +196,6 @@
 
 void get_mapview_corners(int overview_x_array[4], int overview_y_array[4]);
 
-extern int map_overview_x0;
+extern int map_overview_x0, map_overview_y0;
 
 #endif /* FC__MAPVIEW_COMMON_H */
Index: client/gui-gtk/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/mapview.c,v
retrieving revision 1.181
diff -u -r1.181 mapview.c
--- client/gui-gtk/mapview.c    2003/09/29 03:28:43     1.181
+++ client/gui-gtk/mapview.c    2003/09/29 03:52:19
@@ -460,16 +460,20 @@
 {
   int x0 = OVERVIEW_TILE_WIDTH * map_overview_x0;
   int x1 = OVERVIEW_TILE_WIDTH * (map.xsize - map_overview_x0);
-  int dy = OVERVIEW_TILE_HEIGHT * map.ysize;
+  int y0 = OVERVIEW_TILE_HEIGHT * map_overview_y0;
+  int y1 = OVERVIEW_TILE_HEIGHT * (map.ysize - map_overview_y0);
   int gui_x[4], gui_y[4], i;
 
-  /* Copy the part of the overview to the right of map_overview_x0. */
+  /* (map_overview_x0, map_overview_y0) splits the map into four
+   * rectangles.  Draw each of these rectangles to the screen, in turn. */
   gdk_draw_pixmap(overview_canvas->window, civ_gc, overview_canvas_store,
-                 x0, 0, 0, 0, x1, dy);
-
-  /* Copy the part of the overview to the left of map_overview_x0. */
+                 x0, y0, 0, 0, x1, y1);
+  gdk_draw_pixmap(overview_canvas->window, civ_gc, overview_canvas_store,
+                 0, y0, x1, 0, x0, y1);
+  gdk_draw_pixmap(overview_canvas->window, civ_gc, overview_canvas_store,
+                 x0, 0, 0, y1, x1, y0);
   gdk_draw_pixmap(overview_canvas->window, civ_gc, overview_canvas_store,
-                 0, 0, x1, 0, x0, dy);
+                 0, 0, x1, y1, x0, y0);
 
   /* Now draw the mapview window rectangle onto the overview. */
   gdk_gc_set_foreground(civ_gc, colors_standard[COLOR_STD_WHITE]);
Index: client/gui-gtk-2.0/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/mapview.c,v
retrieving revision 1.75
diff -u -r1.75 mapview.c
--- client/gui-gtk-2.0/mapview.c        2003/09/29 03:28:43     1.75
+++ client/gui-gtk-2.0/mapview.c        2003/09/29 03:52:19
@@ -509,16 +509,20 @@
 {
   int x0 = OVERVIEW_TILE_WIDTH * map_overview_x0;
   int x1 = OVERVIEW_TILE_WIDTH * (map.xsize - map_overview_x0);
-  int dy = OVERVIEW_TILE_HEIGHT * map.ysize;
+  int y0 = OVERVIEW_TILE_HEIGHT * map_overview_y0;
+  int y1 = OVERVIEW_TILE_HEIGHT * (map.ysize - map_overview_y0);
   int gui_x[4], gui_y[4], i;
 
-  /* Copy the part of the overview to the right of map_overview_x0. */
+  /* (map_overview_x0, map_overview_y0) splits the map into four
+   * rectangles.  Draw each of these rectangles to the screen, in turn. */
   gdk_draw_drawable(overview_canvas->window, civ_gc, overview_canvas_store,
-                   x0, 0, 0, 0, x1, dy);
-
-  /* Copy the part of the overview to the left of map_overview_x0. */
+                   x0, y0, 0, 0, x1, y1);
+  gdk_draw_drawable(overview_canvas->window, civ_gc, overview_canvas_store,
+                   0, y0, x1, 0, x0, y1);
+  gdk_draw_drawable(overview_canvas->window, civ_gc, overview_canvas_store,
+                   x0, 0, 0, y1, x1, y0);
   gdk_draw_drawable(overview_canvas->window, civ_gc, overview_canvas_store,
-                   0, 0, x1, 0, x0, dy);
+                   0, 0, x1, y1, x0, y0);
 
   /* Now draw the mapview window rectangle onto the overview. */
   gdk_gc_set_foreground(civ_gc, colors_standard[COLOR_STD_WHITE]);
Index: client/gui-win32/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/mapview.c,v
retrieving revision 1.79
diff -u -r1.79 mapview.c
--- client/gui-win32/mapview.c  2003/09/29 03:28:43     1.79
+++ client/gui-win32/mapview.c  2003/09/29 03:52:19
@@ -899,7 +899,8 @@
 {
   int x0 = OVERVIEW_TILE_WIDTH * map_overview_x0;
   int x1 = OVERVIEW_TILE_WIDTH * (map.xsize - map_overview_x0);
-  int dy = OVERVIEW_TILE_HEIGHT * map.ysize;
+  int y0 = OVERVIEW_TILE_HEIGHT * map_overview_y0;
+  int y1 = OVERVIEW_TILE_HEIGHT * (map.ysize - map_overview_y0);
   int gui_x[4], gui_y[4];
   HDC hdc = hdcp;
   HPEN oldpen;
@@ -908,11 +909,12 @@
     hdc = GetDC(root_window);
   }
 
-  /* Copy the part of the overview to the right of map_overview_x0. */
-  BitBlt(hdc, overview_win_x, overview_win_y, x1, dy, x0, 0);
-
-  /* Copy the part of the overview to the left of map_overview_x0. */
-  BitBlt(hdc, overview_win_x + x1, overview_win_y, x0, dy, 0, 0);
+  /* (map_overview_x0, map_overview_y0) splits the map into four
+   * rectangles.  Draw each of these rectangles to the screen, in turn. */
+  BitBlt(hdc, overview_win_x, overview_win_y, x1, y1, x0, y0);
+  BitBlt(hdc, overview_win_x + x1, overview_win_y, x0, y1, 0, y0);
+  BitBlt(hdc, overview_win_x, overview_win_y + y1, x1, y0, x0, 0);
+  BitBlt(hdc, overview_win_x + x1, overview_win_y + y1, x0, y0, 0, 0);
 
   /* Now draw the mapview window rectangle onto the overview. */
   oldpen = SelectObject(hdc, pen_std[COLOR_STD_WHITE]);
Index: client/gui-xaw/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/mapview.c,v
retrieving revision 1.148
diff -u -r1.148 mapview.c
--- client/gui-xaw/mapview.c    2003/09/29 03:28:43     1.148
+++ client/gui-xaw/mapview.c    2003/09/29 03:52:19
@@ -431,16 +431,20 @@
 {
   int x0 = OVERVIEW_TILE_WIDTH * map_overview_x0;
   int x1 = OVERVIEW_TILE_WIDTH * (map.xsize - map_overview_x0);
-  int dy = OVERVIEW_TILE_HEIGHT * map.ysize;
+  int y0 = OVERVIEW_TILE_HEIGHT * map_overview_y0;
+  int y1 = OVERVIEW_TILE_HEIGHT * (map.ysize - map_overview_y0);
   int gui_x[4], gui_y[4], i;
 
-  /* Copy the part of the overview to the right of map_overview_x0. */
+  /* (map_overview_x0, map_overview_y0) splits the map into four
+   * rectangles.  Draw each of these rectangles to the screen, in turn. */
   XCopyArea(display, overview_canvas_store, XtWindow(overview_canvas),
-           civ_gc, x0, 0, x1, dy, 0, 0);
-
-  /* Copy the part of the overview to the left of map_overview_x0. */
+           civ_gc, x0, y0, x1, y1, 0, 0);
+  XCopyArea(display, overview_canvas_store, XtWindow(overview_canvas),
+           civ_gc, 0, y0, x0, y1, x1, 0);
+  XCopyArea(display, overview_canvas_store, XtWindow(overview_canvas),
+           civ_gc, x0, 0, x1, y0, 0, y1);
   XCopyArea(display, overview_canvas_store, XtWindow(overview_canvas),
-           civ_gc, 0, 0, x0, dy, x1, 0);
+           civ_gc, 0, 0, x0, y0, x1, y1);
 
   /* Now draw the mapview window rectangle onto the overview. */
   XSetForeground(display, civ_gc, colors_standard[COLOR_STD_WHITE]);

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#6316) y-scrolling for overview window, Jason Short <=