Commit 0944c30
Stroke for circles and rectangles
Changed files (5)
modifiedlibbirdfont/CircleTool.valamodifiedlibbirdfont/RectangleTool.valamodifiedlibbirdfont/ResizeTool.valamodifiedlibbirdfont/SettingsDisplay.valamodifiedlibbirdfont/StrokeTool.vala
Diff
@@ -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);@@ -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 (); } }@@ -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); }); } @@ -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;@@ -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; }