The Birdfont Source Code


All Repositories / birdfont.git / blob – RSS feed

DescriptionDisplay.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/DescriptionDisplay.vala.
Ignore case in key bindings
1 /* 2 Copyright (C) 2014 2015 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 using Math; 17 18 namespace BirdFont { 19 20 public class DescriptionDisplay : TableLayout { 21 TextArea postscript_name; 22 TextArea name; 23 TextArea style; 24 CheckBox bold; 25 CheckBox italic; 26 TextArea weight; 27 TextArea full_name; 28 TextArea unique_id; 29 TextArea version; 30 TextArea description; 31 TextArea copyright; 32 33 private static bool disable_copyright = false; 34 35 public DescriptionDisplay () { 36 double margin = 12 * MainWindow.units; 37 double label_size = 20 * MainWindow.units; 38 double label_margin = 4 * MainWindow.units; 39 Headline headline; 40 Font font = BirdFont.get_current_font (); 41 42 postscript_name = new LineTextArea (label_size); 43 name = new LineTextArea (label_size); 44 style = new LineTextArea (label_size); 45 weight = new LineTextArea (label_size); 46 full_name = new LineTextArea (label_size); 47 unique_id = new LineTextArea (label_size); 48 version = new LineTextArea (label_size); 49 description = new TextArea (label_size); 50 copyright = new TextArea (label_size); 51 52 headline = new Headline (t_("Name and Description")); 53 headline.margin_bottom = 20 * MainWindow.units; 54 widgets.add (headline); 55 56 widgets.add (new Text (t_("PostScript Name"), label_size, label_margin)); 57 postscript_name.margin_bottom = margin; 58 postscript_name.set_text (font.postscript_name); 59 postscript_name.text_changed.connect ((t) => { 60 font.postscript_name = t; 61 font.touch (); 62 }); 63 widgets.add (postscript_name); 64 focus_ring.add (postscript_name); 65 66 widgets.add (new Text (t_("Name"), label_size, label_margin)); 67 name.margin_bottom = margin; 68 name.set_text (font.name); 69 name.text_changed.connect ((t) => { 70 font.name = t; 71 font.touch (); 72 }); 73 widgets.add (name); 74 focus_ring.add (name); 75 76 widgets.add (new Text (t_("Style"), label_size, label_margin)); 77 style.margin_bottom = 1.5 * margin; 78 style.set_text (font.subfamily); 79 style.text_changed.connect ((t) => { 80 font.subfamily = t; 81 font.touch (); 82 }); 83 widgets.add (style); 84 focus_ring.add (style); 85 86 bold = new CheckBox (t_("Bold"), label_size); 87 bold.updated.connect ((c) => { 88 font.bold = c; 89 font.touch (); 90 }); 91 bold.checked = font.bold; 92 widgets.add (bold); 93 focus_ring.add (bold); 94 95 italic = new CheckBox (t_("Italic"), label_size); 96 italic.updated.connect ((c) => { 97 font.italic = c; 98 font.touch (); 99 }); 100 italic.checked = font.italic; 101 italic.margin_bottom = margin; 102 widgets.add (italic); 103 focus_ring.add (italic); 104 105 widgets.add (new Text (t_("Weight"), label_size, label_margin)); 106 weight.margin_bottom = margin; 107 weight.set_text (font.get_weight ()); 108 weight.text_changed.connect ((t) => { 109 font.set_weight (t); 110 font.touch (); 111 }); 112 widgets.add (weight); 113 focus_ring.add (weight); 114 115 widgets.add (new Text (t_("Full Name (Name and Style)"), label_size, label_margin)); 116 full_name.margin_bottom = margin; 117 full_name.set_text (font.full_name); 118 full_name.text_changed.connect ((t) => { 119 font.full_name = t; 120 font.touch (); 121 }); 122 widgets.add (full_name); 123 focus_ring.add (full_name); 124 125 widgets.add (new Text (t_("Unique Identifier"), label_size, label_margin)); 126 unique_id.margin_bottom = margin; 127 unique_id.set_text (font.unique_identifier); 128 unique_id.text_changed.connect ((t) => { 129 font.unique_identifier = t; 130 font.touch (); 131 }); 132 widgets.add (unique_id); 133 focus_ring.add (unique_id); 134 135 widgets.add (new Text (t_("Version"), label_size, label_margin)); 136 version.margin_bottom = margin; 137 version.set_text (font.version); 138 version.text_changed.connect ((t) => { 139 font.version = t; 140 font.touch (); 141 }); 142 widgets.add (version); 143 focus_ring.add (version); 144 145 widgets.add (new Text (t_("Description"), label_size, label_margin)); 146 description.margin_bottom = margin; 147 description.set_text (font.description); 148 description.scroll.connect (scroll_event); 149 description.text_changed.connect ((t) => { 150 font.description = t; 151 font.touch (); 152 }); 153 widgets.add (description); 154 focus_ring.add (description); 155 156 widgets.add (new Text (t_("Copyright"), label_size, label_margin)); 157 copyright.margin_bottom = margin; 158 copyright.set_text (font.copyright); 159 copyright.scroll.connect (scroll_event); 160 copyright.text_changed.connect ((t) => { 161 font.copyright = t; 162 font.touch (); 163 }); 164 copyright.set_editable (!disable_copyright); 165 widgets.add (copyright); 166 focus_ring.add (copyright); 167 168 set_focus (postscript_name); 169 170 foreach (Widget w in widgets) { 171 if (w is Text) { 172 Theme.text_color ((Text) w, "Text Foreground"); 173 } 174 } 175 } 176 177 public static void set_copyright_editable (bool t) { 178 disable_copyright = !t; 179 } 180 181 public override string get_label () { 182 return t_("Name and Description"); 183 } 184 185 public override string get_name () { 186 return "Description"; 187 } 188 189 public override void selected_canvas () { 190 copyright.set_editable (!disable_copyright); 191 base.selected_canvas (); 192 } 193 } 194 195 } 196