Commit 8ac186c
Insert specia characters in spacing classes
Changed files (4)
modifiedlibbirdfont/SpacingClass.valamodifiedlibbirdfont/SpacingClassTab.valaaddedlibbirdfont/SpacingClassTools.valamodifiedlibbirdfont/Toolbox.vala
Diff
@@ -41,6 +41,11 @@ public class SpacingClass : GLib.Object { update (next); } + public void update_class (string value, bool first) {+ update_first = first;+ update (value);+ }+ void update (string val) { listener = new TextListener (t_("Character"), val, t_("Set")); @@ -48,7 +53,7 @@ public class SpacingClass : GLib.Object { string v = text; if (v.has_prefix ("U+") || v.has_prefix ("u+")) {- v = (!) Font.to_unichar (val).to_string ();+ v = ((!) Font.to_unichar (val).to_string ()).dup (); } if (update_first) {@@ -20,8 +20,11 @@ public class SpacingClassTab : Table { public static int NEW_CLASS = -1; Gee.ArrayList<Row> rows = new Gee.ArrayList<Row> ();+ public static SpacingClass current_class;+ public static bool current_class_first_element; public SpacingClassTab () {+ current_class = new SpacingClass ("", ""); } public override Gee.ArrayList<Row> get_rows () {@@ -51,11 +54,13 @@ public class SpacingClassTab : Table { warning (@"Index: $(row.get_index ()) classes.size: $(spacing.classes.size)"); return; }- spacing.classes.get (row.get_index ()).set_first ();+ current_class = spacing.classes.get (row.get_index ());+ current_class.set_first (); font.touch (); } else if (column == 2) { return_if_fail (0 <= row.get_index () < spacing.classes.size);- spacing.classes.get (row.get_index ()).set_next ();+ current_class = spacing.classes.get (row.get_index ());+ current_class .set_next (); font.touch (); } }new file mode 100644@@ -0,0 +1,56 @@+/*+ Copyright (C) 2016 Johan Mattsson++ This library is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 3 of the + License, or (at your option) any later version.++ This library is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details.+*/++using Cairo;+using Math;++namespace BirdFont {++public class SpacingClassTools : ToolCollection {+ public static Gee.ArrayList<Expander> expanders;++ public SpacingClassTools () {+ Expander spacing_class_tools = new Expander ();+ Tool insert = new Tool ("insert_glyph_from_overview_in_spacing_class", t_("Insert glyph from overview"));+ + insert.set_icon ("insert_glyph_from_overview");+ + insert.select_action.connect ((self) => {+ GlyphSelection glyph_selection = new GlyphSelection ();+ + glyph_selection.selected_glyph.connect ((glyph_collection) => {+ SpacingClassTab.current_class.update_class (glyph_collection.get_name (),+ SpacingClassTab.current_class_first_element);+ MainWindow.get_tab_bar ().select_tab_name ("SpacingClasses");+ });+ + GlyphCanvas.set_display (glyph_selection);+ self.set_selected (false);+ });+ spacing_class_tools.add_tool (insert);+ }+ + public override Gee.ArrayList<Expander> get_expanders () {+ return expanders;+ }+ + public override Gee.ArrayList<string> get_displays () {+ Gee.ArrayList<string> d = new Gee.ArrayList<string> ();+ d.add ("SpacingClasses");+ return d;+ }+ +}++}@@ -27,6 +27,7 @@ public class Toolbox : GLib.Object { public static OverviewTools overview_tools; public static BackgroundTools background_tools; public static SpacingTools spacing_tools;+ public static SpacingClassTools spacing_class_tools; public static FileTools file_tools; public static ThemeTools theme_tools; @@ -64,6 +65,7 @@ public class Toolbox : GLib.Object { overview_tools = new OverviewTools (); background_tools = new BackgroundTools (); spacing_tools = new SpacingTools ();+ spacing_class_tools = new SpacingClassTools (); file_tools = new FileTools (); theme_tools = new ThemeTools (); @@ -74,6 +76,7 @@ public class Toolbox : GLib.Object { tool_sets.add (kerning_tools); tool_sets.add (preview_tools); tool_sets.add (overview_tools);+ tool_sets.add (spacing_class_tools); tool_sets.add (background_tools); // the menu has all the file_tools commands, it will not be added here tool_sets.add (hidden_tools); // tools without a button