Hi all,

using the GTK HID of PCB users experience an annoying bug when pressing
the tab: when the board is flipped (SwapSides()), the view jumps away
showing a different location of the board on thje other side. The attached
patch fixes this.

I am not sure about indenting, the source seems to use mixed tab/space. I
used tabs. Are indentation clenaup patches welcome?

Regards,

Igor2
Index: gtkhid-main.c
===================================================================
RCS file: /cvsroot/pcb/pcb/src/hid/gtk/gtkhid-main.c,v
retrieving revision 1.53
diff -U3 -p -r1.53 gtkhid-main.c
--- gtkhid-main.c	8 Jan 2008 00:50:27 -0000	1.53
+++ gtkhid-main.c	11 Jan 2008 05:26:22 -0000
@@ -1911,7 +1911,9 @@ side'' of the board.
 static int
 SwapSides (int argc, char **argv, int x, int y)
 {
-  gint dx;
+  gint flipd;
+	int do_flip_x = 0;
+	int do_flip_y = 0;
   int comp_group = GetLayerGroupNumberByNumber (max_layer + COMPONENT_LAYER);
   int solder_group = GetLayerGroupNumberByNumber (max_layer + SOLDER_LAYER);
   int active_group = GetLayerGroupNumberByNumber (LayerStack[0]);
@@ -1927,15 +1929,19 @@ SwapSides (int argc, char **argv, int x,
       case 'h':
       case 'H':
 	ghid_flip_x = ! ghid_flip_x;
+	do_flip_x = 1;
 	break;
       case 'v':
       case 'V':
 	ghid_flip_y = ! ghid_flip_y;
+	do_flip_y = 1;
 	break;
       case 'r':
       case 'R':
 	ghid_flip_x = ! ghid_flip_x;
 	ghid_flip_y = ! ghid_flip_y;
+	do_flip_x = 1;
+	do_flip_y = 1;
 	break;
       default:
 	return 1;
@@ -1966,10 +1972,19 @@ SwapSides (int argc, char **argv, int x,
 	}
     }
 
-  /* what does this do? */
-  dx = PCB->MaxWidth / 2 - gport->view_x;
-  ghid_port_ranges_pan (2 * dx, 0, TRUE);
-
+  /* Update coordinates so that the current location stays where it was on the
+	   other side; we need to do this since the actual flip center is the
+		 center of the board while the user expect the center would be the current
+		 location */
+	if (do_flip_x) {
+		flipd = PCB->MaxWidth / 2 - gport->view_x;
+		ghid_port_ranges_pan (2 * flipd, 0, TRUE);
+	}
+	if (do_flip_y) {
+		flipd = PCB->MaxHeight / 2 - gport->view_y;
+		ghid_port_ranges_pan (0, 2 * flipd, TRUE);
+	}
+	
   ghid_invalidate_all ();
   return 0;
 }

_______________________________________________
geda-dev mailing list
[email protected]
http://www.seul.org/cgi-bin/mailman/listinfo/geda-dev

Reply via email to