Commit 48f8a76
Use fixed size glyphs in overview
Changed files (3)
modifiedlibbirdfont/Glyph.valamodifiedlibbirdfont/OverView.valamodifiedlibbirdfont/OverViewItem.vala
Diff
@@ -531,6 +531,8 @@ public class Glyph : FontDisplay { base_line.position_updated.connect ((pos) => { Font f = BirdFont.get_current_font (); f.base_line = pos;+ OverView o = MainWindow.get_overview ();+ o.reset_cache (); }); double bp = BirdFont.get_current_font ().bottom_position;@@ -141,6 +141,12 @@ public class OverView : FontDisplay { } } + public void reset_cache () {+ foreach (OverViewItem i in visible_items) {+ i.clear_cache ();+ }+ }+ public Glyph? get_selected_glyph () { if (selected_items.size == 0) { return null;@@ -641,9 +647,7 @@ public class OverView : FontDisplay { selected_index = selected_items.index_of ((!) glyphs); selected_item = (selected_index != -1); }- - item.adjust_scale ();- + selected_item |= (i == selected); item.selected = selected_item; @@ -118,8 +118,8 @@ public class OverViewItem : GLib.Object { w = width; h = height;- - scale_box = width / DEFAULT_WIDTH;++ scale_box = (height / DEFAULT_HEIGHT) * 0.75; s = Screen.create_background_surface ((int) width, (int) height - 20); c = new Context (s);@@ -131,15 +131,15 @@ public class OverViewItem : GLib.Object { glyph_height = y2 - y1; c.save ();- c.scale (glyph_scale * Screen.get_scale (), glyph_scale * Screen.get_scale ());+ c.scale (scale_box * Screen.get_scale (), scale_box * Screen.get_scale ()); g.add_help_lines (); - gx = ((w / glyph_scale) - glyph_width) / 2 - g.get_left_side_bearing ();- gy = (h / glyph_scale) - 25 / glyph_scale;- - c.translate (gx - Glyph.xc () - g.get_lsb (), g.get_baseline () + gy - Glyph.yc ());- + gx = ((w / scale_box) - glyph_width) / 2 - g.get_left_side_bearing ();+ gy = h / scale_box + g.get_baseline () - 20 / scale_box - 20;++ c.translate (gx - Glyph.xc () - g.get_lsb (), gy - Glyph.yc ());+ g.draw_paths (c, color); c.restore (); @@ -165,8 +165,6 @@ public class OverViewItem : GLib.Object { h = height; scale_box = width / DEFAULT_WIDTH;- adjust_scale ();- s = Screen.create_background_surface ((int) width, (int) height - 20); c = new Context (s); @@ -297,33 +295,6 @@ public class OverViewItem : GLib.Object { draw_menu (cr); } - public void adjust_scale () {- double x1, x2, y1, y2, glyph_width, glyph_height, scale, gx;- Glyph g;- Font font;- - if (glyphs != null) {- font = BirdFont.get_current_font ();- g = ((!) glyphs).get_current ();- g.boundaries (out x1, out y1, out x2, out y2);- - glyph_width = x2 - x1;- glyph_height = y2 - y1;-- if (glyph_scale == 1) {- // caption height is 20- glyph_scale = (height - 20) / (font.top_limit - font.bottom_limit); - }- - scale = glyph_scale; - gx = ((width / scale) - glyph_width) / 2;- - if (gx < 0) {- glyph_scale = 1 + 2 * gx / width;- }- }- }- private void draw_thumbnail (Context cr, double x, double y) { if (cache != null) { cr.save ();