The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Draw unselected object when pen tool is used

These changes was commited to the Birdfont repository Fri, 01 May 2015 08:57:35 +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 08:57:35 +0000 (10:57 +0200)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Fri, 01 May 2015 08:57:35 +0000 (10:57 +0200)
commit 70a5373280b8e5c7c839a62f42fce3cd854774e0
tree 599bbab9bdc057cc563ffb1e3f850bcb9ed0d3a3
parent 5a02ce729c7a66f643e2c367af21089262a7d437
Draw unselected object when pen tool is used

libbirdfont/Glyph.vala
libbirdfont/Path.vala
--- a/libbirdfont/Glyph.vala +++ b/libbirdfont/Glyph.vala @@ -1544,17 +1544,21 @@ cr.fill (); cr.restore (); - cr.save (); - cr.new_path (); - foreach (Path p in active_paths) { - if (p.stroke > 0) { - stroke = p.get_stroke_fast (); - color = Theme.get_color ("Selected Objects"); - draw_path_list (stroke, cr, color); + if (!(MainWindow.get_toolbox ().get_current_tool () is PenTool) + && !(MainWindow.get_toolbox ().get_current_tool () is PointTool) + && !(MainWindow.get_toolbox ().get_current_tool () is TrackTool)) { + cr.save (); + cr.new_path (); + foreach (Path p in active_paths) { + if (p.stroke > 0) { + stroke = p.get_stroke_fast (); + color = Theme.get_color ("Selected Objects"); + draw_path_list (stroke, cr, color); + } } + cr.fill (); + cr.restore (); } - cr.fill (); - cr.restore (); if (is_open () && Path.fill_open_path) { cr.save (); @@ -1581,6 +1585,7 @@ if (!is_open ()) { // This was good for testing but it is way too slow: // Svg.draw_svg_path (cr, get_svg_data (), Glyph.xc () + left, Glyph.yc () - baseline); + cr.save (); cr.new_path ();
--- a/libbirdfont/Path.vala +++ b/libbirdfont/Path.vala @@ -815,13 +815,26 @@ return Math.fabs (Math.sqrt (x * x + y * y)); } + public Path flatten () { + Path flat = new Path (); + + all_of_path ((x, y, t) => { + flat.add (x, y); + return true; + }); + + return flat; + } + /** Variable precision */ public bool is_over_coordinate_var (double x, double y) { int insides = 0; + Path path; if (stroke > 0) { foreach (Path p in get_stroke_fast ().paths) { - if (StrokeTool.is_inside (new EditPoint (x, y), p)) { + path = p.flatten (); + if (StrokeTool.is_inside (new EditPoint (x, y), path)) { insides++; } } @@ -830,7 +843,8 @@ return true; } } else if (is_over_boundry (x, y)) { - return StrokeTool.is_inside (new EditPoint (x, y), this); + path = flatten (); + return StrokeTool.is_inside (new EditPoint (x, y), path); } return false;