Commit 0d22cd5
recalculate linear handles
Changed files (3)
Diff
@@ -99,6 +99,37 @@ class EditPoint { } } + /** Set bezier points for linear paths. */+ public void recalculate_linear_handles () {+ EditPointHandle h;+ unowned EditPoint n;+ double nx, ny;+ + return_if_fail (type == PointType.LINE);++ // left handle+ if (prev != null) {+ n = get_prev ().data;+ h = get_left_handle ();+ + nx = x + ((n.x - x) / 3);+ ny = y + ((n.y - y) / 3);+ + h.move_to_coordinate (nx, ny); + }+ + // right handle+ if (next != null) {+ n = get_next ().data;+ h = get_right_handle ();+ + nx = x + ((n.x - x) / 3);+ ny = y + ((n.y - y) / 3);+ + h.move_to_coordinate (nx, ny);+ }+ }+ public void set_tie_handle (bool t) { tie_handles = t; }@@ -859,7 +859,7 @@ class Path { ymin = 0; } - // inside and outside in vala lambda functions is not intuitive+ // inside and outside in vala lambda functions is a tricky matter // (look at c code). that's the reason for the !new_val expression xmax = -10000;@@ -82,6 +82,7 @@ class PenTool : Tool { public void move (double x, double y) { Glyph glyph = MainWindow.get_current_glyph ();+ EditPoint ep; control_point_event (x, y); @@ -116,11 +117,10 @@ class PenTool : Tool { // move edit point if (move_selected) { glyph.move_selected_edit_point (x, y);+ ep = (!) glyph.selected_point; if (tie_x_or_y_coordinates) { return_if_fail (glyph.selected_point != null);- - EditPoint ep = (!) glyph.selected_point; GridTool.tie_to_prev (ep, x, y); } @@ -132,6 +132,10 @@ class PenTool : Tool { active_corner = (!) active_edit_point; active_corner.set_active_handle (true); }+ + if (ep.type == PointType.LINE) {+ ep.recalculate_linear_handles ();+ } } } @@ -366,25 +370,7 @@ class PenTool : Tool { foreach (EditPoint e in path.points) { if (e.type == PointType.LINE) {- n = e.get_next ().data;- h = e.get_right_handle ();- - nx = e.x + ((n.x - e.x) / 3);- ny = e.y + ((n.y - e.y) / 3);- - h.move_to_coordinate (nx, ny);- }- }- - foreach (EditPoint e in path.points) {- if (e.type == PointType.LINE) {- n = e.get_prev ().data;- h = e.get_left_handle ();- - nx = e.x + ((n.x - e.x) / 3);- ny = e.y + ((n.y - e.y) / 3);- - h.move_to_coordinate (nx, ny);+ e.recalculate_linear_handles (); } } }