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
Circle boundaries heads/master
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 TextArea license; 33 LineTextArea license_url; 34 TextArea trademark; 35 LineTextArea manufacturer; 36 LineTextArea designer; 37 LineTextArea vendor_url; 38 LineTextArea designer_url; 39 40 private static bool disable_copyright = false; 41 42 public DescriptionDisplay () { 43 double margin = 12 * MainWindow.units; 44 double label_size = 20 * MainWindow.units; 45 double label_margin = 4 * MainWindow.units; 46 Headline headline; 47 Font font = BirdFont.get_current_font (); 48 49 postscript_name = new LineTextArea (label_size); 50 name = new LineTextArea (label_size); 51 style = new LineTextArea (label_size); 52 weight = new LineTextArea (label_size); 53 full_name = new LineTextArea (label_size); 54 unique_id = new LineTextArea (label_size); 55 version = new LineTextArea (label_size); 56 description = new TextArea (label_size); 57 copyright = new TextArea (label_size); 58 license = new TextArea (label_size); 59 license_url = new LineTextArea (label_size); 60 trademark = new TextArea (label_size); 61 manufacturer = new LineTextArea (label_size); 62 designer = new LineTextArea (label_size); 63 vendor_url = new LineTextArea (label_size); 64 designer_url = new LineTextArea (label_size); 65 66 headline = new Headline (t_("Name and Description")); 67 headline.margin_bottom = 20 * MainWindow.units; 68 widgets.add (headline); 69 70 widgets.add (new Text (t_("PostScript Name"), label_size, label_margin)); 71 postscript_name.margin_bottom = margin; 72 postscript_name.set_text (font.postscript_name); 73 postscript_name.text_changed.connect ((t) => { 74 font.postscript_name = t; 75 font.touch (); 76 }); 77 widgets.add (postscript_name); 78 focus_ring.add (postscript_name); 79 80 widgets.add (new Text (t_("Name"), label_size, label_margin)); 81 name.margin_bottom = margin; 82 name.set_text (font.name); 83 name.text_changed.connect ((t) => { 84 font.name = t; 85 font.touch (); 86 }); 87 widgets.add (name); 88 focus_ring.add (name); 89 90 widgets.add (new Text (t_("Style"), label_size, label_margin)); 91 style.margin_bottom = 1.5 * margin; 92 style.set_text (font.subfamily); 93 style.text_changed.connect ((t) => { 94 font.subfamily = t; 95 font.touch (); 96 }); 97 widgets.add (style); 98 focus_ring.add (style); 99 100 bold = new CheckBox (t_("Bold"), label_size); 101 bold.updated.connect ((c) => { 102 font.bold = c; 103 font.touch (); 104 }); 105 bold.checked = font.bold; 106 widgets.add (bold); 107 focus_ring.add (bold); 108 109 italic = new CheckBox (t_("Italic"), label_size); 110 italic.updated.connect ((c) => { 111 font.italic = c; 112 font.touch (); 113 }); 114 italic.checked = font.italic; 115 italic.margin_bottom = margin; 116 widgets.add (italic); 117 focus_ring.add (italic); 118 119 widgets.add (new Text (t_("Weight"), label_size, label_margin)); 120 weight.margin_bottom = margin; 121 weight.set_text (font.get_weight ()); 122 weight.text_changed.connect ((t) => { 123 font.set_weight (t); 124 font.touch (); 125 }); 126 widgets.add (weight); 127 focus_ring.add (weight); 128 129 widgets.add (new Text (t_("Full Name (Name and Style)"), label_size, label_margin)); 130 full_name.margin_bottom = margin; 131 full_name.set_text (font.full_name); 132 full_name.text_changed.connect ((t) => { 133 font.full_name = t; 134 font.touch (); 135 MainWindow.get_toolbox ().update_all_expanders (); 136 }); 137 widgets.add (full_name); 138 focus_ring.add (full_name); 139 140 widgets.add (new Text (t_("Unique Identifier"), label_size, label_margin)); 141 unique_id.margin_bottom = margin; 142 unique_id.set_text (font.unique_identifier); 143 unique_id.text_changed.connect ((t) => { 144 font.unique_identifier = t; 145 font.touch (); 146 }); 147 widgets.add (unique_id); 148 focus_ring.add (unique_id); 149 150 widgets.add (new Text (t_("Version"), label_size, label_margin)); 151 version.margin_bottom = margin; 152 version.set_text (font.version); 153 version.text_changed.connect ((t) => { 154 font.version = t; 155 font.touch (); 156 }); 157 widgets.add (version); 158 focus_ring.add (version); 159 160 widgets.add (new Text (t_("Description"), label_size, label_margin)); 161 description.margin_bottom = margin; 162 description.set_text (font.description); 163 description.scroll.connect (scroll_event); 164 description.text_changed.connect ((t) => { 165 font.description = t; 166 font.touch (); 167 }); 168 widgets.add (description); 169 focus_ring.add (description); 170 171 widgets.add (new Text (t_("Copyright"), label_size, label_margin)); 172 copyright.margin_bottom = margin; 173 copyright.set_text (font.copyright); 174 copyright.scroll.connect (scroll_event); 175 copyright.text_changed.connect ((t) => { 176 font.copyright = t; 177 font.touch (); 178 }); 179 copyright.set_editable (!disable_copyright); 180 widgets.add (copyright); 181 focus_ring.add (copyright); 182 183 widgets.add (new Text (t_("License"), label_size, label_margin)); 184 license.margin_bottom = margin; 185 license.set_text (font.license); 186 license.scroll.connect (scroll_event); 187 license.text_changed.connect ((t) => { 188 font.license = t; 189 font.touch (); 190 }); 191 license.set_editable (!disable_copyright); 192 widgets.add (license); 193 focus_ring.add (license); 194 195 widgets.add (new Text (t_("License URL"), label_size, label_margin)); 196 license_url.margin_bottom = margin; 197 license_url.set_text (font.license_url); 198 license_url.scroll.connect (scroll_event); 199 license_url.text_changed.connect ((t) => { 200 font.license_url = t; 201 font.touch (); 202 }); 203 license_url.set_editable (!disable_copyright); 204 widgets.add (license_url); 205 focus_ring.add (license_url); 206 207 widgets.add (new Text (t_("Trademark"), label_size, label_margin)); 208 trademark.margin_bottom = margin; 209 trademark.set_text (font.trademark); 210 trademark.scroll.connect (scroll_event); 211 trademark.text_changed.connect ((t) => { 212 font.trademark = t; 213 font.touch (); 214 }); 215 trademark.set_editable (!disable_copyright); 216 widgets.add (trademark); 217 focus_ring.add (trademark); 218 219 widgets.add (new Text (t_("Manufacturer"), label_size, label_margin)); 220 manufacturer.margin_bottom = margin; 221 manufacturer.set_text (font.manufacturer); 222 manufacturer.scroll.connect (scroll_event); 223 manufacturer.text_changed.connect ((t) => { 224 font.manufacturer = t; 225 font.touch (); 226 }); 227 widgets.add (manufacturer); 228 focus_ring.add (manufacturer); 229 230 widgets.add (new Text (t_("Designer"), label_size, label_margin)); 231 designer.margin_bottom = margin; 232 designer.set_text (font.designer); 233 designer.scroll.connect (scroll_event); 234 designer.text_changed.connect ((t) => { 235 font.designer = t; 236 font.touch (); 237 }); 238 widgets.add (designer); 239 focus_ring.add (designer); 240 241 widgets.add (new Text (t_("Vendor URL"), label_size, label_margin)); 242 vendor_url.margin_bottom = margin; 243 vendor_url.set_text (font.vendor_url); 244 vendor_url.scroll.connect (scroll_event); 245 vendor_url.text_changed.connect ((t) => { 246 font.vendor_url = t; 247 font.touch (); 248 }); 249 widgets.add (vendor_url); 250 focus_ring.add (vendor_url); 251 252 widgets.add (new Text (t_("Designer URL"), label_size, label_margin)); 253 designer_url.margin_bottom = margin; 254 designer_url.set_text (font.designer_url); 255 designer_url.scroll.connect (scroll_event); 256 designer_url.text_changed.connect ((t) => { 257 font.designer_url = t; 258 font.touch (); 259 }); 260 widgets.add (designer_url); 261 focus_ring.add (designer_url); 262 263 set_focus (postscript_name); 264 265 foreach (Widget w in widgets) { 266 if (w is Text) { 267 Theme.text_color ((Text) w, "Text Foreground"); 268 } 269 } 270 } 271 272 public static void set_copyright_editable (bool t) { 273 disable_copyright = !t; 274 } 275 276 public override string get_label () { 277 return t_("Name and Description"); 278 } 279 280 public override string get_name () { 281 return "Description"; 282 } 283 284 public override void selected_canvas () { 285 copyright.set_editable (!disable_copyright); 286 base.selected_canvas (); 287 } 288 } 289 290 } 291