The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Select path when a point is selected

These changes was commited to the Birdfont repository Mon, 20 Apr 2015 09:34:52 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
author Johan Mattsson <johan.mattsson.m@gmail.com>
Mon, 20 Apr 2015 09:34:52 +0000 (11:34 +0200)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Mon, 20 Apr 2015 09:35:25 +0000 (11:35 +0200)
commit d68d82d72d1b0a9109c2e86f5b1762b9df1dfb30
tree 59c2420e15b29dd7e8062b746389e2181433c670
parent 2891d01bfa333dd2a8bdece112e9445f94617093
Select path when a point is selected

libbirdfont/DrawingTools.vala
libbirdfont/PenTool.vala
--- a/libbirdfont/DrawingTools.vala +++ b/libbirdfont/DrawingTools.vala @@ -33,7 +33,9 @@ public static PointType point_type = PointType.DOUBLE_CURVE; + public static Tool add_stroke; public static SpinButton object_stroke; + Tool outline; public static MoveTool move_tool; public static PenTool pen_tool; @@ -724,7 +726,7 @@ draw_tool_modifiers.add_tool (delete_background); // add stroke to path - Tool add_stroke = new Tool ("apply_stroke", t_("Apply stroke")); + add_stroke = new Tool ("apply_stroke", t_("Apply stroke")); add_stroke.select_action.connect ((self) => { Glyph g = MainWindow.get_current_glyph (); StrokeTool.add_stroke = !StrokeTool.add_stroke; @@ -736,6 +738,7 @@ } StrokeTool.stroke_width = object_stroke.get_value (); + StrokeTool.set_stroke_for_selected_paths (StrokeTool.stroke_width); } else { foreach (Path p in g.active_paths) { p.stroke = 0; @@ -774,21 +777,11 @@ stroke_expander.add_tool (object_stroke); move_tool.selection_changed.connect (() => { - bool stroke = false; - Glyph g = MainWindow.get_current_glyph (); - - foreach (Path p in g.active_paths) { - if (p.stroke > 0) { - stroke = true; - } - } - - add_stroke.selected = stroke; - Toolbox.redraw_tool_box (); + update_stroke_settings (); }); // create outline from path - Tool outline = new Tool ("stroke_to_outline", t_("Create outline form stroke")); + outline = new Tool ("stroke_to_outline", t_("Create outline form stroke")); outline.select_action.connect ((self) => { StrokeTool.stroke_selected_paths (); outline.set_selected (false); @@ -1068,6 +1061,20 @@ update_line_selection (glyph); } }); + } + + public static void update_stroke_settings () { + bool stroke = false; + Glyph g = MainWindow.get_current_glyph (); + + foreach (Path p in g.active_paths) { + if (p.stroke > 0) { + stroke = true; + } + } + + add_stroke.selected = stroke; + Toolbox.redraw_tool_box (); } void auto_trace_background () {
--- a/libbirdfont/PenTool.vala +++ b/libbirdfont/PenTool.vala @@ -895,8 +895,7 @@ } public void select_active_point (double x, double y) { - Glyph? g = MainWindow.get_current_glyph (); - Glyph glyph = (!) g; + Glyph glyph = MainWindow.get_current_glyph (); bool reverse; control_point_event (x, y); @@ -905,7 +904,6 @@ reverse = false; foreach (Path p in glyph.path_list) { - if (p.is_open () && p.points.size >= 1 && (active_edit_point == p.points.get (0) || active_edit_point == p.points.get (p.points.size - 1))) { @@ -940,6 +938,13 @@ move_point_on_path = true; if (active_edit_point != null) { + + glyph.clear_active_paths (); + glyph.add_active_path (active_path); + + DrawingTools.update_stroke_settings (); + + if (KeyBindings.modifier == SHIFT) { if (((!)active_edit_point).is_selected () && selected_points.size > 1) { ((!)active_edit_point).set_selected (false); @@ -1134,6 +1139,9 @@ close_path (path); glyph.close_path (); force_direction (); + + glyph.clear_active_paths (); + glyph.add_active_path (path); if (direction_changed) { path.reverse (); @@ -1170,6 +1178,7 @@ glyph.delete_path (path); glyph.delete_path (merge); glyph.clear_active_paths (); + glyph.add_active_path (union); union.reopen (); union.create_list (); @@ -1344,7 +1353,7 @@ bool redraw; Glyph g = MainWindow.get_current_glyph (); - foreach (var p in g.path_list) { + foreach (Path p in g.path_list) { foreach (var ep in p.points) { ep.set_active (false); } @@ -1353,7 +1362,7 @@ redraw = active_edit_point != e; active_edit_point = e; active_path = path; - + if (e != null) { ((!)e).set_active (true); }