The Birdfont Source Code


All Repositories / birdfont.git / commitdiff – RSS feed

Draw overview glyph count with cairo

These changes was commited to the Birdfont repository Mon, 16 Mar 2015 10:42:56 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
[Mon, 16 Mar 2015 10:42:56 +0000]

Updated Files

icons/no_icon.png
icons/overview_counter.png
icons/slow_test.png
icons/test_case.png
icons/version.png
libbirdfont/LabelTool.vala
diff --git icons/no_icon.png(deleted)
--- a/icons/no_icon.png +++ /dev/null @@ -1,6 +1,1 @@ - PNG -  - IHDR;֕JsBIT|d pHYs B(xtEXtSoftwarewww.inkscape.org<IDAT(ӱq0 ᏮxuҩAd7Z5G@ - >')Epǂ8!dz_;6\0L)X[ѵ xűq ,Z - O)"wZwmĘ"b45AqtEPm\}8@?YNgsN?-{cf - صNn1 R yc)}?[ Ghj]kIENDB` +
diff --git icons/overview_counter.png(deleted)
--- a/icons/overview_counter.png +++ /dev/null @@ -1,5 +1,1 @@ - PNG -  - IHDRN7|sBIT|d pHYs1616B tEXtSoftwarewww.inkscape.org<IDATx_h[emڴq֮(7(xc]x?n]1 ta!jg uVAFvQf dVaC7nm=?/ڔvme9͛$%*6^zxNE6+4͠@Ko~T5#g<o`RLq۳ؖkSؼhL|i9=W]ܞtfGlFEUNm4\n^Y3[fO1֚Td2Yx*@u)_~(4zê̓W@3'i-4aRode Kz:μ#"+N+>g1| T+aةH\ϑcˊ۽sKLbgr [3M?zG5ّ׸VHܻKɃpVjߗy:dYH[p",xc"E<Jww" t:~SKk6C;p#p}I#N5[BSA"G.x& ]1fw - 9ksYrYrYrYrYrYrYrYrYrYrYrYrY2(9m#r #?#z+hA+XFGͬw\q6&3r-D0y?\yBD> ?lP~9 ōy,"ёş\C3 (T~rf?2|eO~V~100XV ?WMtpȥ'j+R73):T:]xώZ5]~^ (K-UxXZuW - ՖD Fbhﴻkt#FB <qBy߰xL.jOH9_MV`mʐP*4WyET2_Q1OVY&_Wt\qcs.vP%IENDB` +
diff --git icons/slow_test.png(deleted)
--- a/icons/slow_test.png +++ /dev/null @@ -1,3 +1,1 @@ - PNG -  - IHDR,UգsBIT|d pHYs B(xtEXtSoftwarewww.inkscape.org<IDATeοpor7]beѕpA7t1ȢndfpIȄ.aw^\uzQV'BeԱjZ{q5xڨ櫣մZoS}fZWj:33!?[88%<Eǧ\y<v6^y;)b%6y,Npo>wc?_mIENDB` +
diff --git icons/test_case.png(deleted)
--- a/icons/test_case.png +++ /dev/null @@ -1,3 +1,1 @@ - PNG -  - IHDR!KsBIT|d pHYs B(xtEXtSoftwarewww.inkscape.org<IDAT}1Karj!#Z<.m:}pq+% FKSAӁ=gzxxW bxoxxcla8k̰='Qy^M֫n(2CvS}^s:pSVƤ5.tlY'~:Wb箅xyWx &*Ee:ùIENDB` +
diff --git icons/version.png(deleted)
--- a/icons/version.png +++ /dev/null @@ -1,3 +1,1 @@ - PNG -  - IHDR <$sBIT|d pHYs B(xtEXtSoftwarewww.inkscape.org<6IDAT bh,=-2쐨Oͦo|i`^oYs >IENDB` +
--- a/libbirdfont/LabelTool.vala +++ b/libbirdfont/LabelTool.vala @@ -18,12 +18,14 @@ 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 @@ 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 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 @@ 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);