Commit ebae91c
Replace path list with layers
Changed files (19)
modifiedlibbirdfont/BezierTool.valamodifiedlibbirdfont/BirdFontFile.valamodifiedlibbirdfont/ClipTool.valamodifiedlibbirdfont/DrawingTools.valamodifiedlibbirdfont/ExportTool.valamodifiedlibbirdfont/Font.valamodifiedlibbirdfont/Glyph.valamodifiedlibbirdfont/Layer.valamodifiedlibbirdfont/LayerLabel.valamodifiedlibbirdfont/MenuTab.valamodifiedlibbirdfont/MoveTool.valamodifiedlibbirdfont/OpenFontFormat/GlyfTable.valamodifiedlibbirdfont/PathList.valamodifiedlibbirdfont/PenTool.valamodifiedlibbirdfont/Renderer/Text.valamodifiedlibbirdfont/StrokeTool.valamodifiedlibbirdfont/Svg.valamodifiedlibbirdfont/TestCases.valamodifiedlibbirdfont/TrackTool.vala
Diff
@@ -263,7 +263,7 @@ public class BezierTool : Tool { g.close_path (); MainWindow.set_cursor (NativeWindow.VISIBLE); - if (Path.is_counter (g.get_paths (), current_path)) {+ if (Path.is_counter (g.get_visible_path_list (), current_path)) { current_path.force_direction (Direction.COUNTER_CLOCKWISE); } else { current_path.force_direction (Direction.CLOCKWISE);@@ -386,7 +386,8 @@ class BirdFontFile : GLib.Object { string data; os.put_string (@"\t<glyph id=\"$(g.version_id)\" left=\"$(double_to_string (g.left_limit))\" right=\"$(double_to_string (g.right_limit))\">\n");- foreach (Path p in g.path_list) {+ // FIXME: save layers+ foreach (Path p in g.get_all_paths ()) { data = get_point_data (p); if (data != "") { os.put_string (@"\t\t<path ");@@ -1209,7 +1210,8 @@ class BirdFontFile : GLib.Object { } } - foreach (Path p in glyph.path_list) {+ // FIXME: save layers+ foreach (Path p in glyph.get_all_paths ()) { p.reset_stroke (); } @@ -197,7 +197,7 @@ public class ClipTool : Tool { s.append (@"$(gc.get_current ().right_limit)"); s.append ("\n"); - foreach (Path path in gc.get_current ().path_list) {+ foreach (Path path in gc.get_current ().get_all_paths ()) { s.append ("BF path: "); s.append (BirdFontFile.get_point_data (path)); s.append ("\n");@@ -233,7 +233,7 @@ public class ClipTool : Tool { s.append ("\n"); if (!selected) {- foreach (Path path in glyph.path_list) {+ foreach (Path path in glyph.get_all_paths ()) { s.append ("BF path: "); s.append (BirdFontFile.get_point_data (path)); s.append ("\n");@@ -248,7 +248,7 @@ public class ClipTool : Tool { s.append ("BF cap: square\n"); } }- } else if (glyph.path_list.size > 0) {+ } else if (glyph.get_all_paths ().size > 0) { foreach (Path path in glyph.active_paths) { s.append ("BF path: "); s.append (BirdFontFile.get_point_data (path));@@ -266,7 +266,7 @@ public class ClipTool : Tool { } } else { new_path = new Path ();- foreach (Path path in glyph.path_list) {+ foreach (Path path in glyph.get_all_paths ()) { if (path.points.size > 0 && path.points.get (0).is_selected () && path.points.get (path.points.size - 1).is_selected ()) {@@ -404,7 +404,7 @@ public class ClipTool : Tool { destination = MainWindow.get_current_glyph (); glyph = glyphs.get (0).get_current (); - foreach (Path p in glyph.path_list) {+ foreach (Path p in glyph.get_all_paths ()) { PenTool.clear_directions (); destination.add_path (p); destination.add_active_path (p);@@ -607,16 +607,19 @@ public class DrawingTools : ToolCollection { }); draw_tool_modifiers.add_tool (close_path_tool); + // FIXME: add new layer tools+ /* move_layer = new Tool ("move_layer", t_("Move to path to the bottom layer")); move_layer.select_action.connect ((self) => { Glyph g = MainWindow.get_current_glyph (); foreach (Path p in g.active_paths) {- g.path_list.remove (p);+ g.layers.remove (p); g.path_list.insert (0, p); } }); draw_tool_modifiers.add_tool (move_layer);+ */ flip_vertical = new Tool ("flip_vertical", t_("Flip path vertically")); flip_vertical.select_action.connect ((self) => {@@ -1575,7 +1578,7 @@ public class DrawingTools : ToolCollection { Glyph g = MainWindow.get_current_glyph (); layer_tools.tool.clear ();- foreach (Layer layer in g.layers) { + foreach (Layer layer in g.layers.subgroups) { LayerLabel label = new LayerLabel ("Layer", layer); layer_tools.add_tool (label); }@@ -100,7 +100,7 @@ public class ExportTool : GLib.Object { s = new StringBuilder (); glyph_svg = ""; - pl = only_selected_paths ? glyph.active_paths : glyph.path_list;+ pl = only_selected_paths ? glyph.active_paths : glyph.get_visible_paths (); foreach (Path p in pl) { if (p.stroke > 0) { s.append (@"<path ");@@ -129,7 +129,7 @@ public class ExportTool : GLib.Object { } } } else {- foreach (Path p in glyph.path_list) {+ foreach (Path p in glyph.get_visible_paths ()) { if (p.stroke == 0) { glyph_svg += Svg.to_svg_path (p, glyph); }@@ -357,8 +357,6 @@ public class Font : GLib.Object { n.right_limit = 0; n.remove_empty_paths (); - assert (n.path_list.size == 0);- return gc; } @@ -32,10 +32,6 @@ public class Glyph : FontDisplay { Gee.ArrayList<ZoomView> zoom_list = new Gee.ArrayList<ZoomView> (); int zoom_list_index = 0; - // Paths- public Gee.ArrayList<Path> path_list = new Gee.ArrayList<Path> (); - public Gee.ArrayList<Path> active_paths = new Gee.ArrayList<Path> ();- // The point where edit event begun double pointer_begin_x = 0; double pointer_begin_y = 0;@@ -110,15 +106,16 @@ public class Glyph : FontDisplay { public static bool show_orientation_arrow = false; public static double orientation_arrow_opacity = 1; - public Gee.ArrayList<Layer> layers = new Gee.ArrayList<Layer> ();+ public Layer layers = new Layer (); public Layer current_layer = new Layer ();+ public Gee.ArrayList<Path> active_paths = new Gee.ArrayList<Path> (); public Glyph (string name, unichar unichar_code = 0) { this.name = name; this.unichar_code = unichar_code; - path_list.add (new Path ());- layers.add (current_layer);+ current_layer.add_path (new Path ());+ layers.add_layer (current_layer); add_help_lines (); left_limit = -28;@@ -129,17 +126,28 @@ public class Glyph : FontDisplay { this.name = name; this.unichar_code = unichar_code; - path_list.add (new Path ());- layers.add (current_layer);+ current_layer.add_path (new Path ());+ layers.add_layer (current_layer);+ }++ public PathList get_visible_path_list () {+ return layers.get_visible_paths (); } - ~Glyph () {- path_list.clear ();- active_paths.clear ();+ public Gee.ArrayList<Path> get_visible_paths () {+ return layers.get_visible_paths ().paths;+ }++ public Gee.ArrayList<Path> get_current_layer () {+ return current_layer.paths.paths;+ }+ + public Gee.ArrayList<Path> get_all_paths () {+ return layers.get_all_paths ().paths; } public void add_new_layer () {- layers.add (new Layer ());+ layers.add_layer (new Layer ()); } public GlyfData get_ttf_data () {@@ -157,7 +165,7 @@ public class Glyph : FontDisplay { PathList stroke; pl = new PathList ();- foreach (Path p in path_list) {+ foreach (Path p in get_visible_paths ()) { if (p.stroke > 0) { stroke = p.get_stroke (); foreach (Path stroke_part in stroke.paths) {@@ -220,7 +228,9 @@ public class Glyph : FontDisplay { } public bool boundaries (out double x1, out double y1, out double x2, out double y2) {- if (path_list.size == 0) {+ var paths = get_all_paths ();+ + if (paths.size == 0) { x1 = 0; y1 = 0; x2 = 0;@@ -233,7 +243,7 @@ public class Glyph : FontDisplay { y1 = CANVAS_MAX; y2 = CANVAS_MIN; - foreach (Path p in path_list) {+ foreach (Path p in paths) { p.update_region_boundaries (); if (p.points.size > 1) {@@ -372,7 +382,7 @@ public class Glyph : FontDisplay { } public void add_path (Path p) {- path_list.add (p);+ current_layer.add_path (p); } public override void selected_canvas () {@@ -540,8 +550,9 @@ public class Glyph : FontDisplay { double max_x, min_x, max_y, min_y; PathList pl;+ var paths = get_all_paths (); - if (path_list.size == 0) {+ if (paths.size == 0) { x1 = 0; y1 = 0; x2 = 0;@@ -555,7 +566,7 @@ public class Glyph : FontDisplay { min_y = CANVAS_MAX; // FIXME: optimize- foreach (Path p in path_list) {+ foreach (Path p in paths) { if (p.stroke > 0) { pl = p.get_stroke_fast ();@@ -641,7 +652,7 @@ public class Glyph : FontDisplay { } public void remove_empty_paths () {- foreach (Path p in path_list) {+ foreach (Path p in get_all_paths ()) { if (p.points.size < 2) { delete_path (p); remove_empty_paths ();@@ -650,8 +661,8 @@ public class Glyph : FontDisplay { } } - public void delete_path (Path p) requires (path_list.size > 0) {- path_list.remove (p);+ public void delete_path (Path p) {+ layers.remove_path(p); } public string get_svg_data () {@@ -777,7 +788,7 @@ public class Glyph : FontDisplay { */ public bool process_deleted () { Gee.ArrayList<Path> deleted_paths = new Gee.ArrayList<Path> ();- foreach (Path p in path_list) {+ foreach (Path p in get_all_paths ()) { if (p.points.size > 0) { if (process_deleted_points_in_path (p)) { return true;@@ -913,8 +924,6 @@ public class Glyph : FontDisplay { /** Add new points to this path. */ public void set_active_path (Path p) {- path_list.remove (p);- path_list.add (p); p.reopen (); clear_active_paths (); add_active_path (p);@@ -1065,7 +1074,7 @@ public class Glyph : FontDisplay { Path? p = null; bool found = false; - foreach (Path pt in path_list) {+ foreach (Path pt in get_visible_paths ()) { if (pt.is_over (x, y)) { p = pt; found = true;@@ -1115,14 +1124,15 @@ public class Glyph : FontDisplay { double xt = path_coordinate_x (x); double yt = path_coordinate_y (y);+ var paths = get_visible_paths (); - foreach (Path p in path_list) {+ foreach (Path p in paths) { if (p.is_over (xt, yt)) { return p; } } - foreach (Path p in path_list) {+ foreach (Path p in paths) { if (p.points.size == 0) continue; p.get_closest_point_on_path (ep, xt, yt);@@ -1136,12 +1146,12 @@ public class Glyph : FontDisplay { } // a path without any editpoints- if (path_list.size > 0) {- return path_list.get (0);+ if (paths.size > 0) {+ return paths.get (0); } if (unlikely (min_distance == double.MAX)) {- warning (@"No path found in path_list. Length: $(path_list.size)");+ warning (@"No path found in path_list."); } return min_point;@@ -1224,13 +1234,6 @@ public class Glyph : FontDisplay { redraw_area ((int)px - 20, (int)py - 20, tw + 120, th + 120); } - public Path? get_last_path () - ensures (result != null)- {- return_val_if_fail (path_list.size > 0, null);- return path_list.get (path_list.size - 1);- }- public bool has_active_path () { return active_paths.size > 0; }@@ -1243,7 +1246,7 @@ public class Glyph : FontDisplay { public bool close_path () { bool r = false; - foreach (Path p in path_list) {+ foreach (Path p in get_all_paths ()) { if (p.is_editable ()) { r = true; p.set_editable (false);@@ -1262,7 +1265,7 @@ public class Glyph : FontDisplay { } public void open_path () {- foreach (Path p in path_list) {+ foreach (Path p in get_visible_paths ()) { p.set_editable (true); p.recalculate_linear_handles (); @@ -1343,7 +1346,7 @@ public class Glyph : FontDisplay { reset_zoom (); - foreach (var p in path_list) {+ foreach (var p in get_visible_paths ()) { p.update_region_boundaries (); if (p.points.size > 2) {@@ -1476,7 +1479,7 @@ public class Glyph : FontDisplay { } public bool is_empty () {- foreach (Path p in path_list) {+ foreach (Path p in get_visible_paths ()) { if (p.points.size > 0) { return false; }@@ -1514,7 +1517,7 @@ public class Glyph : FontDisplay { cr.save (); cr.new_path ();- foreach (Path p in path_list) {+ foreach (Path p in get_visible_paths ()) { if (p.stroke > 0) { stroke = p.get_stroke_fast (); draw_path_list (stroke, cr, color);@@ -1532,7 +1535,7 @@ public class Glyph : FontDisplay { cr.save (); cr.new_path ();- foreach (Path p in path_list) {+ foreach (Path p in get_visible_paths ()) { if (p.stroke > 0) { stroke = p.get_stroke_fast (); @@ -1569,7 +1572,7 @@ public class Glyph : FontDisplay { if (is_open () && Path.fill_open_path) { cr.save (); cr.new_path ();- foreach (Path p in path_list) {+ foreach (Path p in get_visible_paths ()) { if (p.stroke == 0) { p.draw_path (cr, this, get_path_fill_color ()); }@@ -1581,7 +1584,7 @@ public class Glyph : FontDisplay { if (is_open ()) { cr.save (); cr.new_path ();- foreach (Path p in path_list) {+ foreach (Path p in get_visible_paths ()) { p.draw_outline (cr); p.draw_edit_points (cr); }@@ -1595,7 +1598,7 @@ public class Glyph : FontDisplay { cr.save (); cr.new_path ();- foreach (Path p in path_list) {+ foreach (Path p in get_visible_paths ()) { if (p.stroke == 0) { p.draw_path (cr, this, Color.black ()); }@@ -1617,7 +1620,7 @@ public class Glyph : FontDisplay { } if (show_orientation_arrow) {- foreach (Path p in path_list) {+ foreach (Path p in get_visible_paths ()) { if (p.stroke > 0) { stroke = p.get_stroke_fast (); foreach (Path ps in stroke.paths) {@@ -1688,7 +1691,7 @@ public class Glyph : FontDisplay { } if (unlikely (Preferences.draw_boundaries)) {- foreach (Path p in path_list) {+ foreach (Path p in get_visible_paths ()) { p.draw_boundaries (cr); } }@@ -1795,10 +1798,8 @@ public class Glyph : FontDisplay { foreach (Line line in get_all_help_lines ()) { g.add_line (line.copy ()); }-- foreach (Path p in path_list) {- g.add_path (p.copy ());- }+ + g.layers = layers.copy (); foreach (Path p in active_paths) { g.active_paths.add (p);@@ -1867,9 +1868,11 @@ public class Glyph : FontDisplay { } void set_glyph_data (Glyph g) {- path_list.clear ();+ // FIXME: get a pointer to current layer not a copy+ // current_layer + layers = g.layers.copy (); - foreach (Path p in g.path_list) {+ foreach (Path p in get_all_paths ()) { add_path (p); p.update_region_boundaries (); }@@ -1911,7 +1914,7 @@ public class Glyph : FontDisplay { min = double.MAX; - foreach (Path pp in path_list) {+ foreach (Path pp in get_visible_paths ()) { lep = new EditPoint (); pp.get_closest_point_on_path (lep, xt, yt); distance = Math.sqrt (Math.pow (Math.fabs (xt - lep.x), 2) + Math.pow (Math.fabs (yt - lep.y), 2));@@ -2266,15 +2269,11 @@ public class Glyph : FontDisplay { TabContent.show_text_input (listener); }- - public PathList get_paths () {- PathList pl = new PathList ();- - foreach (Path p in path_list) {- pl.add (p);- }- - return pl;++ public Path? get_last_path () {+ var paths = get_all_paths ();+ return_val_if_fail (paths.size > 0, null);+ return paths.get (paths.size - 1); } } @@ -35,6 +35,53 @@ public class Layer : GLib.Object { return p; }++ public PathList get_visible_paths () {+ PathList p = new PathList ();+ + p.append (paths);+ + foreach (Layer sublayer in subgroups) {+ if (sublayer.visible) {+ p.append (sublayer.get_all_paths ());+ }+ }+ + return p;+ }+ + public void add_layer (Layer layer) {+ subgroups.add (layer);+ }++ public void add_path (Path path) {+ paths.add (path);+ }++ public void remove_path (Path path) {+ paths.remove (path);+ foreach (Layer sublayer in subgroups) {+ sublayer.remove_path (path);+ }+ }++ public void remove_layer (Layer layer) {+ subgroups.remove (layer);+ foreach (Layer sublayer in subgroups) {+ sublayer.remove_layer (layer);+ }+ }+ + public Layer copy () {+ Layer layer = new Layer ();+ + layer.paths = paths.copy ();+ foreach (Layer l in subgroups) {+ layer.subgroups.add (l.copy ());+ }+ + return layer;+ } } }@@ -63,7 +63,7 @@ public class LayerLabel : Tool { idle.set_callback (() => { Glyph g = MainWindow.get_current_glyph ();- g.layers.remove (layer);+ g.layers.remove_layer (layer); DrawingTools.update_layers (); return false; });@@ -557,7 +557,7 @@ public class MenuTab : FontDisplay { // selected segments if (paths.size == 0) {- foreach (Path p in g.path_list) {+ foreach (Path p in g.get_all_paths ()) { g.add_active_path (p); } @@ -569,15 +569,15 @@ public class MenuTab : FontDisplay { g.store_undo_state (); foreach (Path p in g.active_paths) {- g.path_list.remove (p);+ g.layers.remove_path (p); } foreach (Path p in g.active_paths) {- g.path_list.remove (p);+ g.layers.remove_path (p); } foreach (Path p in paths) {- g.add_path (p);+ g.layers.add_path (p); g.add_active_path (p); } @@ -86,7 +86,7 @@ public class MoveTool : Tool { } foreach (Path p in g.active_paths) {- g.path_list.remove (p);+ g.layers.remove_path (p); g.update_view (); } @@ -202,7 +202,7 @@ public class MoveTool : Tool { glyph.clear_active_paths (); - foreach (Path p in glyph.path_list) {+ foreach (Path p in glyph.get_current_layer ()) { if (p.xmin > x1 && p.xmax < x2 && p.ymin < y1 && p.ymax > y2) { if (p.points.size > 0) { glyph.add_active_path (p);@@ -442,7 +442,7 @@ public class MoveTool : Tool { g.clear_active_paths (); - foreach (Path p in g.path_list) {+ foreach (Path p in g.get_current_layer ()) { if (p.points.size > 0) { g.add_active_path (p); }@@ -214,7 +214,7 @@ public class GlyfTable : OtfTable { this.glyf_data.add (glyf_data); - if (g.path_list.size == 0 || glyf_data.paths.size == 0 || glyf_data.get_ncontours () == 0) {+ if (g.get_visible_paths ().size == 0 || glyf_data.paths.size == 0 || glyf_data.get_ncontours () == 0) { // location_offsets will be equal to location_offset + 1 for // all empty glyphs g.set_empty_ttf (true);@@ -715,15 +715,16 @@ public class GlyfTable : OtfTable { if (ixmax <= ixmin) { warning (@"Bounding box is bad. (xmax == xmin) ($xmax == $xmin)"); - if (glyph.path_list.size > 0) {+ var visible_paths = glyph.get_visible_paths ();+ if (visible_paths.size > 0) { - Path ps = glyph.path_list.get (0);+ Path ps = visible_paths.get (0); ps.update_region_boundaries (); xmin = ps.xmin; xmax = ps.xmax; - foreach (Path p in glyph.path_list) {+ foreach (Path p in visible_paths) { p.update_region_boundaries (); if (p.xmin < xmin) {@@ -21,6 +21,10 @@ public class PathList : GLib.Object { paths = new Gee.ArrayList<Path> (); } + public void remove (Path p) {+ paths.remove (p);+ }+ public void add_unique (Path p) { if (paths.index_of (p) == -1) { paths.add (p);@@ -59,6 +63,16 @@ public class PathList : GLib.Object { return p; }+ + public PathList copy () {+ PathList pl = new PathList ();+ + foreach (Path p in paths) {+ pl.add (p);+ }+ + return pl;+ } } }@@ -180,7 +180,7 @@ public class PenTool : Tool { BirdFont.get_current_font ().touch (); reset_stroke (); - foreach (Path p in g.path_list) {+ foreach (Path p in g.get_visible_paths ()) { if (p.is_open () && p.points.size > 0) { p.get_first_point ().set_tie_handle (false); p.get_first_point ().set_reflective_handles (false);@@ -256,7 +256,7 @@ public class PenTool : Tool { clockwise.clear (); counter_clockwise.clear ();- foreach (Path p in glyph.path_list) {+ foreach (Path p in glyph.get_visible_paths ()) { if (p.is_clockwise ()) { clockwise.add (p); } else {@@ -309,7 +309,7 @@ public class PenTool : Tool { remove_all_selected_points (); - foreach (Path p in g.path_list) {+ foreach (Path p in g.get_visible_paths ()) { // TODO: Select path only of bounding box is in selection box foreach (EditPoint ep in p.points) { if (x1 <= ep.x <= x2 && y2 <= ep.y <= y1) {@@ -329,7 +329,7 @@ public class PenTool : Tool { process_deleted (); - foreach (Path p in g.path_list) {+ foreach (Path p in g.get_all_paths ()) { if (p.has_deleted_point ()) { process_deleted (); }@@ -690,7 +690,7 @@ public class PenTool : Tool { selected_points.clear (); - foreach (Path p in g.path_list) {+ foreach (Path p in g.get_visible_paths ()) { foreach (EditPoint e in p.points) { if (e.is_selected ()) { selected_points.add (new PointSelection (e, p));@@ -706,7 +706,7 @@ public class PenTool : Tool { public static void close_all_paths () { Glyph g = MainWindow.get_current_glyph ();- foreach (Path p in g.path_list) {+ foreach (Path p in g.get_visible_paths ()) { if (p.stroke == 0) { p.close (); }@@ -1081,7 +1081,7 @@ public class PenTool : Tool { clear_directions (); - foreach (Path p in g.path_list) {+ foreach (Path p in g.get_visible_paths ()) { if (!p.has_direction ()) { if (is_counter_path (p)) { p.force_direction (Direction.COUNTER_CLOCKWISE);@@ -1103,7 +1103,7 @@ public class PenTool : Tool { Glyph g = MainWindow.get_current_glyph (); PathList pl = new PathList (); - foreach (Path p in g.path_list) {+ foreach (Path p in g.get_visible_paths ()) { pl.add (p); } @@ -1135,7 +1135,7 @@ public class PenTool : Tool { // continue adding points from the other end of the selected path reverse = false; - foreach (Path p in glyph.path_list) {+ foreach (Path p in glyph.get_visible_paths ()) { 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))) {@@ -1146,7 +1146,7 @@ public class PenTool : Tool { } } - foreach (Path p in glyph.path_list) {+ foreach (Path p in glyph.get_visible_paths ()) { if (p.is_open () && p.points.size > 1 && active_edit_point == p.points.get (0)) { p.reverse (); update_selection ();@@ -1214,7 +1214,7 @@ public class PenTool : Tool { Glyph glyph = MainWindow.get_current_glyph (); EditPoint ep_last, ep_first; - foreach (Path path in glyph.path_list) {+ foreach (Path path in glyph.get_visible_paths ()) { if (path.points.size == 0) { continue; }@@ -1328,8 +1328,10 @@ public class PenTool : Tool { Path union; bool direction_changed = false; int px, py;-- if (glyph.path_list.size == 0) {+ + var paths = glyph.get_visible_paths ();+ + if (paths.size == 0) { warning ("No paths."); return null; }@@ -1355,7 +1357,7 @@ public class PenTool : Tool { glyph.delete_path (path); glyph.clear_active_paths (); - foreach (Path merge in glyph.path_list) {+ foreach (Path merge in paths) { if (merge.points.size > 0) { if (is_close_to_point (merge.points.get (merge.points.size - 1), px, py)) { glyph.add_active_path (merge);@@ -1415,7 +1417,7 @@ public class PenTool : Tool { return path; } - foreach (Path merge in glyph.path_list) {+ foreach (Path merge in paths) { // don't join path with itself here if (path == merge) { continue;@@ -1574,7 +1576,7 @@ public class PenTool : Tool { px = Glyph.reverse_path_coordinate_x (active.x); py = Glyph.reverse_path_coordinate_y (active.y); - foreach (Path path in glyph.path_list) {+ foreach (Path path in glyph.get_visible_paths ()) { if (!path.is_open ()) { continue;@@ -1603,7 +1605,7 @@ public class PenTool : Tool { EditPoint end; Glyph glyph = MainWindow.get_current_glyph (); - foreach (Path path in glyph.path_list) {+ foreach (Path path in glyph.get_visible_paths ()) { if (path.points.size < 1) { continue; }@@ -1623,7 +1625,7 @@ public class PenTool : Tool { bool redraw; Glyph g = MainWindow.get_current_glyph (); - foreach (Path p in g.path_list) {+ foreach (Path p in g.get_visible_paths ()) { foreach (var ep in p.points) { ep.set_active (false); }@@ -1652,7 +1654,7 @@ public class PenTool : Tool { path = null; - foreach (Path current_path in g.path_list) {+ foreach (Path current_path in g.get_visible_paths ()) { if (is_close_to_path (current_path, ex, ey)) { foreach (EditPoint e in current_path.points) { nd = e.get_distance (x, y);@@ -1830,7 +1832,7 @@ public class PenTool : Tool { public static void set_default_handle_positions () { Glyph g = MainWindow.get_current_glyph ();- foreach (var p in g.path_list) {+ foreach (var p in g.get_visible_paths ()) { if (p.is_editable ()) { p.create_list (); set_default_handle_positions_on_path (p);@@ -1857,7 +1859,7 @@ public class PenTool : Tool { } } } else {- foreach (Path p in g.path_list) {+ foreach (Path p in g.get_visible_paths ()) { if (is_close_to_path (p, event_x, event_y)) { foreach (EditPoint ep in p.points) { if (is_close_to_handle (ep, event_x, event_y, distance_to_edit_point)) {@@ -1920,7 +1922,7 @@ public class PenTool : Tool { EditPoint parent_point; EditPoint tied_point; - foreach (Path p in g.path_list) {+ foreach (Path p in g.get_visible_paths ()) { if (is_close_to_path (p, event_x, event_y) || p == active_path) { foreach (EditPoint ep in p.points) { if (ep.is_selected () || Path.show_all_line_handles) {@@ -2044,7 +2046,7 @@ public class PenTool : Tool { selected_points.clear (); - foreach (Path p in g.path_list) {+ foreach (Path p in g.get_visible_paths ()) { foreach (EditPoint e in p.points) { e.set_active (false); e.set_selected (false);@@ -2468,7 +2470,7 @@ public class PenTool : Tool { selected.point.set_selected (true); } - foreach (Path p in glyph.path_list) {+ foreach (Path p in glyph.get_visible_paths ()) { p.update_region_boundaries (); } }@@ -2477,7 +2479,7 @@ public class PenTool : Tool { Glyph g = MainWindow.get_current_glyph (); selected_points.clear (); - foreach (Path p in g.path_list) {+ foreach (Path p in g.get_visible_paths ()) { foreach (EditPoint ep in p.points) { if (ep.is_selected ()) { selected_points.add (new PointSelection (ep, p));@@ -2489,7 +2491,7 @@ public class PenTool : Tool { public void select_all_points () { Glyph g = MainWindow.get_current_glyph (); - foreach (Path p in g.path_list) {+ foreach (Path p in g.get_visible_paths ()) { foreach (EditPoint ep in p.points) { ep.set_selected (true); add_selected_point (ep, p);@@ -392,7 +392,7 @@ public class Text : Widget { lsb = glyph.left_limit; - foreach (Path path in glyph.path_list) {+ foreach (Path path in glyph.get_visible_paths ()) { draw_path (cr, glyph, path, lsb, x, y, ratio); } @@ -428,7 +428,7 @@ public class Text : Widget { cc.set_source_rgba (r, g, b, a); cc.new_path (); - foreach (Path path in glyph.path_list) {+ foreach (Path path in glyph.get_visible_paths ()) { draw_path (cc, glyph, path, lsb, offset_x / 10.0, cc_y + offset_y / 10.0, ratio); } @@ -52,7 +52,7 @@ public class StrokeTool : Tool { if (paths.paths.size > 0) { foreach (Path p in g.active_paths) {- g.path_list.remove (p);+ g.layers.remove_path (p); } g.active_paths.clear ();@@ -23,7 +23,7 @@ class Svg { StringBuilder svg = new StringBuilder (); PathList stroke_list; - foreach (Path p in g.path_list) {+ foreach (Path p in g.get_visible_paths ()) { if (p.stroke == 0) { write_path_as_glyph (p, svg, g); } else {@@ -71,7 +71,7 @@ class TestCases { Gee.ArrayList<Path> paths = new Gee.ArrayList<Path> (); Path pn; - foreach (Path p in g.path_list) {+ foreach (Path p in g.get_all_paths ()) { pn = p.copy (); pn.add_hidden_double_points (); paths.add (pn);@@ -172,7 +172,7 @@ class TestCases { glyph = MainWindow.get_current_glyph (); for (int i = 0; i < 5; i++) {- foreach (Path p in glyph.path_list) {+ foreach (Path p in glyph.get_all_paths ()) { p.set_stroke (i / 100.0); glyph.update_view (); Tool.yield ();@@ -192,7 +192,7 @@ class TestCases { Toolbox.select_tool_by_name ("full_glyph"); - foreach (Path p in g.path_list) {+ foreach (Path p in g.get_all_paths ()) { p.add_extrema (); } }@@ -644,7 +644,7 @@ class TestCases { // convert the current path g = MainWindow.get_current_glyph (); - foreach (Path path in g.path_list) {+ foreach (Path path in g.get_all_paths ()) { paths.append (path.get_quadratic_points ()); paths.append (path.copy ()); }@@ -1245,7 +1245,7 @@ class TestCases { test_open_next_glyph (); test_inkscape_import (); // draw somee thing - foreach (Path p in g.path_list) {+ foreach (Path p in g.get_all_paths ()) { path = new Path (); p.all_of_path ((cx, cy, ct) => { path.add (cx, cy);@@ -227,9 +227,11 @@ public class TrackTool : Tool { } } + // FIXME: double check void set_tie () { Glyph glyph = MainWindow.get_current_glyph ();- Path p = glyph.path_list.get (glyph.path_list.size - 1);+ var paths = glyph.get_visible_paths ();+ Path p = paths.get (paths.size - 1); foreach (EditPoint ep in p.points) { if (ep.get_right_handle ().is_line () || ep.get_left_handle ().is_line ()) {@@ -241,7 +243,7 @@ public class TrackTool : Tool { } } }-+ public void set_samples_per_point (double s) { samples_per_point = s; }@@ -253,13 +255,15 @@ public class TrackTool : Tool { PointSelection joined_path; glyph = MainWindow.get_current_glyph ();+ var paths = glyph.get_visible_paths (); - if (glyph.path_list.size == 0) {+ if (paths.size == 0) { warning ("No path."); return; } - p = glyph.path_list.get (glyph.path_list.size - 1);+ // FIXME: double check this+ p = paths.get (paths.size - 1); draw_freehand = false; convert_points_to_line ();@@ -290,11 +294,6 @@ public class TrackTool : Tool { p.create_list (); - if (glyph.path_list.size < 2) {- warning ("Less than two points");- return;- }- if (DrawingTools.get_selected_point_type () == PointType.QUADRATIC) { foreach (EditPoint e in p.points) { if (e.tie_handles) {@@ -374,7 +373,7 @@ public class TrackTool : Tool { current_end = get_active_path ().get_last_point (); } - foreach (Path p in glyph.path_list) {+ foreach (Path p in glyph.get_visible_paths ()) { if (p.is_open () && p.points.size > 2) { e = p.points.get (0); if (PenTool.is_close_to_point (e, x, y)) {@@ -531,15 +530,15 @@ public class TrackTool : Tool { Gee.ArrayList<EditPoint> points; points = new Gee.ArrayList<EditPoint> ();- glyph = MainWindow.get_current_glyph ();+ var paths = glyph.get_visible_paths (); - if (glyph.path_list.size == 0) {+ if (paths.size == 0) { warning ("No path."); return; } - p = glyph.path_list.get (glyph.path_list.size - 1);+ p = paths.get (paths.size - 1); if (added_points == 0) { // last point return;