The Birdfont Source Code


All Repositories / birdfont.git / commitdiff – RSS feed

Create groups of counter paths

These changes was commited to the Birdfont repository Wed, 17 Jun 2015 20:00:40 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
[Wed, 17 Jun 2015 20:00:40 +0000]

Updated Files

libbirdfont/BezierTool.vala
libbirdfont/ClipTool.vala
libbirdfont/ColorPicker.vala
libbirdfont/Glyph.vala
libbirdfont/Gradient.vala
libbirdfont/Layer.vala
libbirdfont/MenuTab.vala
libbirdfont/MoveTool.vala
libbirdfont/PenTool.vala
libbirdfont/SvgParser.vala
--- a/libbirdfont/BezierTool.vala +++ b/libbirdfont/BezierTool.vala @@ -148,7 +148,7 @@ 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 @@ 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;
--- a/libbirdfont/ClipTool.vala +++ b/libbirdfont/ClipTool.vala @@ -408,7 +408,7 @@ 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) {
--- a/libbirdfont/ColorPicker.vala +++ b/libbirdfont/ColorPicker.vala @@ -244,9 +244,11 @@ 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); @@ -254,6 +256,10 @@ cr.stroke (); cr.restore (); } + } + + if (!found) { + warning ("No stop selected."); } }
--- a/libbirdfont/Glyph.vala +++ b/libbirdfont/Glyph.vala @@ -109,7 +109,8 @@ 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 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; @@ -231,6 +235,13 @@ active_paths.add (path); } PenTool.active_path = path; + } + + if (group != null) { + g = (!) group; + if (!selected_groups.contains (g)) { + selected_groups.add (g); + } } } @@ -828,7 +839,7 @@ 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 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 @@ 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 @@ clear_active_paths (); } - add_active_path (p); + add_active_path (null, p); return found; } @@ -1925,7 +1937,7 @@ 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);
--- a/libbirdfont/Gradient.vala +++ b/libbirdfont/Gradient.vala @@ -18,14 +18,19 @@ 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 @@ 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 ());
--- a/libbirdfont/Layer.vala +++ b/libbirdfont/Layer.vala @@ -19,7 +19,10 @@ 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 ();
--- a/libbirdfont/MenuTab.vala +++ b/libbirdfont/MenuTab.vala @@ -560,7 +560,7 @@ // 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 @@ 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 ();
--- a/libbirdfont/MoveTool.vala +++ b/libbirdfont/MoveTool.vala @@ -112,6 +112,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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); } }
--- a/libbirdfont/PenTool.vala +++ b/libbirdfont/PenTool.vala @@ -1160,7 +1160,7 @@ 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 @@ 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 @@ } 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ } 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 @@ 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) {
--- a/libbirdfont/SvgParser.vala +++ b/libbirdfont/SvgParser.vala @@ -133,7 +133,7 @@ } foreach (Path p in path_list.paths) { - glyph.add_active_path (p); + glyph.add_active_path (null, p); // FIXME: groups p.update_region_boundaries (); }