Clone in a terminal:
Commit cdf97ad
Johan Mattsson - 2015-05-01T06:50:54+00:00
cdf97ad7d8b88b61568cb1a8790d9027167faab3johan.mattsson.m@gmail.com

Update freehand drawing to work with stroke

Changed files (4)

Diff

diff --git a/libbirdfont/ForesightTool.vala b/libbirdfont/ForesightTool.valaindex d0496d4..6a35c05 100644--- a/libbirdfont/ForesightTool.vala+++ b/libbirdfont/ForesightTool.vala@@ -160,14 +160,6 @@ public class ForesightTool : Tool { 				}  			} 		});-		-		double_click_action.connect ((self, b, x, y) => {-			Tool p = PointTool.pen ();-			-			if (!BirdFont.android) {-				p.double_click_action (p, b, x, y);-			}-		});  		release_action.connect ((self, b, x, y) => { 			PenTool p = (PenTool) PointTool.pen ();diff --git a/libbirdfont/Path.vala b/libbirdfont/Path.valaindex 040f428..6a7c489 100644--- a/libbirdfont/Path.vala+++ b/libbirdfont/Path.vala@@ -1469,6 +1469,9 @@ public class Path { 		} else if (right == PointType.CUBIC && left == PointType.CUBIC) { 			x = bezier_path (step, start.x, start.get_right_handle ().x, stop.get_left_handle ().x, stop.x); 			y = bezier_path (step, start.y, start.get_right_handle ().y, stop.get_left_handle ().y, stop.y);	+		} else if (right == PointType.HIDDEN && left == PointType.HIDDEN) {+			x = bezier_path (step, start.x, start.get_right_handle ().x, stop.get_left_handle ().x, stop.x);+			y = bezier_path (step, start.y, start.get_right_handle ().y, stop.get_left_handle ().y, stop.y);	 		} else { 			warning (@"Mixed point types in segment $(start.x),$(start.y) to $(stop.x),$(stop.y) right: $(right), left: $(left) (start: $(start.type), stop: $(stop.type))"); 			x = bezier_path (step, start.x, start.get_right_handle ().x, stop.get_left_handle ().x, stop.x);diff --git a/libbirdfont/PenTool.vala b/libbirdfont/PenTool.valaindex 8f7b8fd..29a9a20 100644--- a/libbirdfont/PenTool.vala+++ b/libbirdfont/PenTool.vala@@ -138,7 +138,6 @@ public class PenTool : Tool { 		double_click_action.connect ((self, b, x, y) => { 			last_point_x = Glyph.path_coordinate_x (x); 			last_point_y = Glyph.path_coordinate_y (y);- 			press (b, x, y, true); 		}); diff --git a/libbirdfont/TrackTool.vala b/libbirdfont/TrackTool.valaindex 61a4e46..052a8e8 100644--- a/libbirdfont/TrackTool.vala+++ b/libbirdfont/TrackTool.vala@@ -51,6 +51,7 @@ public class TrackTool : Tool {  	/** Adjust the number of samples per point by this factor. */ 	double samples_per_point = 1;+	bool drawing = false;  	public TrackTool (string name) { 		string sw;@@ -72,6 +73,8 @@ public class TrackTool : Tool { 			} 			 			if (button == 1) {+				return_if_fail (!drawing);+				 				draw_freehand = true; 				 				last_x = x;@@ -96,13 +99,14 @@ public class TrackTool : Tool { 					glyph.add_path (p); 					glyph.open_path (); 					-					PenTool.add_new_edit_point (x, y).point;+					PenTool.add_new_edit_point (x, y); 				}  				glyph.update_view ();				 				added_points = 0; 				last_update = get_current_time (); 				start_update_timer ();+				drawing = true; 			} 		}); 		@@ -111,14 +115,17 @@ public class TrackTool : Tool {  		release_action.connect ((self, button, x, y) => { 			if (button == 1 && draw_freehand) {+				return_if_fail (drawing); 				add_endpoint_and_merge (x, y); 			} 			-			set_tie ();+			convert_points_to_line ();+			MainWindow.get_current_glyph ().clear_active_paths (); 			+			set_tie (); 			PenTool.force_direction (); -			 			BirdFont.get_current_font ().touch ();+			drawing = false; 		});  		move_action.connect ((self, x, y) => {@@ -334,12 +341,12 @@ public class TrackTool : Tool { 	 		glyph = MainWindow.get_current_glyph (); 		-		if (glyph.path_list.size == 0) {+		if (glyph.active_paths.size == 0) { 			warning ("No path."); 			return; 		} 		-		p = glyph.path_list.get (glyph.path_list.size - 1);+		p = glyph.active_paths.get (glyph.active_paths.size - 1); 		p.reopen (); 		px = Glyph.path_coordinate_x (x); 		py = Glyph.path_coordinate_y (y);@@ -363,12 +370,11 @@ public class TrackTool : Tool { 		TimeoutSource timer = new TimeoutSource (100);  		timer.set_callback (() => {-			 			if (draw_freehand) { 				record_new_position (last_x, last_y); 				convert_on_timeout (); 			}-			+					 			return draw_freehand; 		}); @@ -420,12 +426,12 @@ public class TrackTool : Tool { 	Path get_active_path () { 		Glyph glyph = MainWindow.get_current_glyph (); 		-		if (glyph.path_list.size == 0) {+		if (glyph.active_paths.size == 0) { 			warning ("No path."); 			return new Path (); 		} 			-		return glyph.path_list.get (glyph.path_list.size - 1);		+		return glyph.active_paths.get (glyph.active_paths.size - 1);		 	} 	 	/** Delete all points close to the pixel at x,y. */

Contact

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