Clone in a terminal:
Commit 5f1243e
Johan Mattsson - 2015-06-15T14:29:14+00:00
5f1243e4d78ef6f833659b924cd49824fa4795b0johan.mattsson.m@gmail.com

Fix gradient

Changed files (3)

Diff

diff --git a/libbirdfont/ColorPicker.vala b/libbirdfont/ColorPicker.valaindex 43e30e9..647e404 100644--- a/libbirdfont/ColorPicker.vala+++ b/libbirdfont/ColorPicker.vala@@ -76,11 +76,10 @@ public class ColorPicker : Tool { 		}); 	} 	-	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 @@ public class ColorPicker : Tool { 			} 		} 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 @@ public class ColorPicker : Tool { 				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");diff --git a/libbirdfont/DrawingTools.vala b/libbirdfont/DrawingTools.valaindex f9ea514..15da15f 100644--- a/libbirdfont/DrawingTools.vala+++ b/libbirdfont/DrawingTools.vala@@ -1386,7 +1386,9 @@ public class DrawingTools : ToolCollection  { 			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 @@ public class DrawingTools : ToolCollection  { 			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 ();diff --git a/libbirdfont/Path.vala b/libbirdfont/Path.valaindex ed61fe4..28da126 100644--- a/libbirdfont/Path.vala+++ b/libbirdfont/Path.vala@@ -761,6 +761,10 @@ public class Path : GLib.Object { 			p = ep.copy (); 			new_path.add_point (p); 		}++		if (gradient != null) {+			new_path.gradient = ((!) gradient).copy ();+		} 		 		if (color != null) { 			new_path.color = ((!) color).copy ();

Contact

Email: johan.mattsson.m@gmail.com
Mastodon: typo.social/@birdfont
GitHub: johanmattssonm
LinkedIn: johan-mattsson-2ab324112