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