The Birdfont Source Code


All Repositories / birdfont.git / commitdiff – RSS feed

Replace the list implementation

These changes was commited to the Birdfont repository Sat, 07 Nov 2015 05:40:14 +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, 07 Nov 2015 05:40:14 +0000]

Updated Files

libbirdfont/BirdFontFile.vala
libbirdfont/EditPoint.vala
libbirdfont/EditPointHandle.vala
libbirdfont/Glyph.vala
libbirdfont/OverViewItem.vala
libbirdfont/Path.vala
libbirdfont/PenTool.vala
libbirdfont/PointConverter.vala
libbirdfont/StrokeTool.vala
libbirdfont/TrackTool.vala
--- a/libbirdfont/BirdFontFile.vala +++ b/libbirdfont/BirdFontFile.vala @@ -1422,8 +1422,7 @@ private static void line (Path path, string px, string py) { EditPoint ep; - path.add (parse_double (px), parse_double (py)); - ep = path.get_last_point (); + ep = path.add (parse_double (px), parse_double (py)); ep.get_right_handle ().type = PointType.LINE_DOUBLE_CURVE; ep.get_left_handle ().type = PointType.LINE_DOUBLE_CURVE; ep.type = PointType.LINE_DOUBLE_CURVE;
--- a/libbirdfont/EditPoint.vala +++ b/libbirdfont/EditPoint.vala @@ -22,7 +22,7 @@ LINE_DOUBLE_CURVE, // line with two quadratic handles LINE_CUBIC, // line with cubic handles CUBIC, - DOUBLE_CURVE, // two quadratic points with a hidden point half way between the two line handles + DOUBLE_CURVE, // two quadratic points with a hidden point half way between the two handles QUADRATIC, HIDDEN, FLOATING, @@ -35,8 +35,8 @@ public double y; public PointType type; - public unowned EditPoint? prev = null; - public unowned EditPoint? next = null; + public int index = 0; + public unowned Path? path = null; public static const uint NONE = 0; public static const uint ACTIVE = 1; @@ -167,32 +167,14 @@ public Color? color = null; - public EditPoint (double nx = 0, double ny = 0, PointType nt = PointType.NONE) { + public EditPoint (double nx = 0, double ny = 0, + PointType nt = PointType.NONE, Path? path = null) { x = nx; y = ny; type = nt; - right_handle = new EditPointHandle (this, 0, 7); - left_handle = new EditPointHandle (this, PI, 7); - } - - public EditPoint.full (double nx = 0, double ny = 0, PointType nt = PointType.NONE) { - x = nx; - y = ny; - type = nt; - active_point = true; - - if (nt == PointType.FLOATING) { - active_point = false; - } - right_handle = new EditPointHandle (this, 0, 7); left_handle = new EditPointHandle (this, PI, 7); - - if (unlikely (nx.is_nan () || ny.is_nan ())) { - warning (@"Invalid point at ($nx,$ny)."); - x = 0; - y = 0; - } + this.path = path; } public bool is_valid () { @@ -230,8 +212,8 @@ double dr, dl; EditPointHandle t; - if (next == null || get_next ().next != null) { - return; + if (!has_next () || !get_next ().has_next ()) { + return; } if (unlikely (reflective_point || tie_handles)) { @@ -255,115 +237,167 @@ /** Set bezier points for linear paths. */ public void recalculate_linear_handles () { - unowned EditPointHandle h; - unowned EditPoint n; + EditPointHandle h; + EditPoint n; + EditPoint prevoius_point, next_point; double nx, ny; - + Path p; + return_if_fail (!is_null (right_handle) && !is_null (left_handle)); - - if (prev == null && next != null) { - // FIXME: prev = get_next ().last (); + + if (unlikely (path == null)) { + warning("No path."); + return; } + + p = (!) path; + prevoius_point = has_prev () ? get_prev () : p.get_last_point (); + next_point = has_next () ? get_next () : p.get_first_point (); // left handle - if (prev != null) { - n = get_prev (); - h = get_left_handle (); + n = prevoius_point; + h = get_left_handle (); + + return_if_fail (!is_null (n) && !is_null (h)); - return_if_fail (!is_null (n) && !is_null (h)); - - if (h.type == PointType.LINE_CUBIC) { - nx = x + ((n.x - x) / 3); - ny = y + ((n.y - y) / 3); - h.move_to_coordinate (nx, ny); - } + if (h.type == PointType.LINE_CUBIC) { + nx = x + ((n.x - x) / 3); + ny = y + ((n.y - y) / 3); + h.move_to_coordinate (nx, ny); + } - if (h.type == PointType.LINE_DOUBLE_CURVE) { - nx = x + ((n.x - x) / 4); - ny = y + ((n.y - y) / 4); - h.move_to_coordinate (nx, ny); - } + if (h.type == PointType.LINE_DOUBLE_CURVE) { + nx = x + ((n.x - x) / 4); + ny = y + ((n.y - y) / 4); + h.move_to_coordinate (nx, ny); + } - if (h.type == PointType.LINE_QUADRATIC) { - nx = x + ((n.x - x) / 2); - ny = y + ((n.y - y) / 2); - h.move_to_coordinate (nx, ny); - } - - // the other side - h = n.get_right_handle (); - return_if_fail (!is_null (h) && !is_null (h)); + if (h.type == PointType.LINE_QUADRATIC) { + nx = x + ((n.x - x) / 2); + ny = y + ((n.y - y) / 2); + h.move_to_coordinate (nx, ny); + } + + // the other side + h = n.get_right_handle (); + return_if_fail (!is_null (h) && !is_null (h)); + + if (h.type == PointType.LINE_DOUBLE_CURVE) { + nx = n.x + ((x - n.x) / 4); + ny = n.y + ((y - n.y) / 4); + h.move_to_coordinate (nx, ny); + } - if (h.type == PointType.LINE_DOUBLE_CURVE) { - nx = n.x + ((x - n.x) / 4); - ny = n.y + ((y - n.y) / 4); - h.move_to_coordinate (nx, ny); - } - - if (h.type == PointType.LINE_CUBIC) { - nx = n.x + ((x - n.x) / 3); - ny = n.y + ((y - n.y) / 3); - h.move_to_coordinate (nx, ny); - } + if (h.type == PointType.LINE_CUBIC) { + nx = n.x + ((x - n.x) / 3); + ny = n.y + ((y - n.y) / 3); + h.move_to_coordinate (nx, ny); + } - if (h.type == PointType.LINE_QUADRATIC) { - nx = n.x + ((x - n.x) / 2); - ny = n.y + ((y - n.y) / 2); - h.move_to_coordinate (nx, ny); - } + if (h.type == PointType.LINE_QUADRATIC) { + nx = n.x + ((x - n.x) / 2); + ny = n.y + ((y - n.y) / 2); + h.move_to_coordinate (nx, ny); } // right handle - if (next != null) { - n = get_next (); - h = get_right_handle (); + n = next_point; + h = get_right_handle (); + + return_if_fail (!is_null (n) && !is_null (h)); + + if (h.type == PointType.LINE_CUBIC) { + nx = x + ((n.x - x) / 3); + ny = y + ((n.y - y) / 3); - return_if_fail (!is_null (n) && !is_null (h)); + h.move_to_coordinate (nx, ny); + } + + if (h.type == PointType.LINE_DOUBLE_CURVE) { + nx = x + ((n.x - x) / 4); + ny = y + ((n.y - y) / 4); - if (h.type == PointType.LINE_CUBIC) { - nx = x + ((n.x - x) / 3); - ny = y + ((n.y - y) / 3); - - h.move_to_coordinate (nx, ny); - } + h.move_to_coordinate (nx, ny); + } - if (h.type == PointType.LINE_DOUBLE_CURVE) { - nx = x + ((n.x - x) / 4); - ny = y + ((n.y - y) / 4); - - h.move_to_coordinate (nx, ny); - } + if (h.type == PointType.LINE_QUADRATIC) { + nx = x + ((n.x - x) / 2); + ny = y + ((n.y - y) / 2); + + h.move_to_coordinate (nx, ny); + } - if (h.type == PointType.LINE_QUADRATIC) { - nx = x + ((n.x - x) / 2); - ny = y + ((n.y - y) / 2); - - h.move_to_coordinate (nx, ny); - } + h = n.get_left_handle (); + return_if_fail (!is_null (h)); + + if (h.type == PointType.LINE_CUBIC) { + nx = n.x + ((x - n.x) / 3); + ny = n.y + ((y - n.y) / 3); - h = n.get_left_handle (); - return_if_fail (!is_null (h)); + h.move_to_coordinate (nx, ny); + } + + if (h.type == PointType.LINE_DOUBLE_CURVE) { + nx = n.x + ((x - n.x) / 4); + ny = n.y + ((y - n.y) / 4); + + h.move_to_coordinate (nx, ny); + } + + if (h.type == PointType.LINE_QUADRATIC) { + nx = n.x + ((x - n.x) / 2); + ny = n.y + ((y - n.y) / 2); - if (h.type == PointType.LINE_CUBIC) { - nx = n.x + ((x - n.x) / 3); - ny = n.y + ((y - n.y) / 3); + h.move_to_coordinate (nx, ny); + } + n = next_point; + h = get_right_handle (); + + return_if_fail (!is_null (n) && !is_null (h)); + + if (h.type == PointType.LINE_CUBIC) { + nx = x + ((n.x - x) / 3); + ny = y + ((n.y - y) / 3); + + h.move_to_coordinate (nx, ny); + } - h.move_to_coordinate (nx, ny); - } + if (h.type == PointType.LINE_DOUBLE_CURVE) { + nx = x + ((n.x - x) / 4); + ny = y + ((n.y - y) / 4); - if (h.type == PointType.LINE_DOUBLE_CURVE) { - nx = n.x + ((x - n.x) / 4); - ny = n.y + ((y - n.y) / 4); + h.move_to_coordinate (nx, ny); + } - h.move_to_coordinate (nx, ny); - } + if (h.type == PointType.LINE_QUADRATIC) { + nx = x + ((n.x - x) / 2); + ny = y + ((n.y - y) / 2); + + h.move_to_coordinate (nx, ny); + } - if (h.type == PointType.LINE_QUADRATIC) { - nx = n.x + ((x - n.x) / 2); - ny = n.y + ((y - n.y) / 2); - - h.move_to_coordinate (nx, ny); - } + h = n.get_left_handle (); + return_if_fail (!is_null (h)); + + if (h.type == PointType.LINE_CUBIC) { + nx = n.x + ((x - n.x) / 3); + ny = n.y + ((y - n.y) / 3); + + h.move_to_coordinate (nx, ny); + } + + if (h.type == PointType.LINE_DOUBLE_CURVE) { + nx = n.x + ((x - n.x) / 4); + ny = n.y + ((y - n.y) / 4); + + h.move_to_coordinate (nx, ny); + } + + if (h.type == PointType.LINE_QUADRATIC) { + nx = n.x + ((x - n.x) / 2); + ny = n.y + ((y - n.y) / 2); + + h.move_to_coordinate (nx, ny); } } @@ -372,7 +406,7 @@ } public double get_direction () { - if (prev == null) { + if (!has_prev ()) { return 0; } @@ -407,7 +441,7 @@ /** This can only be performed if the path has been closed. */ public void process_tied_handle () - requires (next != null && prev != null) { + requires (has_next () && has_prev ()) { double a, b, c, length, angle; EditPointHandle eh; EditPointHandle prev_rh, next_lh; @@ -450,6 +484,8 @@ new_point.x = x; new_point.y = y; + + // don't copy the path reference new_point.type = type; new_point.flags = flags; @@ -487,20 +523,39 @@ return right_handle; } - public unowned EditPoint get_prev () { - if (unlikely (prev == null)) { - warning ("EditPoint.prev is null"); + public bool has_next () { + Path p; + return_val_if_fail (path != null, false); + p = (!) path; + return index < p.points.size - 1; + } + + public bool has_prev () { + return 1 <= index; + } + + public EditPoint get_prev () { + Path p; + + if (unlikely (path == null)) { + warning ("No path path for point."); + return new EditPoint (); } - return (!) prev; + p = (!) path; + return p.get_point (index - 1); } - public unowned EditPoint get_next () { - if (unlikely (next == null)) { - warning ("EditPoint.next is null"); + public EditPoint get_next () { + Path p; + + if (unlikely (path == null)) { + warning ("No path path for point."); + return new EditPoint (); } - return (!) next; + p = (!) path; + return p.get_point (index + 1); } public unowned EditPoint get_link_item () { @@ -536,7 +591,7 @@ // move connected quadratic handle if (right_handle.type == PointType.QUADRATIC) { - if (next != null) { + if (has_next ()) { n = get_next (); n.set_tie_handle (false); n.set_reflective_handles (false); @@ -545,7 +600,7 @@ } if (left_handle.type == PointType.QUADRATIC) { - if (prev != null && !get_prev ().is_selected ()) { + if (has_prev () && !get_prev ().is_selected ()) { p = get_prev (); p.set_tie_handle (false); p.set_reflective_handles (false);
--- a/libbirdfont/EditPointHandle.vala +++ b/libbirdfont/EditPointHandle.vala @@ -253,14 +253,14 @@ if (type == PointType.QUADRATIC) { if (!is_left_handle ()) { - if (parent.next != null) { + if (parent.has_next ()) { h = parent.get_next ().get_left_handle (); h.parent.set_tie_handle (false); h.type = PointType.QUADRATIC; h.move_to_coordinate_internal (px (), py ()); } } else { - if (parent.prev != null) { + if (parent.has_prev ()) { h = parent.get_prev ().get_right_handle (); h.parent.set_tie_handle (false); h.type = PointType.QUADRATIC;
--- a/libbirdfont/Glyph.vala +++ b/libbirdfont/Glyph.vala @@ -1298,7 +1298,7 @@ EditPoint p; EditPoint pl = path.get_last_point (); - if (pl.prev != null) { + if (pl.has_prev ()) { p = pl.get_prev (); px = p.x + xc;
--- a/libbirdfont/OverViewItem.vala +++ b/libbirdfont/OverViewItem.vala @@ -228,7 +228,7 @@ gy = (h / glyph_scale) - 25 / glyph_scale; c.translate (gx - Glyph.xc () - g.get_lsb (), g.get_baseline () + gy - Glyph.yc ()); - + g.draw_paths (c, color); c.restore (); } else {
--- a/libbirdfont/Path.vala +++ b/libbirdfont/Path.vala @@ -699,8 +699,7 @@ Path.get_point_for_step (a, b, step, out px, out py); new_point = new EditPoint (px, py); - new_point.prev = a; - new_point.next = b; + new_point.index = a.index + 1; p.insert_new_point_on_path (new_point, step); @@ -923,10 +922,6 @@ r = points.get (0); points.remove_at (0); - - if (size > 1) { - r.get_next ().prev = null; - } return r; } @@ -943,14 +938,6 @@ r = points.get (size - 1); points.remove_at (size - 1); - - if (size > 1) { - r.get_prev ().next = null; - - if (r.next != null) { - r.get_next ().prev = null; - } - } return r; } @@ -965,13 +952,13 @@ if (points.size == 0) { points.add (p); - p.prev = p; - p.next = p; + p.index = 0; + p.path = this; } else { previous_point = points.get (points.size - 1); + p.index = points.size; + p.path = this; points.add (p); - p.prev = previous_point; - p.next = previous_point.next; } last_point = p; @@ -990,12 +977,7 @@ if (points.size == 0) { points.add (p); - p.prev = points.get (0).get_link_item (); - p.next = points.get (0).get_link_item (); } else { - p.prev = (!) previous_point; - p.next = ((!) previous_point).next; - prev_index = points.index_of ((!) previous_point); if (unlikely (!(0 <= prev_index < points.size))) { @@ -1005,6 +987,7 @@ points.insert (prev_index + 1, p); } + create_list (); last_point = p; return p; @@ -1145,8 +1128,8 @@ requires (outline.points.size >= 2 || points.size >= 2) { // rather slow use it for testing, only - unowned EditPoint i = outline.points.get (0).get_link_item (); - unowned EditPoint prev = outline.points.get (outline.points.size - 1).get_link_item (); + EditPoint i = outline.points.get (0); + EditPoint prev = outline.points.get (outline.points.size - 1); double tolerance = 1; bool g = false; @@ -1268,7 +1251,7 @@ double closest_x = 0; double closest_y = 0; - if (ep.next == null || ep.prev == null) { + if (ep.has_next () || ep.has_prev ()) { warning ("missing point"); return; } @@ -1368,7 +1351,7 @@ start.get_right_handle ().length *= position; if (right == PointType.QUADRATIC) { // update connected handle - if (ep.prev != null) { + if (ep.has_prev ()) { ep.get_left_handle ().move_to_coordinate_internal ( ep.get_prev ().right_handle.x, ep.get_prev ().right_handle.y); @@ -1412,6 +1395,7 @@ EditPoint previous; EditPoint next; double step = 0; + int index = -1; if (points.size == 0) { warning ("Empty path."); @@ -1421,9 +1405,6 @@ if (points.size == 1) { edit_point.x = i.x; edit_point.y = i.y; - - edit_point.prev = i; - edit_point.next = i; return; } @@ -1433,6 +1414,8 @@ create_list (); while (!exit) { + ++index; + if (!first && i == points.get (points.size - 1)) { done = true; } @@ -1452,7 +1435,7 @@ continue; } - if (prev.prev != null && skip_previous == prev.get_prev ()) { + if (prev.has_prev () && skip_previous == prev.get_prev ()) { continue; } @@ -1460,7 +1443,7 @@ continue; } - if (prev.next != null && skip_next == prev.get_next ()) { + if (prev.has_next () && skip_next == prev.get_next ()) { continue; } @@ -1473,7 +1456,7 @@ ox = cx; oy = cy; - previous_point = i.prev; + previous_point = i.get_prev (); next_point = i; step = t; @@ -1504,9 +1487,9 @@ previous = (!) previous_point; next = (!) next_point; - edit_point.prev = previous_point; - edit_point.next = next_point; - + edit_point.path = this; + edit_point.index = index; + edit_point.set_position (ox, oy); edit_point.type = previous.type; @@ -1540,6 +1523,11 @@ // warning (@"Mixed point types in segment $(start.x),$(start.y) to $(stop.x),$(stop.y) right: $(right), left: $(left) (start: $(start.type), stop: $(stop.type))"); return all_of_quadratic_curve (start.x, start.y, start.get_right_handle ().x, start.get_right_handle ().x, stop.x, stop.y, iter, steps); + } + + public EditPoint get_point (int i) { + return_val_if_fail (0 <= i < points.size, new EditPoint ()); + return points.get (i); } public static void get_point_for_step (EditPoint start, EditPoint stop, double step, @@ -1668,14 +1656,14 @@ } public bool all_segments (SegmentIterator iter) { - unowned EditPoint i, next; + EditPoint i, next; if (points.size < 2) { return false; } - for (int j = 0; j < points.size - 1; j++) { - i = points.get (j).get_link_item (); + for (int j = 0; j < points.size - 2; j++) { + i = points.get (j); next = i.get_next (); if (!iter (i, next)) { return false; @@ -1837,24 +1825,16 @@ if (points.size == 1) { ep = points.get (0); - ep.next = null; - ep.prev = null; + ep.index = 0; + ep.path = this; return; } - ep = points.get (0); - ep.next = points.get (1).get_link_item (); - ep.prev = points.get (points.size - 1).get_link_item (); - - for (int i = 1; i < points.size - 1; i++) { + for (int i = 0; i < points.size - 1; i++) { ep = points.get (i); - ep.prev = points.get (i - 1).get_link_item (); - ep.next = points.get (i + 1).get_link_item (); + ep.index = i; + ep.path = this; } - - ep = points.get (points.size - 1); - ep.next = points.get (0).get_link_item (); - ep.prev = points.get (points.size - 2).get_link_item (); } public bool has_point (EditPoint ep) { @@ -2232,8 +2212,8 @@ get_closest_point_on_path (ep, x, y); - next = (ep.next == null) ? points.get (0) : ep.get_next (); - prev = (ep.prev == null) ? points.get (points.size - 1) : ep.get_prev (); + next = (ep.has_next ()) ? points.get (0) : ep.get_next (); + prev = (ep.has_prev ()) ? points.get (points.size - 1) : ep.get_prev (); exists = prev.x == ep.x && prev.y == ep.y; exists |= next.x == ep.x && next.y == ep.y; @@ -2333,7 +2313,7 @@ return; } - if (r.next != null) { + if (r.has_next ()) { n = r.get_next (); } else { n = points.get (0);
--- a/libbirdfont/PenTool.vala +++ b/libbirdfont/PenTool.vala @@ -494,13 +494,13 @@ p.point.deleted = true; - if (p.point.next != null) { + if (p.point.has_next ()) { next = p.point.get_next (); } else { next = p.path.points.get (0); } - if (p.point.prev != null) { + if (p.point.has_prev ()) { prev = p.point.get_prev (); } else { prev = p.path.points.get (p.path.points.size - 1); @@ -620,13 +620,13 @@ p.point.deleted = true; - if (p.point.next != null) { + if (p.point.has_next ()) { next = p.point.get_next (); } else { next = p.path.points.get (0); } - if (p.point.prev != null) { + if (p.point.has_prev ()) { prev = p.point.get_prev (); } else { prev = p.path.points.get (p.path.points.size - 1); @@ -1863,7 +1863,7 @@ } static void set_point_type (EditPoint p) { - if (p.prev != null && p.get_prev ().right_handle.type == PointType.QUADRATIC) { + if (p.has_prev () && p.get_prev ().right_handle.type == PointType.QUADRATIC) { p.left_handle.type = PointType.QUADRATIC; p.right_handle.type = PointType.LINE_QUADRATIC; p.type = PointType.QUADRATIC; @@ -2005,14 +2005,14 @@ parent_point = eh.get_parent (); if (left_handle) { - if (parent_point.prev != null) { + if (parent_point.has_prev ()) { tied_point = parent_point.get_prev (); if (tied_point.selected_point) { eh = tied_point.get_right_handle (); } } } else { - if (parent_point.next != null) { + if (parent_point.has_next ()) { tied_point = parent_point.get_next (); if (tied_point.selected_point) { eh = tied_point.get_left_handle (); @@ -2146,8 +2146,8 @@ double min_right, min_left; double min; - return_val_if_fail (e.point.next != null, new EditPoint ()); - return_val_if_fail (e.point.prev != null, new EditPoint ()); + return_val_if_fail (e.point.has_next (), new EditPoint ()); + return_val_if_fail (e.point.has_prev (), new EditPoint ()); // angle might be greater than 2 PI or less than 0 min_right = double.MAX; @@ -2291,13 +2291,13 @@ ep.set_tie_handle (false); ep.set_reflective_handles (false); - if (ep.next == null) { - // FIXME: write a new function for this case + if (!ep.has_next ()) { + // FIXME: write a new method for this case // warning ("Next is null."); } - if (ep.prev == null) { - warning ("Prev is null."); + if (!ep.has_prev ()) { + warning ("No previous point"); } if (ep.type == PointType.CUBIC || ep.type == PointType.LINE_CUBIC) { @@ -2308,11 +2308,11 @@ ep.get_right_handle ().type = PointType.LINE_CUBIC; } - if (ep.next != null && ep.get_next ().is_selected ()) { + if (ep.has_next () && ep.get_next ().is_selected ()) { ep.get_right_handle ().type = PointType.LINE_CUBIC; } - if (ep.prev != null && ep.get_prev ().is_selected ()) { + if (ep.has_prev () && ep.get_prev ().is_selected ()) { ep.get_left_handle ().type = PointType.LINE_CUBIC; } @@ -2325,11 +2325,11 @@ ep.get_right_handle ().type = PointType.LINE_DOUBLE_CURVE; } - if (ep.next != null && ep.get_next ().is_selected ()) { + if (ep.has_next () && ep.get_next ().is_selected ()) { ep.get_right_handle ().type = PointType.LINE_DOUBLE_CURVE; } - if (ep.prev != null && ep.get_prev ().is_selected ()) { + if (ep.has_prev () && ep.get_prev ().is_selected ()) { ep.get_left_handle ().type = PointType.LINE_DOUBLE_CURVE; } } @@ -2341,21 +2341,21 @@ ep.get_left_handle ().type = PointType.LINE_QUADRATIC; ep.get_right_handle ().type = PointType.LINE_QUADRATIC; - if (ep.next != null) { + if (ep.has_next ()) { ep.get_next ().get_left_handle ().type = PointType.LINE_QUADRATIC; } - if (ep.prev != null) { + if (ep.has_prev ()) { ep.get_prev ().get_right_handle ().type = PointType.LINE_QUADRATIC; } } - if (ep.next != null && ep.get_next ().is_selected ()) { + if (ep.has_next () && ep.get_next ().is_selected ()) { ep.get_right_handle ().type = PointType.LINE_QUADRATIC; ep.get_next ().get_left_handle ().type = PointType.LINE_QUADRATIC; } - if (ep.prev != null && ep.get_prev ().is_selected ()) { + if (ep.has_prev () && ep.get_prev ().is_selected ()) { ep.get_left_handle ().type = PointType.LINE_QUADRATIC; ep.get_prev ().get_right_handle ().type = PointType.LINE_QUADRATIC; } @@ -2499,12 +2499,12 @@ if (selected_points.size == 1) { selected = selected_points.get (0); - if (selected.point.next != null) { + if (selected.point.has_next ()) { selected_points.add (new PointSelection (selected.point.get_next (), selected.path)); selected.point.get_next ().set_selected (true); } - if (selected.point.prev != null) { + if (selected.point.has_prev ()) { selected_points.add (new PointSelection (selected.point.get_prev (), selected.path)); selected.point.get_next ().set_selected (true); } @@ -2516,7 +2516,7 @@ e = ps.point; // convert segments not control points - if (e.next == null || !e.get_next ().is_selected ()) { + if (e.has_next () || !e.get_next ().is_selected ()) { continue; }
--- a/libbirdfont/PointConverter.vala +++ b/libbirdfont/PointConverter.vala @@ -133,8 +133,6 @@ distance = 0; new_point = new EditPoint (); - new_point.prev = a0; - new_point.next = a1; new_point.get_right_handle ().type = PointType.CUBIC; new_point.get_left_handle ().type = PointType.CUBIC;
--- a/libbirdfont/StrokeTool.vala +++ b/libbirdfont/StrokeTool.vala @@ -364,27 +364,27 @@ if (Path.distance_to_point (ep, lep) < 0.1) { EditPoint lep2 = new EditPoint (); - pp.get_closest_point_on_path (lep2, ep.x, ep.y, lep.prev, lep.next); + pp.get_closest_point_on_path (lep2, ep.x, ep.y, lep.get_prev (), lep.get_next ()); - if (lep.prev != null) { + if (lep.has_prev ()) { lep.get_left_handle ().type = lep.get_prev ().get_right_handle ().type; } else { lep.get_left_handle ().type = pp.get_last_point ().get_right_handle ().type; } - if (lep.next != null) { + if (lep.has_next ()) { lep.get_right_handle ().type = lep.get_next ().get_left_handle ().type; } else { lep.get_left_handle ().type = pp.get_first_point ().get_right_handle ().type; } - if (lep2.prev != null) { + if (lep2.has_prev ()) { lep2.get_left_handle ().type = lep2.get_prev ().get_right_handle ().type; } else { lep2.get_left_handle ().type = pp.get_first_point ().get_right_handle ().type; } - if (lep2.next != null) { + if (lep2.has_next ()) { lep2.get_right_handle ().type = lep2.get_next ().get_left_handle ().type; } else { lep2.get_left_handle ().type = pp.get_last_point ().get_right_handle ().type; @@ -394,11 +394,11 @@ if (Path.distance_to_point (ep, lep2) < 0.1 && Path.distance_to_point (ep, lep) < 0.1) { - if (Path.distance_to_point (lep, (!) lep.prev) < 0.001) { + if (Path.distance_to_point (lep, lep.get_prev ()) < 0.001) { continue; } - if (Path.distance_to_point (lep, (!) lep.next) < 0.001) { + if (Path.distance_to_point (lep, lep.get_next ()) < 0.001) { continue; } @@ -416,14 +416,14 @@ lep2.tie_handles = false; lep2.reflective_point = false; } else { - if (lep.prev != null && Path.distance_to_point (lep, (!) lep.prev) < 0.00000001) { + if (lep.has_prev () && Path.distance_to_point (lep, lep.get_prev ()) < 0.00000001) { lep.get_prev ().flags |= EditPoint.INTERSECTION; lep.get_prev ().tie_handles = false; lep.get_prev ().reflective_point = false; continue; } - if (lep.next != null && Path.distance_to_point (lep, (!) lep.next) < 0.00000001) { + if (lep.has_next () && Path.distance_to_point (lep, lep.get_next ()) < 0.00000001) { lep.get_next ().flags |= EditPoint.INTERSECTION; lep.get_next ().tie_handles = false; lep.get_next ().reflective_point = false; @@ -528,8 +528,8 @@ if (lep.get_right_handle ().type == PointType.DOUBLE_CURVE || lep.get_right_handle ().type == PointType.LINE_DOUBLE_CURVE) { - return_if_fail (lep.prev != null); - return_if_fail (lep.next != null); + return_if_fail (lep.has_prev ()); + return_if_fail (lep.has_next ()); before = lep.get_prev (); after = lep.get_next (); @@ -907,7 +907,7 @@ if ((ep1.flags & EditPoint.INTERSECTION) > 0) { first_point.left_handle.move_to_coordinate (previous.left_handle.x, previous.left_handle.y); - if (first_point.next != null) { + if (first_point.has_next ()) { h = first_point.get_next ().get_left_handle (); h.process_connected_handle (); } @@ -1222,7 +1222,6 @@ last.convert_to_line (); last.recalculate_linear_handles (); - last.next = stroke1.add_point (stroke2.get_first_point ()).get_link_item (); stroke2.delete_first_point (); last.get_left_handle ().convert_to_curve (); @@ -1374,7 +1373,7 @@ double or = original.get_right_handle ().angle; double ol = original.get_left_handle ().angle; - if (previous.prev == null) { // FIXME: first point + if (!previous.has_prev ()) { // FIXME: first point warning ("Point before corner."); d1 = false; d2 = false; @@ -1711,14 +1710,6 @@ EditPoint ep3 = new EditPoint (); double d; - if (next == path.get_first_point ()) { - ep1.prev = null; - } else { - ep1.prev = prev; - } - - ep1.prev = prev; - ep1.next = ep2; ep1.flags |= EditPoint.NEW_CORNER | EditPoint.SPLIT_POINT; ep1.type = prev.type; ep1.x = px; @@ -1726,17 +1717,13 @@ ep1.color = c; n.add (ep1); - ep2.prev = ep1; - ep2.next = ep3; ep2.flags |= EditPoint.INTERSECTION | EditPoint.SPLIT_POINT; ep2.type = prev.type; ep2.x = px; ep2.y = py; ep2.color = c; n.add (ep2); - - ep3.prev = ep2; - ep3.next = next; + ep3.flags |= EditPoint.NEW_CORNER | EditPoint.SPLIT_POINT; ep3.type = prev.type; ep3.x = px; @@ -1747,7 +1734,7 @@ next.get_left_handle ().convert_to_line (); foreach (EditPoint np in n) { - np = path.add_point_after (np, np.prev); + np = path.add_point_after (np, np.get_prev ()); path.create_list (); }
--- a/libbirdfont/TrackTool.vala +++ b/libbirdfont/TrackTool.vala @@ -577,7 +577,7 @@ return; } - if (average.prev != null && average.get_prev ().tie_handles) { + if (average.has_prev () && average.get_prev ().tie_handles) { if (p.points.size > 2) { previous = average.get_prev (); previous.type = DrawingTools.point_type;