Clone in a terminal:
Commit aebfda5
Johan Mattsson - 2012-08-08T15:12:20+00:00
aebfda5b63dc47c69fbfc73ba6a14fe2425fdc1ajohan.mattsson.m@gmail.com

move points relative to last position instead of absolute position

Changed files (4)

Diff

diff --git a/src/EditPointHandle.vala b/src/EditPointHandle.valaindex c5c105a..6a482e7 100644--- a/src/EditPointHandle.vala+++ b/src/EditPointHandle.vala@@ -140,6 +140,13 @@ class EditPointHandle  { 		} 	} 	+	public void move_delta (double dx, double dy) {+		double px = px () + dx * Glyph.ivz ();+		double py = py () - dy * Glyph.ivz ();+		+		move_to_coordinate (px, py);+	}+	 	public void move_to (double x, double y) { 		EditPoint.to_coordinate (ref x, ref y); 		move_to_coordinate (x, y);diff --git a/src/Font.vala b/src/Font.valaindex f191507..131695c 100644--- a/src/Font.vala+++ b/src/Font.vala@@ -664,11 +664,6 @@ class Font : GLib.Object { 		double x1, x2, y1, y2;  		if (gl == null) {-			print ("no glyph a\n");-			glyph_cache.print_all ();-		}--		if (gl == null) { 			gl = get_glyph_indice (4); 		}		 		diff --git a/src/Glyph.vala b/src/Glyph.valaindex 98956bb..650bb04 100644--- a/src/Glyph.vala+++ b/src/Glyph.vala@@ -881,6 +881,18 @@ class Glyph : FontDisplay { 		move_selected_edit_point (x, y); 	} 	+	public void move_selected_edit_point_delta (double dx, double dy) +		requires (selected_point != null)+	{+		double px = ((!) selected_point).x + xc () - view_offset_x;+		double py = -1 * (((!) selected_point).y - yc () + view_offset_y);+		+		px *= view_zoom;+		py *= view_zoom;+		+		move_selected_edit_point (dx + px, dy + py);+	}+	 	public void move_selected_edit_point (double x, double y) {		 		double xc, yc, xt, yt; 		double ivz = 1 / view_zoom;diff --git a/src/PenTool.vala b/src/PenTool.valaindex 55365ee..1cde884 100644--- a/src/PenTool.vala+++ b/src/PenTool.vala@@ -38,6 +38,9 @@ class PenTool : Tool {  	private static bool move_selected_handle = false; +	private static double last_point_x = 0;+	private static double last_point_y = 0;+ 	public PenTool (string name) { 		base (name, "Edit path", 'p', CTRL); 						@@ -55,6 +58,9 @@ class PenTool : Tool { 		}); 		 		press_action.connect((self, b, x, y) => {+			last_point_x = x;+			last_point_y = y;+			 			press (b, x, y); 		}); @@ -104,22 +110,27 @@ class PenTool : Tool { 		if (move_selected_handle) { 			if (GridTool.is_visible ()) { 				GridTool.tie (ref x, ref y);+				selected_handle.set_point_type (PointType.CURVE);+				selected_handle.move_to (x, y);+			} else {+				selected_handle.set_point_type (PointType.CURVE);+				selected_handle.move_delta (x - last_point_x, y - last_point_y); 			} 			-			selected_handle.set_point_type (PointType.CURVE);-			selected_handle.move_to (x, y);-			 			selected_handle.parent.recalculate_linear_handles (); 			 			// Fixa: redraw line only 			glyph.redraw_area (0, 0, glyph.allocation.width, glyph.allocation.height);+						+			last_point_x = x;+			last_point_y = y; 			 			return; 		} 		 		// move edit point 		if (move_selected) {-			glyph.move_selected_edit_point (x, y);+			glyph.move_selected_edit_point_delta (x - last_point_x, y - last_point_y); 			ep = (!) glyph.selected_point; 			 			if (tie_x_or_y_coordinates) {@@ -138,6 +149,9 @@ class PenTool : Tool { 			 			ep.recalculate_linear_handles (); 		}+		+		last_point_x = x;+		last_point_y = y; 	} 	 	public void press (int button, int x, int y) {

Contact

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