Clone in a terminal:
Commit 16a7f71
Johan Mattsson - 2014-07-13T13:13:39+00:00
16a7f710f8951bd8fc464290791029666b85798fjohan.mattsson.m@gmail.com

Center at a point in glyph canvas

Changed files (3)

Diff

diff --git a/libbirdfont/FontDisplay.vala b/libbirdfont/FontDisplay.valaindex 3ab08e3..77b036e 100644--- a/libbirdfont/FontDisplay.vala+++ b/libbirdfont/FontDisplay.vala@@ -77,6 +77,9 @@ public abstract class FontDisplay : GLib.Object { 	public virtual void zoom_min () { 	} 	+	public virtual void center_at (double x, double y) {+	}+	 	public virtual void reset_zoom () { 	} 	diff --git a/libbirdfont/Glyph.vala b/libbirdfont/Glyph.valaindex a52b2ea..0463ea2 100644--- a/libbirdfont/Glyph.vala+++ b/libbirdfont/Glyph.vala@@ -1865,6 +1865,20 @@ public class Glyph : FontDisplay { 	public string get_hex () { 		return Font.to_hex_code (unichar_code); 	}+	+	public override void center_at (double x, double y) {+		double px, py;+		double cx, cy;+		+		px = Glyph.path_coordinate_x (x);+		py = Glyph.path_coordinate_y (y);+		+		cx = Glyph.path_coordinate_x (allocation.width / 2.0);+		cy = Glyph.path_coordinate_y (allocation.height / 2.0);		+		+		view_offset_x += px - cx;+		view_offset_y += py - cy;+	} }  }diff --git a/libbirdfont/TabContent.vala b/libbirdfont/TabContent.valaindex 381a1fe..cc20ba8 100644--- a/libbirdfont/TabContent.vala+++ b/libbirdfont/TabContent.vala@@ -34,6 +34,14 @@ public class TabContent : GLib.Object { 		GlyphCanvas.current_display.zoom_out (); 	} 	+	public static void center_at (double x, double y) {+		if (MenuTab.suppress_event) {+			return;+		}+		+		GlyphCanvas.current_display.center_at (x, y);+	}+	 	public static bool has_scrollbar () { 		if (MenuTab.suppress_event) { 			return false;

Contact

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