Clone in a terminal:
Commit e5ce817
Johan Mattsson - 2014-11-06T16:48:27+00:00
e5ce8175bca29756ad42ced2626357d17110bf70johan.mattsson.m@gmail.com

Tools for the new overview tool box

Changed files (3)

Diff

diff --git a/libbirdfont/FontName.vala b/libbirdfont/FontName.valanew file mode 100644index 0000000..5b6cb8b--- /dev/null+++ b/libbirdfont/FontName.vala@@ -0,0 +1,44 @@+/*+    Copyright (C) 2014 Johan Mattsson++    This library is free software; you can redistribute it and/or modify +    it under the terms of the GNU Lesser General Public License as +    published by the Free Software Foundation; either version 3 of the +    License, or (at your option) any later version.++    This library is distributed in the hope that it will be useful, but +    WITHOUT ANY WARRANTY; without even the implied warranty of +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +    Lesser General Public License for more details.+*/++using Cairo;++namespace BirdFont {++public class FontName : Tool {++	public FontName (string? name = null, string tip = "", unichar key = '\0', uint modifier_flag = 0) {+		base (null , tip, key, modifier_flag);++		if (name != null) {+			base.name = (!) name;+		}+	}+	+	public override void draw (Context cr) {+		Text font_name;+		double text_height;+		+		cr.save ();+		// tab label+		font_name = new Text ();+		font_name.set_text (BirdFont.get_current_font ().get_full_name ());+		text_height = 12;+		cr.set_source_rgba (234 / 255.0, 77 / 255.0, 26 / 255.0, 1);+		font_name.draw (cr, x, y + 3, text_height);+		cr.restore ();+	}+}++}diff --git a/libbirdfont/OverviewTool.vala b/libbirdfont/OverviewTool.valanew file mode 100644index 0000000..bddff81--- /dev/null+++ b/libbirdfont/OverviewTool.vala@@ -0,0 +1,110 @@+/*+    Copyright (C) 2014 Johan Mattsson++    This library is free software; you can redistribute it and/or modify +    it under the terms of the GNU Lesser General Public License as +    published by the Free Software Foundation; either version 3 of the +    License, or (at your option) any later version.++    This library is distributed in the hope that it will be useful, but +    WITHOUT ANY WARRANTY; without even the implied warranty of +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +    Lesser General Public License for more details.+*/++using Cairo;++namespace BirdFont {++public class OverviewTool : Tool {++	private static ImageSurface? counter_background = null;+	public string label { get; set; }+	public string number { get; set; }+	public bool has_counter { get; set; }++	public OverviewTool (string label) {+		base ();++		this.label = label;+		this.number = "-";+		+		has_counter = true;+		counter_background = Icons.get_icon ("overview_counter.png");+		+		panel_press_action.connect ((selected, button, tx, ty) => {+		});++		panel_move_action.connect ((selected, button, tx, ty) => {+			return false;+		});++		panel_release_action.connect ((selected, button, tx, ty) => {+			set_selected (y <= ty <= y + h);+		});+	}+	+	public override void draw (Context cr) {+		Text font_name, glyph_count;+		double text_height;+		double scale, bgx, bgy;+		double center_x, center_y;+		+		// background+		if (is_selected ()) {+			cr.save ();+			cr.set_source_rgba (38 / 255.0, 39 / 255.0, 43 / 255.0, 1);+			cr.rectangle (0, y - 2, w, h + 7);+			cr.fill ();+			cr.restore ();		+		}+		+		// tab label+		cr.save ();+		font_name = new Text ();+		font_name.set_text (label);+		text_height = 10;++		if (is_selected ()) {+			cr.set_source_rgba (1, 1, 1, 1);+		} else {+			cr.set_source_rgba (101 / 255.0, 108 / 255.0, 116 / 255.0, 1);+		}+		+		font_name.draw (cr, x + 14, y + 4, text_height);+		cr.restore ();++		// glyph count+		if (has_counter && counter_background != null) {+			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 ();+			+			glyph_count = new Text ();+			glyph_count.set_text (@"$(this.number)");+			text_height = 6 / scale;+			+			center_x = bgx + ((!) counter_background).get_width () / 2.0  - glyph_count.get_extent (text_height) / 2.0;+			center_y = bgy + ((!) counter_background).get_height () / 2.0 - text_height / 2.0;+			+			if (is_selected ()) {+				cr.set_source_rgba (1, 1, 1, 1);+			} else {+				cr.set_source_rgba (51 / 255.0, 54 / 255.0, 59 / 255.0, 1);+			}+			+			glyph_count.draw (cr, center_x, center_y, text_height);+									+			cr.restore ();+		}+		+	}+}++}diff --git a/libbirdfont/Renderer/CarioDrawing.vala b/libbirdfont/Renderer/CarioDrawing.valanew file mode 100644index 0000000..0835d4d--- /dev/null+++ b/libbirdfont/Renderer/CarioDrawing.vala@@ -0,0 +1,34 @@+/*+    Copyright (C) 2014 Johan Mattsson++    This library is free software; you can redistribute it and/or modify +    it under the terms of the GNU Lesser General Public License as +    published by the Free Software Foundation; either version 3 of the +    License, or (at your option) any later version.++    This library is distributed in the hope that it will be useful, but +    WITHOUT ANY WARRANTY; without even the implied warranty of +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +    Lesser General Public License for more details.+*/++using Cairo;++namespace BirdFont {++public class CairoDrawing {+	+	public static Context? drawing_context;+	+	public static void new_path (double xa, double ya) {	+	}++	public static void curve_to (double xb, double yb, double xc, double yc, double xd, double yd) {+	}++	public static void close_path (double x, double y) {+	}++}++}

Contact

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