The Birdfont Source Code


All Repositories / birdfont.git / commitdiff – RSS feed

Ensure that active paths are unique

These changes was commited to the Birdfont repository Tue, 05 Jan 2016 11:37:28 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
[Tue, 05 Jan 2016 11:37:28 +0000]

Updated Files

libbirdfont/FastPath.vala
libbirdfont/Glyph.vala
libbirdfont/MoveTool.vala
libbirdfont/SaveCallback.vala
--- a/libbirdfont/FastPath.vala +++ b/libbirdfont/FastPath.vala @@ -209,10 +209,6 @@ public override void update_region_boundaries () { path.update_region_boundaries (); - xmax = path.xmax; - xmin = path.xmin; - ymax = path.ymax; - ymin = path.ymin; } public override void rotate (double theta, double xc, double yc) {
--- a/libbirdfont/Glyph.vala +++ b/libbirdfont/Glyph.vala @@ -312,7 +312,7 @@ if (o != null) { object = (!) o; - if (!active_paths.contains (object)) { + if (!active_paths_contains (object)) { active_paths.add (object); } @@ -336,6 +336,29 @@ } } + public bool active_paths_contains (Object object) { + Glyph glyph = MainWindow.get_current_glyph (); + + if (glyph.active_paths.contains (object)) { + return true; + } + + if (object is FastPath) { + FastPath path = (FastPath) object; + + foreach (Object active in glyph.active_paths) { + if (active is FastPath) { + FastPath path_active = (FastPath) active; + if (path_active.get_path () == path.get_path ()) { + return true; + } + } + } + } + + return false; + } + public void delete_background () { store_undo_state (); background_image = null;
--- a/libbirdfont/MoveTool.vala +++ b/libbirdfont/MoveTool.vala @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 2013 Johan Mattsson + Copyright (C) 2012 2013 2015 Johan Mattsson This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -114,9 +114,8 @@ public void move (int x, int y) { Glyph glyph = MainWindow.get_current_glyph (); - double dx = last_x - x; - double dy = last_y - y; - double p = PenTool.precision; + double dx = Glyph.path_coordinate_x (last_x) - Glyph.path_coordinate_x (x); + double dy = Glyph.path_coordinate_y (last_y) - Glyph.path_coordinate_y (y); double delta_x, delta_y; if (!move_path) { @@ -126,8 +125,8 @@ if (move_path && (fabs(dx) > 0 || fabs (dy) > 0)) { moved = true; - delta_x = Glyph.ivz () * -dx * p; - delta_y = Glyph.ivz () * dy * p; + delta_x = -dx; + delta_y = -dy; if (glyph.color_svg_data != null) { glyph.svg_x += delta_x; @@ -143,8 +142,8 @@ } } - foreach (Object path in glyph.active_paths) { - path.move (delta_x, delta_y); + foreach (Object object in glyph.active_paths) { + object.move (delta_x, delta_y); } } } @@ -217,7 +216,7 @@ g = (!) group; return_if_fail (g.objects.objects.size > 0); object = g.objects.objects.get (0); - selected = glyph.active_paths.contains (object); + selected = glyph.active_paths_contains (object); if (!selected && !KeyBindings.has_shift ()) { glyph.clear_active_paths (); @@ -253,8 +252,7 @@ selection_changed (); GlyphCanvas.redraw (); } - - + void select_group () { double x1 = Glyph.path_coordinate_x (Math.fmin (selection_x, last_x)); double y1 = Glyph.path_coordinate_y (Math.fmin (selection_y, last_y));
--- a/libbirdfont/SaveCallback.vala +++ b/libbirdfont/SaveCallback.vala @@ -28,7 +28,7 @@ } public void save_as () { - if (MenuTab.has_suppress_event ()) { + if (unlikely (MenuTab.has_suppress_event ())) { warn_if_test ("Event suppressed"); return; } @@ -54,6 +54,7 @@ file_name = @"$(f)"; file = File.new_for_path (file_name); font_file_path = (!) file.get_path (); + if (!file.query_exists ()) { save (); } else {