The Birdfont Source Code


All Repositories / birdfont.git / commitdiff – RSS feed

Add points with pen tool

These changes was commited to the Birdfont repository Sat, 09 May 2015 15:53:22 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
[Sat, 09 May 2015 15:53:22 +0000]

Updated Files

libbirdfont/Glyph.vala
libbirdfont/MoveTool.vala
libbirdfont/PenTool.vala
libbirdfont/ResizeTool.vala
--- a/libbirdfont/Glyph.vala +++ b/libbirdfont/Glyph.vala @@ -903,13 +903,6 @@ p.reopen (); clear_active_paths (); add_active_path (p); - } - - /** Insert new edit point for current path on the appropriate zoom - * level. - */ - public PointSelection add_new_edit_point (int x, int y) { - return insert_edit_point (x, y); } /** Move view port centrum to this coordinate. */ @@ -1137,50 +1130,6 @@ } return min_point; - } - - private PointSelection insert_edit_point (double x, double y) { - double xt, yt; - Path np; - EditPoint inserted; - bool stroke = StrokeTool.add_stroke; - - if (active_paths.size == 0) { - np = new Path (); - path_list.add (np); - np.stroke = stroke ? StrokeTool.stroke_width : 0; - add_active_path (np); - PenTool.active_path = np; - } - - xt = path_coordinate_x (x); - yt = path_coordinate_y (y); - - return_val_if_fail (active_paths.size > 0, new PointSelection.empty ()); - - if (PenTool.active_path.is_open ()) { - np = PenTool.active_path; - np.add (xt, yt); - } else { - np = new Path (); - np.stroke = stroke ? StrokeTool.stroke_width : 0; - path_list.add (np); - np.add (xt, yt); - - if (DrawingTools.pen_tool.is_selected ()) { - np.set_stroke (PenTool.path_stroke_width); - } - - PenTool.active_path = np; - } - - clear_active_paths (); - add_active_path (np); - PenTool.active_path = np; - - inserted = np.points.get (np.points.size - 1); - - return new PointSelection (inserted, np); } public void move_selected_edit_point_coordinates (EditPoint selected_point, double xt, double yt) {
--- a/libbirdfont/MoveTool.vala +++ b/libbirdfont/MoveTool.vala @@ -154,6 +154,10 @@ selection_changed (); objects_moved (); DrawingTools.resize_tool.signal_objects_rotated (); + + foreach (Path p in glyph.active_paths) { + p.get_stroke (); + } } else { objects_deselected (); }
--- a/libbirdfont/PenTool.vala +++ b/libbirdfont/PenTool.vala @@ -45,6 +45,7 @@ public static Path active_path; public static EditPoint selected_point; + public static Path selected_path; public static double last_point_x = 0; public static double last_point_y = 0; @@ -88,6 +89,7 @@ active_edit_point = new EditPoint (); active_path = new Path (); + selected_path = new Path (); selected_point = new EditPoint (); clockwise = new Gee.ArrayList<Path> (); @@ -143,12 +145,8 @@ double_click_action.connect ((self, b, x, y) => { last_point_x = Glyph.path_coordinate_x (x); last_point_y = Glyph.path_coordinate_y (y); - - if (!move_selected_handle && !move_selected) { - press (b, x, y, true); - } else { - warning ("double click suppressed"); - } + + press (b, x, y, true); }); release_action.connect ((self, b, ix, iy) => { @@ -852,6 +850,7 @@ selected.point.y + delta_coordinate_y); } + selected.path.reset_stroke (); selected.point.recalculate_linear_handles (); selected.path.update_region_boundaries (); } @@ -885,7 +884,8 @@ selected.point.set_position (selected.point.x + delta_coordinate_x, selected.point.y + delta_coordinate_y); } - + + selected.path.reset_stroke (); selected.point.recalculate_linear_handles (); selected.path.update_region_boundaries (); } @@ -920,6 +920,7 @@ } selected.point.recalculate_linear_handles (); + selected.path.reset_stroke (); selected.path.update_region_boundaries (); } } @@ -937,7 +938,7 @@ last_point_x = Glyph.path_coordinate_x (x); last_point_y = Glyph.path_coordinate_y (y); } - + GlyphCanvas.redraw (); } @@ -990,6 +991,7 @@ } if (button == 3) { + selected_path = active_path; move_point_event (x, y); // alt+click on a handle ends the symmetrical editing @@ -1625,7 +1627,8 @@ redraw = active_edit_point != e; active_edit_point = e; - + active_path = path; + if (e != null) { ((!)e).set_active (true); } @@ -1732,9 +1735,7 @@ Glyph glyph; PointSelection new_point; - glyph = MainWindow.get_current_glyph (); - - new_point = glyph.add_new_edit_point (x, y); + new_point = insert_edit_point (x, y); new_point.path.update_region_boundaries (); if (new_point.path.is_open () && new_point.path.points.size > 0) { @@ -1756,6 +1757,52 @@ return new_point; } + private static PointSelection insert_edit_point (double x, double y) { + double xt, yt; + Path np; + EditPoint inserted; + bool stroke = StrokeTool.add_stroke; + Glyph g = MainWindow.get_current_glyph (); + + if (g.active_paths.size == 0) { + np = new Path (); + g.add_path (np); + np.stroke = stroke ? StrokeTool.stroke_width : 0; + g.add_active_path (np); + + active_path = np; + selected_path = np; + } + + xt = Glyph.path_coordinate_x (x); + yt = Glyph.path_coordinate_y (y); + + if (selected_path.is_open ()) { + np = PenTool.selected_path; + np.add (xt, yt); + } else { + np = new Path (); + np.stroke = stroke ? StrokeTool.stroke_width : 0; + g.add_path (np); + np.add (xt, yt); + + if (DrawingTools.pen_tool.is_selected ()) { + np.set_stroke (PenTool.path_stroke_width); + } + + PenTool.active_path = np; + } + + g.clear_active_paths (); + g.add_active_path (np); + active_path = np; + selected_path = np; + + inserted = np.points.get (np.points.size - 1); + + return new PointSelection (inserted, np); + } + static void set_point_type (EditPoint p) { if (p.prev != null && p.get_prev ().right_handle.type == PointType.QUADRATIC) { p.left_handle.type = PointType.QUADRATIC;
--- a/libbirdfont/ResizeTool.vala +++ b/libbirdfont/ResizeTool.vala @@ -106,6 +106,10 @@ DrawingTools.move_tool.release (b, x, y); update_selection_box (); GlyphCanvas.redraw (); + + foreach (Path p in MainWindow.get_current_glyph ().active_paths) { + p.get_stroke (); + } }); move_action.connect ((self, x, y) => {