Commit cdf97ad
Update freehand drawing to work with stroke
Changed files (4)
modifiedlibbirdfont/ForesightTool.valamodifiedlibbirdfont/Path.valamodifiedlibbirdfont/PenTool.valamodifiedlibbirdfont/TrackTool.vala
Diff
@@ -160,14 +160,6 @@ public class ForesightTool : Tool { } } });- - double_click_action.connect ((self, b, x, y) => {- Tool p = PointTool.pen ();- - if (!BirdFont.android) {- p.double_click_action (p, b, x, y);- }- }); release_action.connect ((self, b, x, y) => { PenTool p = (PenTool) PointTool.pen ();@@ -1469,6 +1469,9 @@ public class Path { } else if (right == PointType.CUBIC && left == PointType.CUBIC) { x = bezier_path (step, start.x, start.get_right_handle ().x, stop.get_left_handle ().x, stop.x); y = bezier_path (step, start.y, start.get_right_handle ().y, stop.get_left_handle ().y, stop.y); + } else if (right == PointType.HIDDEN && left == PointType.HIDDEN) {+ x = bezier_path (step, start.x, start.get_right_handle ().x, stop.get_left_handle ().x, stop.x);+ y = bezier_path (step, start.y, start.get_right_handle ().y, stop.get_left_handle ().y, stop.y); } else { 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))"); x = bezier_path (step, start.x, start.get_right_handle ().x, stop.get_left_handle ().x, stop.x);@@ -138,7 +138,6 @@ public class PenTool : Tool { double_click_action.connect ((self, b, x, y) => { last_point_x = Glyph.path_coordinate_x (x); last_point_y = Glyph.path_coordinate_y (y);- press (b, x, y, true); }); @@ -51,6 +51,7 @@ public class TrackTool : Tool { /** Adjust the number of samples per point by this factor. */ double samples_per_point = 1;+ bool drawing = false; public TrackTool (string name) { string sw;@@ -72,6 +73,8 @@ public class TrackTool : Tool { } if (button == 1) {+ return_if_fail (!drawing);+ draw_freehand = true; last_x = x;@@ -96,13 +99,14 @@ public class TrackTool : Tool { glyph.add_path (p); glyph.open_path (); - PenTool.add_new_edit_point (x, y).point;+ PenTool.add_new_edit_point (x, y); } glyph.update_view (); added_points = 0; last_update = get_current_time (); start_update_timer ();+ drawing = true; } }); @@ -111,14 +115,17 @@ public class TrackTool : Tool { release_action.connect ((self, button, x, y) => { if (button == 1 && draw_freehand) {+ return_if_fail (drawing); add_endpoint_and_merge (x, y); } - set_tie ();+ convert_points_to_line ();+ MainWindow.get_current_glyph ().clear_active_paths (); + set_tie (); PenTool.force_direction (); - BirdFont.get_current_font ().touch ();+ drawing = false; }); move_action.connect ((self, x, y) => {@@ -334,12 +341,12 @@ public class TrackTool : Tool { glyph = MainWindow.get_current_glyph (); - if (glyph.path_list.size == 0) {+ if (glyph.active_paths.size == 0) { warning ("No path."); return; } - p = glyph.path_list.get (glyph.path_list.size - 1);+ p = glyph.active_paths.get (glyph.active_paths.size - 1); p.reopen (); px = Glyph.path_coordinate_x (x); py = Glyph.path_coordinate_y (y);@@ -363,12 +370,11 @@ public class TrackTool : Tool { TimeoutSource timer = new TimeoutSource (100); timer.set_callback (() => {- if (draw_freehand) { record_new_position (last_x, last_y); convert_on_timeout (); }- + return draw_freehand; }); @@ -420,12 +426,12 @@ public class TrackTool : Tool { Path get_active_path () { Glyph glyph = MainWindow.get_current_glyph (); - if (glyph.path_list.size == 0) {+ if (glyph.active_paths.size == 0) { warning ("No path."); return new Path (); } - return glyph.path_list.get (glyph.path_list.size - 1); + return glyph.active_paths.get (glyph.active_paths.size - 1); } /** Delete all points close to the pixel at x,y. */