Commit c71d2bd
Draw overview glyph count with cairo
Changed files (6)
deletedicons/no_icon.pngdeletedicons/overview_counter.pngdeletedicons/slow_test.pngdeletedicons/test_case.pngdeletedicons/version.pngmodifiedlibbirdfont/LabelTool.vala
Diff
deleted file mode 100644Binary files a/icons/no_icon.png and /dev/null differdeleted file mode 100644Binary files a/icons/overview_counter.png and /dev/null differdeleted file mode 100644Binary files a/icons/slow_test.png and /dev/null differdeleted file mode 100644Binary files a/icons/test_case.png and /dev/null differdeleted file mode 100644Binary files a/icons/version.png and /dev/null differ@@ -18,13 +18,15 @@ namespace BirdFont { public class LabelTool : Tool { - private static ImageSurface? counter_background = null; public string label { get; set; } public string number { get; set; } public bool has_counter { get; set; } public bool has_delete_button { get; set; } public signal void delete_action (LabelTool self); + double counter_box_width = 22;+ double counter_box_height = 11;+ public LabelTool (string label) { base (); @@ -33,8 +35,7 @@ public class LabelTool : Tool { has_delete_button = false; has_counter = false;- counter_background = Icons.get_icon ("overview_counter.png");- + panel_press_action.connect ((selected, button, tx, ty) => { if (has_delete_button && y <= ty <= y + h && tx >= w - 30) { delete_action (this);@@ -49,7 +50,7 @@ public class LabelTool : Tool { public override void draw (Context cr) { Text label_text, glyph_count; double text_height;- double scale, bgx, bgy;+ double bgx, bgy; double center_x, center_y; // background@@ -78,39 +79,33 @@ public class LabelTool : Tool { cr.restore (); // glyph count- if (has_counter && counter_background != null) {+ if (has_counter) { 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 ();+ bgx = Toolbox.allocation_width - counter_box_width - 15;+ bgy = y + 2;++ Theme.color (cr, "Background 3");+ draw_rounded_rectangle (cr, bgx, bgy, counter_box_width, counter_box_height, 3);+ cr.fill ();+ cr.restore (); glyph_count = new Text (); glyph_count.set_text (@"$(this.number)");- text_height = 12 / scale;+ text_height = 13; glyph_count.set_font_size (text_height);- center_x = bgx + ((!) counter_background).get_width () / 2.0 - glyph_count.get_extent () / 2.0;- center_y = bgy + ((!) counter_background).get_height () / 2.0 + 4 / scale;- - if (is_selected ()) {- Theme.text_color (glyph_count, "Background 1");- } else {- Theme.text_color (glyph_count, "Background 4");- }- + center_x = bgx + (counter_box_width / 2.0 - glyph_count.get_extent () / 2.0);+ center_y = bgy + (counter_box_height / 2.0 + 5);++ Theme.text_color (glyph_count, "Foreground Inverted");+ glyph_count.set_font_size (text_height); glyph_count.draw_at_baseline (cr, center_x, center_y);- - cr.restore (); } if (has_delete_button) { cr.save ();+ Theme.color (cr, "Foreground Inverted"); cr.set_line_width (1); cr.move_to (w - 20, y + h / 2 - 2.5 + 2); cr.line_to (w - 25, y + h / 2 + 2.5 + 2);