The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Cache path orientation icon

These changes was commited to the Birdfont repository Sun, 13 Dec 2015 17:40:41 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
author Johan Mattsson <johan.mattsson.m@gmail.com>
Sun, 13 Dec 2015 17:40:41 +0000 (18:40 +0100)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Sun, 13 Dec 2015 17:40:41 +0000 (18:40 +0100)
commit c5a0f468d3468202d879550ff3b065a1fc546623
tree 2cad0c437351f9167f88f260259f5dc4638243b9
parent c667aba38ac548c6e96f75f998bcc437c9e46f18
Cache path orientation icon

libbirdfont/Path.vala
--- a/libbirdfont/Path.vala +++ b/libbirdfont/Path.vala @@ -104,6 +104,8 @@ public Color? stroke_color = null; public Gradient? gradient = null; + + private static Text? arrow = null; public Path () { string width; @@ -318,9 +320,9 @@ public void draw_orientation_arrow (Context cr, double opacity) { EditPoint top = new EditPoint (); double max = Glyph.CANVAS_MIN; - Text arrow; double x, y, angle; - double size = 50 * Screen.get_scale (); + double size = 200 * Screen.get_scale (); + Text arrow_icon; foreach (EditPoint e in points) { if (e.y > max) { @@ -329,10 +331,15 @@ } } - arrow = new Text ("orientation_arrow", size); - arrow.load_font ("icons.bf"); + if (arrow == null) { + arrow_icon = new Text ("orientation_arrow", size); + arrow_icon.load_font ("icons.bf"); + arrow = arrow_icon; + } + + arrow_icon = (!) arrow; - Theme.text_color_opacity (arrow, "Highlighted 1", opacity); + Theme.text_color_opacity (arrow_icon, "Highlighted 1", opacity); angle = top.get_right_handle ().angle; x = Glyph.xc () + top.x + cos (angle + PI / 2) * 10 * Glyph.ivz (); @@ -342,11 +349,12 @@ cr.save (); cr.translate (x, y); double inverted_zoom = Glyph.ivz (); - cr.scale (inverted_zoom, inverted_zoom); cr.rotate (-angle); cr.translate (-x, -y); - arrow.draw_at_baseline (cr, x, y); + cr.scale (inverted_zoom, inverted_zoom); + + arrow_icon.draw_at_baseline (cr, x, y); cr.restore (); }