The Birdfont Source Code


All Repositories / birdfont.git / commitdiff – RSS feed

Merge branch '2.10'

These changes was commited to the Birdfont repository Thu, 18 Jun 2015 21:42: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
[Thu, 18 Jun 2015 21:42:28 +0000]

Updated Files

libbirdfont/BezierTool.vala
libbirdfont/ClipTool.vala
libbirdfont/ColorPicker.vala
libbirdfont/DrawingTools.vala
libbirdfont/Glyph.vala
libbirdfont/Gradient.vala
libbirdfont/Layer.vala
libbirdfont/MenuTab.vala
libbirdfont/MoveTool.vala
libbirdfont/Path.vala
libbirdfont/PathList.vala
libbirdfont/PenTool.vala
libbirdfont/SvgParser.vala
libbirdfont/Toolbox.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 @@ -76,11 +76,10 @@ }); } - public void set_gradient (Gradient g, bool update_gradient) { + public void set_gradient (Gradient g, Stop stop, bool update_gradient) { gradient = g; this.update_gradient = update_gradient; - return_if_fail (g.stops.size > 0); - current_stop = g.stops.get (0); + current_stop = stop; redraw (); } @@ -117,22 +116,25 @@ } } else if (update_gradient && selected_bar == 4) { if (gradient.stops.size > 0) { - int g = (int) ((double) Toolbox.allocation_width / gradient.stops.size); + int g = (int) ((tx / Toolbox.allocation_width) * gradient.stops.size); return_if_fail (0 <= g < gradient.stops.size); current_stop = gradient.stops.get (g); + set_color (current_stop.color); } } - if (update_gradient) { - current_stop.color = new Color.hsba (hue, s, b, a); - gradient_color_updated (); - } else { - if (has_stroke_color && stroke_selected) { - stroke_color = new Color.hsba (hue, s, b, a); - stroke_color_updated (); + if (selected_bar != 4) { + if (update_gradient) { + current_stop.color = new Color.hsba (hue, s, b, a); + gradient_color_updated (); } else { - fill_color = new Color.hsba (hue, s, b, a); - fill_color_updated (); + if (has_stroke_color && stroke_selected) { + stroke_color = new Color.hsba (hue, s, b, a); + stroke_color_updated (); + } else { + fill_color = new Color.hsba (hue, s, b, a); + fill_color_updated (); + } } } } @@ -240,8 +242,13 @@ cr.rectangle (i * stop_size, y + 4 * bar_height, stop_size, bar_height); cr.fill (); 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); @@ -249,6 +256,10 @@ cr.stroke (); cr.restore (); } + } + + if (!found) { + warning ("No stop selected."); } }
--- a/libbirdfont/DrawingTools.vala +++ b/libbirdfont/DrawingTools.vala @@ -1417,7 +1417,6 @@ flip_horizontal.set_selected (false); current_tool.set_selected (true); - //current_tool.select_action (current_tool); if (resize_tool.is_selected () || move_tool.is_selected ()) { show_object_tool_modifiers ();
--- 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; @@ -215,11 +216,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; @@ -233,6 +237,13 @@ active_paths.add (path); } PenTool.active_path = path; + } + + if (group != null) { + g = (!) group; + if (!selected_groups.contains (g)) { + selected_groups.add (g); + } } } @@ -830,7 +841,7 @@ path.reopen (); path.create_list (); - add_active_path (path); + add_active_path (null, path); } if (remaining_points.paths.size > 0) { @@ -943,7 +954,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. */ @@ -1105,6 +1116,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; } @@ -1129,7 +1141,7 @@ clear_active_paths (); } - add_active_path (p); + add_active_path (null, p); return found; } @@ -1927,7 +1939,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,21 @@ 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 int id = -1; + public Gradient () { + x1 = 0; + y1 = 0; + x2 = 0; + y2 = 0; + stops = new Gee.ArrayList<Stop> (); } public Gradient copy () { @@ -33,7 +40,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 (); @@ -85,8 +88,14 @@ foreach (Layer l in subgroups) { layer.subgroups.add (l.copy ()); + } + + if (gradient != null) { + layer.gradient = ((!) gradient).copy (); } + layer.single_path = single_path; + return layer; }
--- 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/Path.vala +++ b/libbirdfont/Path.vala @@ -760,6 +760,10 @@ foreach (EditPoint ep in points) { p = ep.copy (); new_path.add_point (p); + } + + if (gradient != null) { + new_path.gradient = ((!) gradient).copy (); } if (color != null) {
--- a/libbirdfont/PathList.vala +++ b/libbirdfont/PathList.vala @@ -21,6 +21,11 @@ paths = new Gee.ArrayList<Path> (); } + public PathList.for_path (Path p) { + paths = new Gee.ArrayList<Path> (); + paths.add (p); + } + public void remove (Path p) { paths.remove (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 (); }
--- a/libbirdfont/Toolbox.vala +++ b/libbirdfont/Toolbox.vala @@ -232,36 +232,6 @@ if (!action) { scroll_current_set (dy); - } - - redraw_tool_box (); - } - - public void scroll_up (double x, double y) { - bool action = false; - - y -= current_set.scroll; - - if (MenuTab.suppress_event) { - warn_if_test ("Event suppressed"); - return; - } - - if (!scrolling_toolbox) { - foreach (Expander exp in current_set.get_expanders ()) { - if (exp.visible) { - foreach (Tool t in exp.tool) { - if (t.tool_is_visible () && t.is_over (x, y)) { - action = t.scroll_wheel_up_action (t); - press_tool = t; - } - } - } - } - } - - if (!action) { - scroll_current_set (35); } redraw_tool_box (); @@ -284,29 +254,12 @@ suppress_scroll (); } + public void scroll_up (double x, double y) { + scroll_wheel (x, y, 0, 20); + } + public void scroll_down (double x, double y) { - bool action = false; - - y -= current_set.scroll; - - if (!scrolling_toolbox) { - foreach (Expander exp in current_set.get_expanders ()) { - if (exp.visible) { - foreach (Tool t in exp.tool) { - if (t.tool_is_visible () && t.is_over (x, y)) { - action = t.scroll_wheel_down_action (t); - press_tool = t; - } - } - } - } - } - - if (!action) { - scroll_current_set (-35); - } - - redraw_tool_box (); + scroll_wheel (x, y, 0, -20); } void suppress_scroll () {