Commit 6779e73
Ensure that active paths are unique
Changed files (4)
modifiedlibbirdfont/FastPath.valamodifiedlibbirdfont/Glyph.valamodifiedlibbirdfont/MoveTool.valamodifiedlibbirdfont/SaveCallback.vala
Diff
@@ -209,10 +209,6 @@ public class FastPath : Object { 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) {@@ -312,7 +312,7 @@ public class Glyph : FontDisplay { if (o != null) { object = (!) o; - if (!active_paths.contains (object)) {+ if (!active_paths_contains (object)) { active_paths.add (object); } @@ -336,6 +336,29 @@ public class Glyph : FontDisplay { } } + 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;@@ -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 class MoveTool : Tool { 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 @@ public class MoveTool : Tool { 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 @@ public class MoveTool : Tool { } } - 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 @@ public class MoveTool : Tool { 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 @@ public class MoveTool : Tool { 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));@@ -28,7 +28,7 @@ public class SaveCallback : GLib.Object { } 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 @@ public class SaveCallback : GLib.Object { file_name = @"$(f)"; file = File.new_for_path (file_name); font_file_path = (!) file.get_path ();+ if (!file.query_exists ()) { save (); } else {