Clone in a terminal:
Commit 0944c30
Johan Mattsson - 2015-05-02T23:02:08+00:00
0944c302f6939692ac4dd24bdba7ec50d3c358d7johan.mattsson.m@gmail.com

Stroke for circles and rectangles

Changed files (5)

Diff

diff --git a/libbirdfont/CircleTool.vala b/libbirdfont/CircleTool.valaindex 8810dc0..2070b31 100644--- a/libbirdfont/CircleTool.vala+++ b/libbirdfont/CircleTool.vala@@ -55,16 +55,19 @@ public class CircleTool : Tool { 		double dy = last_y - y;  		double p = PenTool.precision; 		double ratio, diameter, radius, cx, cy, nx, ny;+		double xmin, xmax, ymin; 		 		if (move_circle) { 			circle.move (Glyph.ivz () * -dx * p, Glyph.ivz () * dy * p);+			circle.reset_stroke (); 		} 		 		if (resize_circle) {-			circle.update_region_boundaries ();-			diameter = circle.xmax - circle.xmin;-			cx = circle.xmin + diameter / 2;-			cy = circle.ymin + diameter / 2;+			get_boundaries (out xmin, out xmax, out ymin);+			+			diameter = xmax - xmin;+			cx = xmin + diameter / 2;+			cy = ymin + diameter / 2; 		 			radius = Path.distance_pixels (press_x, press_y, x, y); 			ratio = 2 * radius / diameter;@@ -73,14 +76,17 @@ public class CircleTool : Tool { 				circle.resize (ratio); 			} 			-			diameter = circle.xmax - circle.xmin;-			nx = circle.xmin + diameter / 2;-			ny = circle.ymin + diameter / 2;+			get_boundaries (out xmin, out xmax, out ymin);+		+			diameter = xmax - xmin;+			nx = xmin + diameter / 2;+			ny = ymin + diameter / 2; 			-			circle.update_region_boundaries (); 			circle.move (cx - nx, cy - ny); 			 			last_radius = radius;+			circle.reset_stroke ();+			circle.update_region_boundaries (); 		} 		 		last_x = x;@@ -89,6 +95,25 @@ public class CircleTool : Tool { 		GlyphCanvas.redraw (); 	} 	+	void get_boundaries (out double xmin, out double xmax, out double ymin) {+		xmin = Glyph.CANVAS_MAX;+		xmax = Glyph.CANVAS_MIN;+		ymin = Glyph.CANVAS_MAX;+		foreach (EditPoint p in circle.points) {+			if (p.x < xmin) {+				xmin = p.x;+			} ++			if (p.x > xmax) {+				xmax = p.x;+			}+			+			if (p.y < ymin) {+				ymin = p.y;+			}+		}+	}+	 	void press (int button, double x, double y) { 		Glyph glyph = MainWindow.get_current_glyph (); 		double radius = 2;@@ -119,6 +144,10 @@ public class CircleTool : Tool { 		path.close (); 		path.recalculate_linear_handles (); +		if (StrokeTool.add_stroke) {+			path.stroke = StrokeTool.stroke_width;+		}+ 		for (int i = 0; i < 3; i++) { 			foreach (EditPoint ep in path.points) { 				ep.set_tie_handle (true);diff --git a/libbirdfont/RectangleTool.vala b/libbirdfont/RectangleTool.valaindex b77d065..a7af6fe 100644--- a/libbirdfont/RectangleTool.vala+++ b/libbirdfont/RectangleTool.vala@@ -70,6 +70,10 @@ public class RectangleTool : Tool { 			rectangle.add (x2, y2); 			rectangle.add (x1, y2); +			if (StrokeTool.add_stroke) {+				rectangle.stroke = StrokeTool.stroke_width;+			}+		 			rectangle.init_point_type (); 			rectangle.close (); 			@@ -79,6 +83,9 @@ public class RectangleTool : Tool { 				e.recalculate_linear_handles (); 			} 			+			rectangle.reset_stroke ();+			rectangle.update_region_boundaries ();+			 			GlyphCanvas.redraw (); 		} 	}diff --git a/libbirdfont/ResizeTool.vala b/libbirdfont/ResizeTool.valaindex 2c04012..2aa37e6 100644--- a/libbirdfont/ResizeTool.vala+++ b/libbirdfont/ResizeTool.vala@@ -109,6 +109,8 @@ public class ResizeTool : Tool { 		}); 		 		move_action.connect ((self, x, y)	 => {+			Glyph glyph;+			 			if (resize_path && can_resize (x, y)) { 				resize (x, y); 			}@@ -118,6 +120,12 @@ public class ResizeTool : Tool { 			}  			if (move_paths || rotate_path || resize_path) {+				glyph = MainWindow.get_current_glyph ();+				+				foreach (Path selected_path in glyph.active_paths) {+					selected_path.reset_stroke ();+				}+				 				update_selection_box (); 				GlyphCanvas.redraw (); 			}@@ -150,7 +158,7 @@ public class ResizeTool : Tool { 		}); 		 		key_press_action.connect ((self, keyval) => {-			DrawingTools.move_tool.key_press (keyval);+			DrawingTools.move_tool.key_down (keyval); 		}); 	} diff --git a/libbirdfont/SettingsDisplay.vala b/libbirdfont/SettingsDisplay.valaindex 946b258..9b713e8 100644--- a/libbirdfont/SettingsDisplay.vala+++ b/libbirdfont/SettingsDisplay.vala@@ -102,7 +102,7 @@ public abstract class SettingsDisplay : FontDisplay { 	public override void key_release (uint keyval) { 		SettingsItem old_key_binding; 		-		if (!KeyBindings.is_modifier_key (keyval)) {+		if (!is_modifier_key (keyval)) { 			if (update_key_bindings) { 				if (keyval == Key.BACK_SPACE) { 					update_key_bindings = false;diff --git a/libbirdfont/StrokeTool.vala b/libbirdfont/StrokeTool.valaindex f30bd33..ebbf7bc 100644--- a/libbirdfont/StrokeTool.vala+++ b/libbirdfont/StrokeTool.vala@@ -1811,8 +1811,7 @@ public class StrokeTool : Tool { 					add_corner (side2, previous_inside, start, p2.copy (), thickness); 				} 			} else {-				print (@"l.angle + r.angle   $(l.angle) + $(r.angle)  $(fabs (l.angle + r.angle % (2 * PI) - PI) )\n");-				+				// FIXME: DELETE 				//previous.flags |= EditPoint.CURVE; 				//previous_inside.flags |= EditPoint.CURVE; 			}

Contact

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