Commit 1ba5925
Create groups of counter paths
Changed files (10)
modifiedlibbirdfont/BezierTool.valamodifiedlibbirdfont/ClipTool.valamodifiedlibbirdfont/ColorPicker.valamodifiedlibbirdfont/Glyph.valamodifiedlibbirdfont/Gradient.valamodifiedlibbirdfont/Layer.valamodifiedlibbirdfont/MenuTab.valamodifiedlibbirdfont/MoveTool.valamodifiedlibbirdfont/PenTool.valamodifiedlibbirdfont/SvgParser.vala
Diff
@@ -148,7 +148,7 @@ public class BezierTool : Tool { current_point.recalculate_linear_handles (); set_point_type (); g.clear_active_paths ();- g.add_active_path (current_path);+ g.add_active_path (null, current_path); GlyphCanvas.redraw (); state = MOVE_POINT; } else {@@ -254,7 +254,7 @@ public class BezierTool : Tool { current_point.recalculate_linear_handles (); set_point_type (); g.clear_active_paths ();- g.add_active_path (current_path);+ g.add_active_path (null, current_path); GlyphCanvas.redraw (); state = MOVE_POINT;@@ -408,7 +408,7 @@ public class ClipTool : Tool { foreach (Path p in glyph.get_all_paths ()) { PenTool.clear_directions (); destination.add_path (p);- destination.add_active_path (p);+ destination.add_active_path (null, p); } if (paste_guide_lines) {@@ -244,9 +244,11 @@ public class ColorPicker : Tool { cr.restore (); } + bool found = false; for (int i = 0; i < gradient.stops.size; i++) { Stop s = gradient.stops.get (i); if (s == current_stop) {+ found = true; cr.save (); Theme.color (cr, "Tool Foreground"); cr.set_line_width (1);@@ -255,6 +257,10 @@ public class ColorPicker : Tool { cr.restore (); } }+ + if (!found) {+ warning ("No stop selected.");+ } } }@@ -109,7 +109,8 @@ public class Glyph : FontDisplay { public Layer layers = new Layer (); public int current_layer = 0; public Gee.ArrayList<Path> active_paths = new Gee.ArrayList<Path> ();- + public Gee.ArrayList<Layer> selected_groups = new Gee.ArrayList<Layer> ();+ public Glyph (string name, unichar unichar_code = 0) { this.name = name; this.unichar_code = unichar_code;@@ -213,11 +214,14 @@ public class Glyph : FontDisplay { } public void clear_active_paths () { + selected_groups.clear (); active_paths.clear (); } - public void add_active_path (Path? p) {+ public void add_active_path (Layer? group, Path? p) { Path path;+ Layer g;+ if (p != null) { path = (!) p; @@ -232,6 +236,13 @@ public class Glyph : FontDisplay { } PenTool.active_path = path; }++ if (group != null) {+ g = (!) group;+ if (!selected_groups.contains (g)) {+ selected_groups.add (g);+ }+ } } public void delete_background () {@@ -828,7 +839,7 @@ public class Glyph : FontDisplay { path.reopen (); path.create_list (); - add_active_path (path);+ add_active_path (null, path); } if (remaining_points.paths.size > 0) {@@ -941,7 +952,7 @@ public class Glyph : FontDisplay { public void set_active_path (Path p) { p.reopen (); clear_active_paths ();- add_active_path (p);+ add_active_path (null, p); } /** Move view port centrum to this coordinate. */@@ -1103,6 +1114,7 @@ public class Glyph : FontDisplay { if (pt.is_over (x, y)) { Layer layer = new Layer (); layer.is_counter = true;+ layer.single_path = true; layer.add_path (pt); group = layer; }@@ -1127,7 +1139,7 @@ public class Glyph : FontDisplay { clear_active_paths (); } - add_active_path (p);+ add_active_path (null, p); return found; }@@ -1925,7 +1937,7 @@ public class Glyph : FontDisplay { clear_active_paths (); foreach (Path p in g.active_paths) {- add_active_path (p);+ add_active_path (null, p); } redraw_area (0, 0, allocation.width, allocation.height); @@ -18,14 +18,19 @@ using Math; namespace BirdFont { public class Gradient : GLib.Object {- public double x1 = 0;- public double y1 = 0;- public double x2 = 0;- public double y2 = 0;- - public Gee.ArrayList<Stop> stops = new Gee.ArrayList<Stop> ();+ public double x1;+ public double y1;+ public double x2;+ public double y2;++ public Gee.ArrayList<Stop> stops; public Gradient () {+ x1 = 0;+ y1 = 0;+ x2 = 0;+ y2 = 0;+ stops = new Gee.ArrayList<Stop> (); } public Gradient copy () {@@ -33,7 +38,7 @@ public class Gradient : GLib.Object { g.x1 = x1; g.y1 = y1; g.x2 = x2;- g.x2 = y2;+ g.y2 = y2; foreach (Stop s in stops) { g.stops.add (s.copy ());@@ -19,7 +19,10 @@ public class Layer : GLib.Object { public Gee.ArrayList<Layer> subgroups; public bool visible = true; public string name = "Layer";+ public bool is_counter = false;+ public Gradient? gradient = null;+ public bool single_path = false; public Layer () { paths = new PathList ();@@ -560,7 +560,7 @@ public class MenuTab : FontDisplay { // selected segments if (paths.size == 0) { foreach (Path p in g.get_all_paths ()) {- g.add_active_path (p);+ g.add_active_path (null, p); } foreach (Path p in g.active_paths) {@@ -580,7 +580,7 @@ public class MenuTab : FontDisplay { foreach (Path p in paths) { g.layers.add_path (p);- g.add_active_path (p);+ g.add_active_path (null, p); } g.active_paths.clear ();@@ -112,6 +112,7 @@ public class MoveTool : Tool { double dx = last_x - x; double dy = last_y - y; double p = PenTool.precision;+ double delta_x, delta_y; if (!move_path) { return;@@ -119,8 +120,22 @@ 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;+ + foreach (Layer group in glyph.selected_groups) {+ if (group.gradient != null) {+ Gradient g = (!) group.gradient;+ g.x1 += delta_x;+ g.x2 += delta_x;+ g.y1 += delta_y;+ g.y2 += delta_y;+ }+ }+ foreach (Path path in glyph.active_paths) {- path.move (Glyph.ivz () * -dx * p, Glyph.ivz () * dy * p);+ path.move (delta_x, delta_y); } } @@ -196,9 +211,10 @@ public class MoveTool : Tool { foreach (Path lp in g.paths.paths) { if (selected && KeyBindings.has_shift ()) {+ glyph.selected_groups.remove ((!) group); glyph.active_paths.remove (lp); } else {- glyph.add_active_path (lp);+ glyph.add_active_path ((!) group, lp); } } } else if (!KeyBindings.has_shift ()) {@@ -236,7 +252,7 @@ public class MoveTool : Tool { foreach (Path p in glyph.get_paths_in_current_layer ()) { if (p.xmin > x1 && p.xmax < x2 && p.ymin < y1 && p.ymax > y2) { if (p.points.size > 0) {- glyph.add_active_path (p);+ glyph.add_active_path (null, p); } } }@@ -474,7 +490,7 @@ public class MoveTool : Tool { g.clear_active_paths (); foreach (Path p in g.get_paths_in_current_layer ()) { if (p.points.size > 0) {- g.add_active_path (p);+ g.add_active_path (null, p); } } @@ -1160,7 +1160,7 @@ public class PenTool : Tool { if (active_edit_point != null) { glyph.clear_active_paths ();- glyph.add_active_path (active_path);+ glyph.add_active_path (null, active_path); DrawingTools.update_stroke_settings (); if (KeyBindings.modifier == SHIFT) {@@ -1352,7 +1352,7 @@ public class PenTool : Tool { foreach (Path merge in paths) { if (merge.points.size > 0) { if (is_close_to_point (merge.points.get (merge.points.size - 1), px, py)) {- glyph.add_active_path (merge);+ glyph.add_active_path (null, merge); active_path = merge; merge.reopen (); glyph.open_path ();@@ -1360,7 +1360,7 @@ public class PenTool : Tool { } if (is_close_to_point (merge.points.get (0), px, py)) {- glyph.add_active_path (merge);+ glyph.add_active_path (null, merge); active_path = merge; clear_directions (); merge.reopen ();@@ -1397,7 +1397,7 @@ public class PenTool : Tool { force_direction (); glyph.clear_active_paths ();- glyph.add_active_path (path);+ glyph.add_active_path (null, path); if (direction_changed) { path.reverse ();@@ -1440,7 +1440,7 @@ public class PenTool : Tool { glyph.delete_path (path); glyph.delete_path (merge); glyph.clear_active_paths ();- glyph.add_active_path (union);+ glyph.add_active_path (null, union); union.reopen (); union.create_list ();@@ -1722,7 +1722,7 @@ public class PenTool : Tool { active_path = new_point.path; glyph.clear_active_paths ();- glyph.add_active_path (new_point.path);+ glyph.add_active_path (null, new_point.path); move_selected = true; @@ -1767,7 +1767,7 @@ public class PenTool : Tool { np.stroke = stroke ? StrokeTool.stroke_width : 0; np.line_cap = StrokeTool.line_cap; - g.add_active_path (np);+ g.add_active_path (null, np); active_path = np; selected_path = np;@@ -1793,7 +1793,7 @@ public class PenTool : Tool { } g.clear_active_paths ();- g.add_active_path (np);+ g.add_active_path (null, np); active_path = np; selected_path = np; @@ -1998,7 +1998,7 @@ public class PenTool : Tool { selected_handle.selected = true; active_path = p.path;- g.add_active_path (active_path);+ g.add_active_path (null, active_path); } public static void add_selected_point (EditPoint p, Path path) {@@ -133,7 +133,7 @@ public class SvgParser { } foreach (Path p in path_list.paths) {- glyph.add_active_path (p);+ glyph.add_active_path (null, p); // FIXME: groups p.update_region_boundaries (); }