Commit 880bd56
Fix drawing problem in vector tool
Changed files (3)
modifiedlibbirdfont/ForesightTool.valamodifiedlibbirdfont/Glyph.valamodifiedlibbirdfont/Tool.vala
Diff
@@ -66,6 +66,8 @@ public class ForesightTool : Tool { EditPoint first_point; bool clockwise; + MainWindow.get_current_glyph ().store_undo_state ();+ last_move_x = x; last_move_y = y; @@ -195,7 +197,7 @@ public class ForesightTool : Tool { return; } last = PenTool.selected_points.get (PenTool.selected_points.size - 1);- //last.point.convert_to_curve ();+ last.point.convert_to_curve (); } PenTool.move_selected_handle = true;@@ -215,9 +217,19 @@ public class ForesightTool : Tool { PenTool.selected_handle = h; PenTool.active_handle = h; + if (previous_point == 0 + && !last.point.reflective_point+ && !last.point.tie_handles) {+ + last.point.convert_to_curve ();+ last.point.set_reflective_handles (true);+ last.point.get_right_handle ().length = 0.01;+ last.point.get_left_handle ().length = 0.01;+ }+ if (previous_point == 0) { last.point.set_reflective_handles (true);- } + } if (previous_point > 0) { PenTool.retain_angle = last.point.tie_handles;@@ -342,6 +354,34 @@ public class ForesightTool : Tool { return last; }+ + // FIXME: solve the straight line issue in undo+ public override void before_undo () {+ EditPoint last;+ + if (PenTool.active_path.points.size > 1) {+ last = PenTool.active_path.points.get (PenTool.active_path.points.size - 2);+ last.convert_to_curve ();+ + print (@"Before $(last.x) $(last.y)\n");+ }+ }+ + public override void after_undo () {+ PenTool.selected_points.clear ();+ PenTool.active_edit_point = null;+ state = NONE;++ EditPoint last;+ + if (PenTool.active_path.points.size > 0) {+ last = PenTool.active_path.points.get (PenTool.active_path.points.size - 1);+ last.convert_to_curve ();+ + print (@"After $(last.x) $(last.y)\n");+ }+ }+ } }@@ -1703,11 +1703,15 @@ public class Glyph : FontDisplay { public override void undo () { Glyph g;+ Tool tool; if (undo_list.size == 0) { return; } + tool = MainWindow.get_toolbox ().get_current_tool ();+ tool.before_undo ();+ g = undo_list.get (undo_list.size - 1); store_redo_state ();@@ -1718,6 +1722,8 @@ public class Glyph : FontDisplay { PenTool.update_selected_points (); clear_active_paths ();+ + tool.after_undo (); } public override void redo () {@@ -352,6 +352,13 @@ public class Tool : Widget { public void set_persistent (bool p) { persistent = p; }+ + public virtual void before_undo () {+ }++ public virtual void after_undo () {+ }+ } }