The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Update freehand drawing to work with stroke

These changes was commited to the Birdfont repository Fri, 01 May 2015 06:50:54 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
author Johan Mattsson <johan.mattsson.m@gmail.com>
Fri, 01 May 2015 06:50:54 +0000 (08:50 +0200)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Fri, 01 May 2015 06:50:54 +0000 (08:50 +0200)
commit cdf97ad7d8b88b61568cb1a8790d9027167faab3
tree b8c329bedc7619f556ef6a37564bb3a5380a1815
parent e749eab9679badec1b6d53fa8cb7cf6fed32d908
Update freehand drawing to work with stroke

libbirdfont/ForesightTool.vala
libbirdfont/Path.vala
libbirdfont/PenTool.vala
libbirdfont/TrackTool.vala
--- a/libbirdfont/ForesightTool.vala +++ b/libbirdfont/ForesightTool.vala @@ -158,14 +158,6 @@ state = MOVE_FIRST_HANDLE; release_action(this, b, x, y); } - } - }); - - double_click_action.connect ((self, b, x, y) => { - Tool p = PointTool.pen (); - - if (!BirdFont.android) { - p.double_click_action (p, b, x, y); } });
--- a/libbirdfont/Path.vala +++ b/libbirdfont/Path.vala @@ -1467,6 +1467,9 @@ x = quadratic_bezier_path (step, start.x, start.get_right_handle ().x, stop.x); y = quadratic_bezier_path (step, start.y, start.get_right_handle ().y, stop.y); } 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 {
--- a/libbirdfont/PenTool.vala +++ b/libbirdfont/PenTool.vala @@ -138,7 +138,6 @@ 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); });
--- a/libbirdfont/TrackTool.vala +++ b/libbirdfont/TrackTool.vala @@ -51,6 +51,7 @@ /** 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 @@ } if (button == 1) { + return_if_fail (!drawing); + draw_freehand = true; last_x = x; @@ -96,13 +99,14 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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. */