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
Circle boundaries heads/master
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 private static Text? info_icon = null; 25 Text icon; 26 double x = 0; 27 double y = 0; 28 bool ligature = false; 29 string name = ""; 30 31 public CharacterInfo (unichar c, GlyphCollection? gc) { 32 unicode = c; 33 34 if (info_icon == null) { 35 info_icon= new Text ("info_icon", 22); 36 ((!) info_icon).load_font ("icons.bf"); 37 } 38 39 icon = (!) info_icon; 40 41 if (gc != null) { 42 ligature = ((!) gc).is_unassigned (); 43 name = ((!) gc).get_name (); 44 } 45 } 46 47 public string get_name () { 48 return name; 49 } 50 51 public bool is_ligature () { 52 return ligature; 53 } 54 55 public string get_entry () { 56 return CharDatabase.get_unicode_database_entry (unicode); 57 } 58 59 public void set_position (double x, double y) { 60 this.x = x; 61 this.y = y; 62 } 63 64 public bool is_over_icon (double px, double py) { 65 return (x <= px <= x + 12) && (y <= py <= y + 24); 66 } 67 68 public void draw_icon (Context cr, bool selected, double px, double py) { 69 if (selected) { 70 Theme.text_color (icon, "Overview Selected Foreground"); 71 } else { 72 Theme.text_color (icon, "Overview Foreground"); 73 } 74 75 icon.draw_at_top (cr, px, py); 76 } 77 } 78 79 } 80