Clone in a terminal:
Commit 400013d
Johan Mattsson - 2015-06-05T21:09:34+00:00
400013d3ebc8b32c12811fb54a8b044764ffb325johan.mattsson.m@gmail.com

Draw color in color toolbox

Changed files (7)

Diff

diff --git a/libbirdfont/Color.vala b/libbirdfont/Color.valaindex 6bbca71..a720fa0 100644--- a/libbirdfont/Color.vala+++ b/libbirdfont/Color.vala@@ -66,6 +66,14 @@ public class Color { 	public static Color magenta () { 		return new Color (103.0 / 255, 33.0 / 255, 120.0 / 255, 1); 	}+	+	public string to_string () {+		return @"r: $r, g: $g, b: $b, a: $a";+	}+	+	public Color copy () {+		return new Color (r, g, b, a);+	} }  }diff --git a/libbirdfont/ColorTool.vala b/libbirdfont/ColorTool.valaindex f7f932e..ddb938c 100644--- a/libbirdfont/ColorTool.vala+++ b/libbirdfont/ColorTool.vala@@ -33,7 +33,7 @@ public class ColorTool : Tool { 		}); 		 		color_updated.connect (() => {-			MainWindow.get_toolbox ().redraw ((int)x, (int)y, (int)x + 20, (int)y + 20);+			redraw (); 			GlyphCanvas.redraw (); 		}); 	}@@ -43,15 +43,18 @@ public class ColorTool : Tool { 	} 	 	public void signal_color_updated () {+		print (get_color ().to_string ()); 		color_updated (); 	} 	-	public override void draw (Context cr) {+	public override void draw_tool (Context cr, double px, double py) { 		double scale = Toolbox.get_scale ();+		double x = this.x - px;+		double y = this.y - py; 		double xt = x + w / 2 - 8 * scale; 		double yt = y + h / 2 - 8 * scale;-		-		base.draw (cr);+				+		base.draw_tool (cr, px, py); 		 		cr.save (); 		cr.set_source_rgba (color_r, color_g, color_b, 1);diff --git a/libbirdfont/Glyph.vala b/libbirdfont/Glyph.valaindex dd3c902..b91da39 100644--- a/libbirdfont/Glyph.vala+++ b/libbirdfont/Glyph.vala@@ -55,7 +55,7 @@ public class Glyph : FontDisplay { 	double zoom_y1 = 0; 	double zoom_x2 = 0; 	double zoom_y2 = 0;-	bool zoom_area_is_visible = false;+	public bool zoom_area_is_visible = false; 	 	bool view_is_moving = false; 	public double move_offset_x = 0;@@ -73,7 +73,7 @@ public class Glyph : FontDisplay { 	// x-height, lsb, etc. 	public Gee.ArrayList<Line> vertical_help_lines = new Gee.ArrayList<Line> (); 	public Gee.ArrayList<Line> horizontal_help_lines = new Gee.ArrayList<Line> ();-	bool show_help_lines = true;+	public bool show_help_lines = true; 	bool xheight_lines_visible = false; 	bool margin_boundaries_visible = false; 	string new_guide_name = "";@@ -1520,7 +1520,7 @@ public class Glyph : FontDisplay { 		return background_image_visible; 	} 	-	private void draw_coordinate (Context cr) {+	public void draw_coordinate (Context cr) { 		Theme.color (cr, "Table Border"); 		cr.set_font_size (12); 		cr.move_to (0, 10);@@ -1536,7 +1536,6 @@ public class Glyph : FontDisplay { 		cr.save (); 		cr.new_path (); 		foreach (Path p in get_visible_paths ()) {-			 			if (c != null) { 				color = (!) c; 			} else if (p.color != null) {@@ -1601,7 +1600,8 @@ public class Glyph : FontDisplay { 			cr.new_path (); 			foreach (Path p in get_visible_paths ()) { 				if (p.stroke == 0) {-					p.draw_path (cr, this, get_path_fill_color ());+					color = p.color == null ? get_path_fill_color () : (!) p.color;+					p.draw_path (cr, this, color); 				} 			} 			cr.fill ();@@ -1626,7 +1626,8 @@ public class Glyph : FontDisplay { 			cr.new_path (); 			foreach (Path p in get_visible_paths ()) { 				if (p.stroke == 0) {-					p.draw_path (cr, this, Color.black ());+					color = p.color == null ? Color.black () : (!) p.color;+					p.draw_path (cr, this, color); 				} 			} 			cr.close_path ();@@ -1669,7 +1670,7 @@ public class Glyph : FontDisplay { 		} 	} 		-	private void draw_zoom_area(Context cr) {+	public void draw_zoom_area(Context cr) { 		cr.save (); 		cr.set_line_width (2.0); 		Theme.color (cr, "Selection Border");@@ -1678,7 +1679,7 @@ public class Glyph : FontDisplay { 		cr.restore (); 	} -	private void draw_background_color (Context cr, double opacity) {+	public void draw_background_color (Context cr, double opacity) { 		if (opacity > 0) { 			cr.save (); 			cr.rectangle (0, 0, allocation.width, allocation.height);@@ -1688,7 +1689,7 @@ public class Glyph : FontDisplay { 		} 	} 	-	private void draw_help_lines (Context cr) {+	public void draw_help_lines (Context cr) { 		foreach (Line line in get_all_help_lines ()) { 			cr.save (); 			line.draw (cr, allocation);diff --git a/libbirdfont/OverView.vala b/libbirdfont/OverView.valaindex ce5a207..395547a 100644--- a/libbirdfont/OverView.vala+++ b/libbirdfont/OverView.vala@@ -139,7 +139,7 @@ public class OverView : FontDisplay { 		OverviewTools.update_overview_characterset (); 		return glyph_collection; 	}-	+		 	public GlyphCollection add_empty_character_to_font (unichar character, bool unassigned, string name) { 		return add_character_to_font (character, true, unassigned); 	}@@ -210,7 +210,7 @@ public class OverView : FontDisplay { 		return null; 	} 	-	private void set_initial_zoom () {+	public void set_initial_zoom () { 		Toolbox tools = MainWindow.get_toolbox (); 		ZoomTool z = (ZoomTool) tools.get_tool ("zoom_tool"); 		z.store_current_view ();diff --git a/libbirdfont/OverViewItem.vala b/libbirdfont/OverViewItem.valaindex cba08c5..24be580 100644--- a/libbirdfont/OverViewItem.vala+++ b/libbirdfont/OverViewItem.vala@@ -226,7 +226,7 @@ public class OverViewItem : GLib.Object { 			g.add_help_lines (); 			 			c.translate (gx - g.get_lsb () - Glyph.xc (), g.get_baseline () + gy - Glyph.yc ());-			+						 			g.draw_paths (c, color); 			c.restore (); 		} else {diff --git a/libbirdfont/Path.vala b/libbirdfont/Path.valaindex a58115b..33e0fd6 100644--- a/libbirdfont/Path.vala+++ b/libbirdfont/Path.vala@@ -281,7 +281,10 @@ public class Path { 		// fill path 		cr.close_path (); 		-		if (color != null) {+		if (this.color != null) {+			c = (!) this.color;+			cr.set_source_rgba (c.r, c.g, c.b, c.a);+		} else if (color != null) { 			c = (!) color; 			cr.set_source_rgba (c.r, c.g, c.b, c.a); 		} else {diff --git a/libbirdfont/PenTool.vala b/libbirdfont/PenTool.valaindex b91e277..bfbb1dd 100644--- a/libbirdfont/PenTool.vala+++ b/libbirdfont/PenTool.vala@@ -107,7 +107,7 @@ public class PenTool : Tool { 			// retain path direction 			clockwise = new Gee.ArrayList<Path> (); 			counter_clockwise = new Gee.ArrayList<Path> ();-+			 			begin_action_x = x; 			begin_action_y = y; 				

Contact

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