Clone in a terminal:
Commit c71d2bd
Johan Mattsson - 2015-03-16T10:42:56+00:00
c71d2bdb9c8f70194df7f15b1a4b3c5543bb3099johan.mattsson.m@gmail.com

Draw overview glyph count with cairo

Changed files (6)

Diff

diff --git a/icons/no_icon.png b/icons/no_icon.pngdeleted file mode 100644index 7ddb2f4..0000000Binary files a/icons/no_icon.png and /dev/null differdiff --git a/icons/overview_counter.png b/icons/overview_counter.pngdeleted file mode 100644index 385c162..0000000Binary files a/icons/overview_counter.png and /dev/null differdiff --git a/icons/slow_test.png b/icons/slow_test.pngdeleted file mode 100644index f7a3d3e..0000000Binary files a/icons/slow_test.png and /dev/null differdiff --git a/icons/test_case.png b/icons/test_case.pngdeleted file mode 100644index 77b2b1c..0000000Binary files a/icons/test_case.png and /dev/null differdiff --git a/icons/version.png b/icons/version.pngdeleted file mode 100644index f6b2462..0000000Binary files a/icons/version.png and /dev/null differdiff --git a/libbirdfont/LabelTool.vala b/libbirdfont/LabelTool.valaindex d8d45a9..efef1de 100644--- a/libbirdfont/LabelTool.vala+++ b/libbirdfont/LabelTool.vala@@ -18,13 +18,15 @@ namespace BirdFont {  public class LabelTool : Tool { -	private static ImageSurface? counter_background = null; 	public string label { get; set; } 	public string number { get; set; } 	public bool has_counter { get; set; } 	public bool has_delete_button { get; set; } 	public signal void delete_action (LabelTool self); +	double counter_box_width = 22;+	double counter_box_height = 11;+ 	public LabelTool (string label) { 		base (); @@ -33,8 +35,7 @@ public class LabelTool : Tool { 		 		has_delete_button = false; 		has_counter = false;-		counter_background = Icons.get_icon ("overview_counter.png");-		+ 		panel_press_action.connect ((selected, button, tx, ty) => { 			if (has_delete_button && y <= ty <= y + h && tx >= w - 30) { 				delete_action (this);@@ -49,7 +50,7 @@ public class LabelTool : Tool { 	public override void draw (Context cr) { 		Text label_text, glyph_count; 		double text_height;-		double scale, bgx, bgy;+		double bgx, bgy; 		double center_x, center_y; 		 		// background@@ -78,39 +79,33 @@ public class LabelTool : Tool { 		cr.restore ();  		// glyph count-		if (has_counter && counter_background != null) {+		if (has_counter) { 			cr.save ();-			scale = 30.0 / 111.0; // scale to 320 dpi-			cr.scale (scale, scale);-			-			bgx = Toolbox.allocation_width / scale - ((!) counter_background).get_width () - 15 / scale;-			bgy = y / scale + 2 / scale;-			-			cr.set_source_surface ((!) counter_background, bgx, bgy);-			cr.paint ();+			bgx = Toolbox.allocation_width - counter_box_width - 15;+			bgy = y + 2;++			Theme.color (cr, "Background 3");+			draw_rounded_rectangle (cr, bgx, bgy, counter_box_width, counter_box_height, 3);+			cr.fill ();+			cr.restore (); 			 			glyph_count = new Text (); 			glyph_count.set_text (@"$(this.number)");-			text_height = 12 / scale;+			text_height = 13; 			 			glyph_count.set_font_size (text_height);-			center_x = bgx + ((!) counter_background).get_width () / 2.0  - glyph_count.get_extent () / 2.0;-			center_y = bgy + ((!) counter_background).get_height () / 2.0 + 4 / scale;-			-			if (is_selected ()) {-				Theme.text_color (glyph_count, "Background 1");-			} else {-				Theme.text_color (glyph_count, "Background 4");-			}-			+			center_x = bgx + (counter_box_width / 2.0  - glyph_count.get_extent () / 2.0);+			center_y = bgy + (counter_box_height / 2.0 + 5);++			Theme.text_color (glyph_count, "Foreground Inverted");+	 			glyph_count.set_font_size (text_height); 			glyph_count.draw_at_baseline (cr, center_x, center_y);-									-			cr.restore (); 		} 		 		if (has_delete_button) { 			cr.save ();+			Theme.color (cr, "Foreground Inverted"); 			cr.set_line_width (1); 			cr.move_to (w - 20, y + h / 2 - 2.5 + 2); 			cr.line_to (w - 25, y + h / 2 + 2.5 + 2);

Contact

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