Clone in a terminal:
Commit ca941cc
Johan Mattsson - 2015-03-10T07:02:33+00:00
ca941cc5f9ccb5cd56ef9b6c8e4dd9480f4f55a8johan.mattsson.m@gmail.com

Replace pixly tool button with cairo drawing

Changed files (6)

Diff

diff --git a/icons/tool_button_deselected.png b/icons/tool_button_deselected.pngdeleted file mode 100644index cb080a8..0000000Binary files a/icons/tool_button_deselected.png and /dev/null differdiff --git a/icons/tool_button_deselected_active.png b/icons/tool_button_deselected_active.pngdeleted file mode 100644index a73f693..0000000Binary files a/icons/tool_button_deselected_active.png and /dev/null differdiff --git a/icons/tool_button_selected.png b/icons/tool_button_selected.pngdeleted file mode 100644index 92313ff..0000000Binary files a/icons/tool_button_selected.png and /dev/null differdiff --git a/icons/tool_button_selected_active.png b/icons/tool_button_selected_active.pngdeleted file mode 100644index 1f7918a..0000000Binary files a/icons/tool_button_selected_active.png and /dev/null differdiff --git a/libbirdfont/BirdFont.vala b/libbirdfont/BirdFont.valaindex 6926c8d..9b5d4f0 100644--- a/libbirdfont/BirdFont.vala+++ b/libbirdfont/BirdFont.vala@@ -523,6 +523,18 @@ public class BirdFont { 		 		Theme.save_color ("Background Glyph", 0.2, 0.2, 0.2, 0.5); 		+		Theme.save_color ("Tool Border 1", 38 / 255.0, 39 / 255.0, 43 / 255.0, 1);+		Theme.save_color ("Tool Background 1", 14 / 255.0, 16 / 255.0, 17 / 255.0, 1);++		Theme.save_color ("Tool Border 2", 38 / 255.0, 39 / 255.0, 43 / 255.0, 1);+		Theme.save_color ("Tool Background 2", 26 / 255.0, 30 / 255.0, 32 / 255.0, 1);++		Theme.save_color ("Tool Border 3", 38 / 255.0, 39 / 255.0, 43 / 255.0, 1);+		Theme.save_color ("Tool Background 3", 44 / 255.0, 47 / 255.0, 51 / 255.0, 1);++		Theme.save_color ("Tool Border 4", 38 / 255.0, 39 / 255.0, 43 / 255.0, 1);+		Theme.save_color ("Tool Background 4", 33 / 255.0, 36 / 255.0, 39 / 255.0, 1);+			 		N_("Background 1"); 		N_("Background 2"); 		N_("Background 3");@@ -536,8 +548,26 @@ public class BirdFont { 		N_("Foreground 1"); 		N_("Foreground 2"); 		N_("Foreground 3");+		N_("Foreground 4");+		N_("Foreground 5"); 		 		N_("Highlighted 1");+		N_("Highlighted Guide");+		+		N_("Grid");+		+		N_("Guide 1");+		N_("Guide 2");+		N_("Guide 3");+		+		N_("Tool Border 1");+		N_("Tool Background 1");+		N_("Tool Border 2");+		N_("Tool Background 2");+		N_("Tool Border 3");+		N_("Tool Background 3");+		N_("Tool Border 4");+		N_("Tool Background 4"); 	}  	public static void set_bundle_path (string path) {diff --git a/libbirdfont/Tool.vala b/libbirdfont/Tool.valaindex 3d3db44..3682a24 100644--- a/libbirdfont/Tool.vala+++ b/libbirdfont/Tool.vala@@ -16,13 +16,15 @@ using Cairo;  namespace BirdFont { -public class Tool : GLib.Object {+public class Tool : Widget { 	 	public double x = 0; 	public double y = 0; 	public double w = 33 * Toolbox.get_scale (); 	public double h = (33 / 1.11) * Toolbox.get_scale ();-	++	double scale;+			 	public bool active = false; 	public bool selected = false; 	@@ -86,6 +88,8 @@ public class Tool : GLib.Object { 	public Tool (string? name = null, string tip = "", unichar key = '\0', uint modifier_flag = 0) { 		this.tip = tip; 		+		scale = w / 111.0; // scale to 320 dpi+		 		if (selected_button == null) { 			selected_button = Icons.get_icon ("tool_button_selected.png"); 			active_selected_button = Icons.get_icon ("tool_button_selected_active.png");@@ -120,6 +124,14 @@ public class Tool : GLib.Object { 		}); 	} +	public override double get_height () {+		return 33 * scale;+	}++	public override double get_width () {+		return 33 * scale;+	}+	 	public void set_tool_visibility (bool v) { 		visible = v; 	}@@ -232,18 +244,17 @@ public class Tool : GLib.Object { 		return ret; 	} 	-	public virtual void draw (Context cr) {+	public override void draw (Context cr) { 		double xt = x; 		double yt = y; 		 		double bgx, bgy; 		double iconx, icony; 		-		double scale;--		cr.save ();+		string border = "Foreground 1";+		string background = "Background 1"; 		-		scale = w / 111.0; // scale to 320 dpi+		cr.save (); 		 		if (unlikely (scale == 0)) { 			warning ("Scale is zero.");@@ -257,25 +268,34 @@ public class Tool : GLib.Object {  		// Button in four states 		if (selected && selected_button != null) {-			cr.set_source_surface ((!) selected_button, bgx, bgy);-			cr.paint ();+			border = "Tool Border 1";+			background = "Tool Background 1"; 		}  		if (selected && active && active_selected_button != null) {-			cr.set_source_surface ((!) active_selected_button, bgx, bgy);-			cr.paint ();+			border = "Tool Border 2";+			background = "Tool Background 2"; 		}  		if (!selected && deselected_button != null) {-			cr.set_source_surface ((!) deselected_button, bgx, bgy);-			cr.paint ();+			border = "Tool Border 3";+			background = "Tool Background 3"; 		}  		if (!selected && active && active_deselected_button != null) {-			cr.set_source_surface ((!) active_deselected_button, bgx, bgy);-			cr.paint ();+			border = "Tool Border 4";+			background = "Tool Background 4"; 		}++		Theme.color (cr, background);+		draw_rounded_rectangle (cr, bgx, bgy, 34 / scale, 28 / scale, 4 / scale);+		cr.fill (); 				+		cr.set_line_width (1 / scale);+		Theme.color (cr, border);+		draw_rounded_rectangle (cr, bgx, bgy, 34 / scale, 28 / scale, 4 / scale);+		cr.stroke ();+					 		if (icon != null) { 			ImageSurface i = (!) icon; 			

Contact

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