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.
Merge branch '2.10'
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 icon.use_cache (true); 40 } 41 } 42 43 public string get_name () { 44 return name; 45 } 46 47 public bool is_ligature () { 48 return ligature; 49 } 50 51 public string get_entry () { 52 return CharDatabase.get_unicode_database_entry (unicode); 53 } 54 55 public void set_position (double x, double y) { 56 this.x = x; 57 this.y = y; 58 } 59 60 public bool is_over_icon (double px, double py) { 61 return (x <= px <= x + 12) && (y <= py <= y + 24); 62 } 63 64 public void draw_icon (Context cr, bool selected, double px, double py) { 65 if (selected) { 66 Theme.text_color (icon, "Overview Selected Foreground"); 67 } else { 68 Theme.text_color (icon, "Overview Foreground"); 69 } 70 71 icon.draw_at_top (cr, px, py); 72 } 73 } 74 75 } 76