Complete.Org: Mailing Lists: Archives: freeciv-dev: April 2004:
[Freeciv-Dev] Re: (PR#8603) faster mapview scrolling
Home

[Freeciv-Dev] Re: (PR#8603) faster mapview scrolling

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] Re: (PR#8603) faster mapview scrolling
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 27 Apr 2004 18:06:25 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=8603 >

Here's an updated patch.  There are no changes, but it's much smaller 
now.  It's still not ready to be applied because of the issues I 
mentioned before.

Raimar: please test this with gui-fs's grab-and-drag scrolling mechanism.

jason

Index: client/mapview_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.c,v
retrieving revision 1.110
diff -u -r1.110 mapview_common.c
--- client/mapview_common.c     28 Apr 2004 00:54:24 -0000      1.110
+++ client/mapview_common.c     28 Apr 2004 00:59:54 -0000
@@ -390,13 +390,59 @@
   /* Then update everything. */
   if (mapview_canvas.gui_x0 != gui_x0 || mapview_canvas.gui_y0 != gui_y0) {
     int map_center_x, map_center_y;
+    int old_gui_x0 = mapview_canvas.gui_x0;
+    int old_gui_y0 = mapview_canvas.gui_y0;
+    const int width = mapview_canvas.width, height = mapview_canvas.height;
+    int common_x0, common_x1, common_y0, common_y1;
+    int update_x0, update_x1, update_y0, update_y1;
 
     mapview_canvas.gui_x0 = gui_x0;
     mapview_canvas.gui_y0 = gui_y0;
 
+    common_x0 = MAX(old_gui_x0, gui_x0);
+    common_x1 = MIN(old_gui_x0, gui_x0) + width;
+    common_y0 = MAX(old_gui_y0, gui_y0);
+    common_y1 = MIN(old_gui_y0, gui_y0) + height;
+
+    if (common_x1 > common_x0 && common_y1 > common_y0) {
+      /* Do a partial redraw only. */
+
+      if (old_gui_x0 < gui_x0) {
+       update_x0 = MAX(old_gui_x0 + width, gui_x0);
+       update_x1 = gui_x0 + width;
+      } else {
+       update_x0 = gui_x0;
+       update_x1 = MIN(old_gui_x0, gui_x0 + width);
+      }
+      if (old_gui_y0 < gui_y0) {
+       update_y0 = MAX(old_gui_y0 + height, gui_y0);
+       update_y1 = gui_y0 + height;
+      } else {
+       update_y0 = gui_y0;
+       update_y1 = MIN(old_gui_y0, gui_y0 + height);
+      }
+
+      dirty_all();
+      canvas_copy(mapview_canvas.store, mapview_canvas.store,
+                 common_x0 - old_gui_x0,
+                 common_y0 - old_gui_y0,
+                 common_x0 - gui_x0, common_y0 - gui_y0,
+                 common_x1 - common_x0, common_y1 - common_y0);
+      if (update_y1 > update_y0) {
+       update_map_canvas(0, update_y0 - gui_y0,
+                         width, update_y1 - update_y0);
+      }
+      if (update_x1 > update_x0) {
+       update_map_canvas(update_x0 - gui_x0, common_y0 - gui_y0,
+                         update_x1 - update_x0, common_y1 - common_y0);
+      }
+      show_city_descriptions();
+    } else {
+      update_map_canvas_visible();
+    }
+
     get_center_tile_mapcanvas(&map_center_x, &map_center_y);
     center_tile_overviewcanvas(map_center_x, map_center_y);
-    update_map_canvas_visible();
     update_map_canvas_scrollbars();
     if (hover_state == HOVER_GOTO || hover_state == HOVER_PATROL) {
       create_line_at_mouse_pos();

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] Re: (PR#8603) faster mapview scrolling, Jason Short <=