Commit 16a7f71
Center at a point in glyph canvas
Changed files (3)
modifiedlibbirdfont/FontDisplay.valamodifiedlibbirdfont/Glyph.valamodifiedlibbirdfont/TabContent.vala
Diff
@@ -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 () { } @@ -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;+ } } }@@ -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;