Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2004:
[Freeciv-Dev] Re: (PR#7384) Vertical scroll zigzag in iso mode.
Home

[Freeciv-Dev] Re: (PR#7384) Vertical scroll zigzag in iso mode.

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Gregory.Berkolaiko@xxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#7384) Vertical scroll zigzag in iso mode.
From: "Jason Dorje Short" <jdorje@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 6 Feb 2004 13:22:00 -0800
Reply-to: rt@xxxxxxxxxxx

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

Gregory Berkolaiko wrote:
> <URL: http://rt.freeciv.org/Ticket/Display.html?id=7384 >
> 
> Set topo to >= 4.
> tiles to isotrident (I guess this is irrelevant).
> 
> Scroll vertically, using either the bar or the arrow buttons.  View 
> zigzags unpleasantly.

Yep.

This is somewhat related to the bug whereby iso-view scrolling on an 
orthogonal map or orthogonal-view scrolling on an iso-map sucks.

> A hack which sets the scroll step to 2 and cures zigzaging is attached.  
> It's is not good, but probably a step in the right direction.

Sort of.

First, the correct check is topo_has_flag(TF_ISO), not is_isometric. 
This problem occurs because the X direction is compressed but the Y 
direction isn't in iso-maps.

The attached patch is a bit better: it introduces a function 
get_mapview_scroll_step.  This at least hides the implementation in 
mapview_common rather than putting it in mapview.  It also (untested) 
supports gui-gtk and gui-xaw (I couldn't see any useful changes to make 
to gui-win32, and gui-sdl doesn't support scrolling).

Unfortunately this is still very lacking.  A more complicated problem is 
that the changes you make to set_mapview_scroll_pos introduce an even 
bigger bug: you can't center on all tiles.  Under your patch, in 
iso-view on an iso-map center on a tile.  Now try centering on the tile 
to the southeast (down-right) of this tile.  You can't do it: the scroll 
bar does a "jumpback" and it's ugly.

In my patch I "solve" this by removing the changes to 
set_mapview_scroll_pos.  But this means that you'll still get the zigzag 
behavior if you click-and-drag on the scrollbar.  Very ugly.

Fundamentally there is no way to fix this problem while scroll 
coordinates are equivalent to native coordinates.  What we have to do to 
get it to work is have scroll coordinates be _natural_ _gui_ coordinates 
(either at the tile or the canvas level).  However the math on this 
becomes very complicated.

I do believe this patch is a step in the right direction, because it 
does unify the logic into mapview_common.  It should therefore be 
possible to fix scrolling changing only this file.

jason

Index: client/mapview_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.c,v
retrieving revision 1.74
diff -u -r1.74 mapview_common.c
--- client/mapview_common.c     2004/02/03 20:16:07     1.74
+++ client/mapview_common.c     2004/02/06 21:18:25
@@ -476,6 +476,16 @@
 }
 
 /****************************************************************************
+  Find the scroll step for the mapview.  This is the amount to scroll (in
+  scroll coordinates) on each "step".  See also get_mapview_scroll_window.
+****************************************************************************/
+void get_mapview_scroll_step(int *xstep, int *ystep)
+{
+  *xstep = 1;
+  *ystep = (topo_has_flag(TF_ISO) ? 2 : 1);
+}
+
+/****************************************************************************
   Find the current scroll position (origin) of the mapview.
 ****************************************************************************/
 void get_mapview_scroll_pos(int *scroll_x, int *scroll_y)
Index: client/mapview_common.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.h,v
retrieving revision 1.40
diff -u -r1.40 mapview_common.h
--- client/mapview_common.h     2004/02/03 20:16:07     1.40
+++ client/mapview_common.h     2004/02/06 21:18:25
@@ -149,6 +149,7 @@
 void get_mapview_scroll_window(int *xmin, int *ymin,
                               int *xmax, int *ymax,
                               int *xsize, int *ysize);
+void get_mapview_scroll_step(int *xstep, int *ystep);
 void get_mapview_scroll_pos(int *scroll_x, int *scroll_y);
 void set_mapview_scroll_pos(int scroll_x, int scroll_y);
 
Index: client/gui-gtk/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/mapview.c,v
retrieving revision 1.191
diff -u -r1.191 mapview.c
--- client/gui-gtk/mapview.c    2004/02/05 20:20:27     1.191
+++ client/gui-gtk/mapview.c    2004/02/06 21:18:26
@@ -1130,12 +1130,13 @@
 **************************************************************************/
 void update_map_canvas_scrollbars_size(void)
 {
-  int xmin, ymin, xmax, ymax, xsize, ysize;
+  int xmin, ymin, xmax, ymax, xsize, ysize, xstep, ystep;
 
   get_mapview_scroll_window(&xmin, &ymin, &xmax, &ymax, &xsize, &ysize);
+  get_mapview_scroll_step(&xstep, &ystep);
 
-  map_hadj = gtk_adjustment_new(-1, xmin, xmax, 1, xsize, xsize);
-  map_vadj = gtk_adjustment_new(-1, ymin, ymax, 1, ysize, ysize);
+  map_hadj = gtk_adjustment_new(-1, xmin, xmax, xstep, xsize, xsize);
+  map_vadj = gtk_adjustment_new(-1, ymin, ymax, ystep, ysize, ysize);
 
   gtk_range_set_adjustment(GTK_RANGE(map_horizontal_scrollbar),
        GTK_ADJUSTMENT(map_hadj));
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.91
diff -u -r1.91 mapview.c
--- client/gui-gtk-2.0/mapview.c        2004/02/05 20:20:27     1.91
+++ client/gui-gtk-2.0/mapview.c        2004/02/06 21:18:26
@@ -1207,12 +1207,13 @@
 **************************************************************************/
 void update_map_canvas_scrollbars_size(void)
 {
-  int xmin, ymin, xmax, ymax, xsize, ysize;
+  int xmin, ymin, xmax, ymax, xsize, ysize, xstep, ystep;
 
   get_mapview_scroll_window(&xmin, &ymin, &xmax, &ymax, &xsize, &ysize);
+  get_mapview_scroll_step(&xstep, &ystep);
 
-  map_hadj = gtk_adjustment_new(-1, xmin, xmax, 1, xsize, xsize);
-  map_vadj = gtk_adjustment_new(-1, ymin, ymax, 1, ysize, ysize);
+  map_hadj = gtk_adjustment_new(-1, xmin, xmax, xstep, xsize, xsize);
+  map_vadj = gtk_adjustment_new(-1, ymin, ymax, ystep, ysize, ysize);
 
   gtk_range_set_adjustment(GTK_RANGE(map_horizontal_scrollbar),
        GTK_ADJUSTMENT(map_hadj));
Index: client/gui-xaw/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/mapview.c,v
retrieving revision 1.155
diff -u -r1.155 mapview.c
--- client/gui-xaw/mapview.c    2004/02/03 20:16:08     1.155
+++ client/gui-xaw/mapview.c    2004/02/06 21:18:26
@@ -1002,9 +1002,10 @@
                             XtPointer position_val)
 {
   int position = XTPOINTER_TO_INT(position_val);
-  int scroll_x, scroll_y;
+  int scroll_x, scroll_y, xstep, ystep;
 
   get_mapview_scroll_pos(&scroll_x, &scroll_y);
+  get_mapview_scroll_ste(&xstep, &ystep);
 
   if (!can_client_change_view()) {
     return;
@@ -1012,16 +1013,16 @@
 
   if(w==map_horizontal_scrollbar) {
     if (position > 0) {
-      scroll_x++;
+      scroll_x += xstep;
     } else {
-      scroll_x--;
+      scroll_x -= xstep;
     }
   }
   else {
     if (position > 0) {
-      scroll_y++;
+      scroll_y += ystep;
     } else {
-      scroll_y--;
+      scroll_y -= ystep;
     }
   }
 

[Prev in Thread] Current Thread [Next in Thread]