The Birdfont Source Code


All Repositories / birdfont.git / blob – RSS feed

CharacterInfo.vala in libbirdfont

This file is a part of the Birdfont project.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git

Revisions

View the latest version of libbirdfont/CharacterInfo.vala.
Faster text and icon rendering
1 /* 2 Copyright (C) 2013 Johan Mattsson 3 4 This library is free software; you can redistribute it and/or modify 5 it under the terms of the GNU Lesser General Public License as 6 published by the Free Software Foundation; either version 3 of the 7 License, or (at your option) any later version. 8 9 This library is distributed in the hope that it will be useful, but 10 WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Lesser General Public License for more details. 13 */ 14 15 using Cairo; 16 17 namespace BirdFont { 18 19 /** Display functions for a unicode character database entry. */ 20 public class CharacterInfo : GLib.Object { 21 22 public unichar unicode; 23 24 Text icon; 25 double x = 0; 26 double y = 0; 27 bool ligature = false; 28 string name = ""; 29 30 public CharacterInfo (unichar c, GlyphCollection? gc) { 31 unicode = c; 32 icon = new Text ("info_icon", 22); 33 icon.load_font ("icons.bf"); 34 35 if (gc != null) { 36 ligature = ((!) gc).is_unassigned (); 37 name = ((!) gc).get_name (); 38 icon.load_font ("icons.bf"); 39 } 40 } 41 42 public string get_name () { 43 return name; 44 } 45 46 public bool is_ligature () { 47 return ligature; 48 } 49 50 public string get_entry () { 51 return CharDatabase.get_unicode_database_entry (unicode); 52 } 53 54 public void set_position (double x, double y) { 55 this.x = x; 56 this.y = y; 57 } 58 59 public bool is_over_icon (double px, double py) { 60 return (x <= px <= x + 12) && (y <= py <= y + 24); 61 } 62 63 public void draw_icon (Context cr, bool selected, double px, double py) { 64 if (selected) { 65 Theme.text_color (icon, "Overview Selected Foreground"); 66 } else { 67 Theme.text_color (icon, "Overview Foreground"); 68 } 69 70 icon.draw_at_top (cr, px, py); 71 } 72 } 73 74 } 75