The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Fix gradient

These changes was commited to the Birdfont repository Mon, 15 Jun 2015 14:29:14 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
author Johan Mattsson <johan.mattsson.m@gmail.com>
Mon, 15 Jun 2015 14:29:14 +0000 (16:29 +0200)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Mon, 15 Jun 2015 14:29:14 +0000 (16:29 +0200)
commit 5f1243e4d78ef6f833659b924cd49824fa4795b0
tree ce8d58db9238ffce75e0c3060db90abb839b4baa
parent e147293b45c01d5d5eceba16347a46ac68a80b71
Fix gradient

libbirdfont/ColorPicker.vala
libbirdfont/DrawingTools.vala
libbirdfont/Path.vala
--- 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,7 +242,10 @@ cr.rectangle (i * stop_size, y + 4 * bar_height, stop_size, bar_height); cr.fill (); cr.restore (); - + } + + for (int i = 0; i < gradient.stops.size; i++) { + Stop s = gradient.stops.get (i); if (s == current_stop) { cr.save (); Theme.color (cr, "Tool Foreground");
--- a/libbirdfont/DrawingTools.vala +++ b/libbirdfont/DrawingTools.vala @@ -1386,7 +1386,9 @@ hide_all_modifiers (); foreach (Tool t in draw_tools.tool) { - t.set_selected (false); + if (t != current_tool) { + t.set_selected (false); + } } cut_background.set_selected (false); @@ -1415,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/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) {