Clone in a terminal:
Commit 232ab49
Johan Mattsson - 2013-07-12T14:27:15+00:00
232ab4936a1a57db2ed7e658e2100bd448baa6d2johan.mattsson.m@gmail.com

more grid fixes

Changed files (4)

Diff

diff --git a/libbirdfont/Glyph.vala b/libbirdfont/Glyph.valaindex 2d0e26f..281e434 100644--- a/libbirdfont/Glyph.vala+++ b/libbirdfont/Glyph.vala@@ -1390,7 +1390,7 @@ public class Glyph : FontDisplay { 		cr.save (); 		draw_background_color (cr, 1); 		cr.restore ();-+		 		if (background_image != null && background_image_visible) { 			((!)background_image).draw (cr, allocation, view_offset_x, view_offset_y, view_zoom); 		}diff --git a/libbirdfont/GridTool.vala b/libbirdfont/GridTool.valaindex 6bcd5de..34b215f 100644--- a/libbirdfont/GridTool.vala+++ b/libbirdfont/GridTool.vala@@ -176,7 +176,7 @@ class GridTool : Tool { 			ypos.move_line_to (x, y, g.allocation); 		} else { 			xpos = new Line ("", x, Line.VERTICAL);-			ypos = new Line ("", y, Line.HORIZONTAL);+			ypos = new Line ("", -y, Line.HORIZONTAL); 		}  		m = double.MAX;@@ -204,13 +204,17 @@ class GridTool : Tool { 		 		if (!coordinate) { 			x = Glyph.reverse_path_coordinate_x (xmin.get_pos ());-			y = Glyph.reverse_path_coordinate_y (-ymin.get_pos ());+			y = Glyph.reverse_path_coordinate_y (ymin.get_pos ()); 		} else { 			x = xmin.get_pos ();-			y = ymin.get_pos ();+			y = -ymin.get_pos (); 		} 	} +	public static void set_visible (bool v) {+		visible = v;+	}+	 	public static bool is_visible () { 		return visible; 	}diff --git a/libbirdfont/Line.vala b/libbirdfont/Line.valaindex 08e3ba7..1bbd12f 100644--- a/libbirdfont/Line.vala+++ b/libbirdfont/Line.vala@@ -160,7 +160,7 @@ public class Line : GLib.Object { 			swap_lines (); 		} -		if (is_vertical ()) {+		if (is_vertical ()) { // over line handle y 			if (ay > g.allocation.height - 10) { 				 				p = get_coordinate ();@@ -175,7 +175,7 @@ public class Line : GLib.Object {  			set_active (a); 			-		} else {+		} else { // over line handle x 			if (ax > g.allocation.width - 10) { 				p = get_coordinate (); 				c = ay * ivz + g.view_offset_y;diff --git a/libbirdfont/PenTool.vala b/libbirdfont/PenTool.valaindex 0dfbda4..1eb99e8 100644--- a/libbirdfont/PenTool.vala+++ b/libbirdfont/PenTool.vala@@ -45,6 +45,8 @@ public class PenTool : Tool { 	public static double precision = 1; 	private static ImageSurface? tie_icon = null; 	+	/** First move action must move the current point in to the grid. */+	bool first_move_action = false; 	 	/** Move curve handle instead of control point. */ 	private bool last_selected_is_handle = false;@@ -76,6 +78,8 @@ public class PenTool : Tool { 		}); 		 		press_action.connect ((self, b, x, y) => {+			first_move_action = true;+			 			if (GridTool.is_visible ()) { 				tie_pixels (ref x, ref y); 			}@@ -162,7 +166,7 @@ public class PenTool : Tool { 		double coordinate_x, coordinate_y; 		double px = 0; 		double py = 0;-		+	 		control_point_event (x, y); 		curve_active_corner_event (x, y); 		set_default_handle_positions ();@@ -684,6 +688,19 @@ public class PenTool : Tool {  		if (distance < CONTACT_SURFACE) { 			set_active_edit_point (ep);+			+			if (first_move_action && GridTool.is_visible () && move_selected) {+				double coordinate_x = e.x;+				double coordinate_y = e.y;+				GridTool.tie_coordinate (ref coordinate_x, ref coordinate_y);+				int px = Glyph.reverse_path_coordinate_x (coordinate_x);+				int py = Glyph.reverse_path_coordinate_y (coordinate_y);+				+				last_point_x += Glyph.reverse_path_coordinate_x (e.x) - px;+				last_point_y += Glyph.reverse_path_coordinate_y (e.y) - py;+				+				first_move_action = false;+			} 		} 	} 	

Contact

Email: johan.mattsson.m@gmail.com
Mastodon: typo.social/@birdfont
GitHub: johanmattssonm
LinkedIn: johan-mattsson-2ab324112