Clone in a terminal:
Commit 0d22cd5
Johan Mattsson - 2012-07-13T12:16:43+00:00
0d22cd57ee67c378b021f363ee2091c90a7a256bjohan.mattsson.m@gmail.com

recalculate linear handles

Changed files (3)

Diff

diff --git a/src/EditPoint.vala b/src/EditPoint.valaindex 527f3d5..d90b32d 100644--- a/src/EditPoint.vala+++ b/src/EditPoint.vala@@ -99,6 +99,37 @@ class EditPoint { 		}		 	} 	+	/** Set bezier points for linear paths. */+	public void recalculate_linear_handles () {+		EditPointHandle h;+		unowned EditPoint n;+		double nx, ny;+		+		return_if_fail (type == PointType.LINE);++		// left handle+		if (prev != null) {+			n = get_prev ().data;+			h = get_left_handle ();+			+			nx = x + ((n.x - x) / 3);+			ny = y + ((n.y - y) / 3);+			+			h.move_to_coordinate (nx, ny);	+		}+		+		// right handle+		if (next != null) {+			n = get_next ().data;+			h = get_right_handle ();+			+			nx = x + ((n.x - x) / 3);+			ny = y + ((n.y - y) / 3);+			+			h.move_to_coordinate (nx, ny);+		}+	}+	 	public void set_tie_handle (bool t) { 		tie_handles = t; 	}diff --git a/src/Path.vala b/src/Path.valaindex 3122e36..c119d32 100644--- a/src/Path.vala+++ b/src/Path.vala@@ -859,7 +859,7 @@ class Path { 			ymin = 0;			 		} -		// inside and outside in vala lambda functions is not intuitive+		// inside and outside in vala lambda functions is a tricky matter 		// (look at c code). that's the reason for the !new_val expression  		xmax = -10000;diff --git a/src/PenTool.vala b/src/PenTool.valaindex 58d6cfd..d5a2ae4 100644--- a/src/PenTool.vala+++ b/src/PenTool.vala@@ -82,6 +82,7 @@ class PenTool : Tool { 		 	public void move (double x, double y) { 		Glyph glyph = MainWindow.get_current_glyph ();+		EditPoint ep; 		 		control_point_event (x, y); @@ -116,11 +117,10 @@ class PenTool : Tool { 		// move edit point 		if (move_selected) { 			glyph.move_selected_edit_point (x, y);+			ep = (!) glyph.selected_point; 			 			if (tie_x_or_y_coordinates) { 				return_if_fail (glyph.selected_point != null);-				-				EditPoint ep = (!) glyph.selected_point; 				GridTool.tie_to_prev (ep, x, y); 			} 			@@ -132,6 +132,10 @@ class PenTool : Tool { 				active_corner = (!) active_edit_point; 				active_corner.set_active_handle (true); 			}+			+			if (ep.type == PointType.LINE) {+				ep.recalculate_linear_handles ();+			} 		} 	} 	@@ -366,25 +370,7 @@ class PenTool : Tool { 		 		foreach (EditPoint e in path.points) { 			if (e.type == PointType.LINE) {-				n = e.get_next ().data;-				h = e.get_right_handle ();-				-				nx = e.x + ((n.x - e.x) / 3);-				ny = e.y + ((n.y - e.y) / 3);-				-				h.move_to_coordinate (nx, ny);-			}-		}-		-		foreach (EditPoint e in path.points) {-			if (e.type == PointType.LINE) {-				n = e.get_prev ().data;-				h = e.get_left_handle ();-				-				nx = e.x + ((n.x - e.x) / 3);-				ny = e.y + ((n.y - e.y) / 3);-				-				h.move_to_coordinate (nx, ny);+				e.recalculate_linear_handles (); 			} 		} 	}

Contact

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