The Birdfont Source Code


All Repositories / birdfont.git / blobdiff – RSS feed

Redraw moving canvas and keep OTF feature tab open

Changes made to libbirdfont/OtfFeatureTable.vala

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
--- libbirdfont/OtfFeatureTable.vala +++ libbirdfont/OtfFeatureTable.vala @@ -26,7 +26,7 @@ static const int REPLACEMENT_GLYPH = 3; static const int ALTERNATE_ENTRY = 4; - GlyphCollection glyph_collection; + GlyphCollection? glyph_collection = null; GlyphCollection? replacement_glyph = null; string alternate_name = ""; TextListener listener; @@ -34,7 +34,7 @@ Gee.ArrayList<AlternateItem> undo_items; // FIXME: implement redo - public OtfFeatureTable (GlyphCollection gc) { + public OtfFeatureTable (GlyphCollection? gc) { glyph_collection = gc; undo_items = new Gee.ArrayList<AlternateItem> (); } @@ -102,7 +102,15 @@ row = new Row.headline (t_("Glyph Substitutions")); rows.add (row); - row = new Row.columns_1 (t_("Glyph") + ": " + glyph_collection.get_name (), SOURCE_GLYPH, false); + string glyph = ""; + + if (glyph_collection == null) { + glyph = t_("New glyph"); + } else { + glyph = ((!) glyph_collection).get_name (); + } + + row = new Row.columns_1 (t_("Glyph") + ": " + glyph, SOURCE_GLYPH, false); rows.add (row); string replacement = t_("New glyph"); @@ -176,7 +184,14 @@ } public void add_new_alternate (string tag) { - GlyphCollection gc = glyph_collection; + GlyphCollection gc; + + if (glyph_collection == null) { + MainWindow.show_message (t_("Select a glyph to create an alternate for.")); + return; + } + + gc = (!) glyph_collection; listener = new TextListener (t_("Glyph name"), "", t_("Add")); @@ -190,19 +205,15 @@ OverView overview = MainWindow.get_overview (); font = BirdFont.get_current_font (); - - if (alternate_name == "" || gc.is_unassigned ()) { - MainWindow.tabs.close_display (this); - return; - } - + if (font.glyph_name.has_key (alternate_name)) { MainWindow.show_message (t_("All glyphs must have unique names.")); } else { alt = new GlyphCollection.with_glyph ('\0', alternate_name); alt.set_unassigned (true); font.add_new_alternate (gc, alt, tag); - MainWindow.tabs.close_display (this); + update_rows (); + GlyphCanvas.redraw (); MainWindow.get_overview ().update_item_list (); overview.open_glyph_signal (alt); } @@ -212,7 +223,8 @@ GlyphCollection replacement = (!) replacement_glyph; Font f = BirdFont.get_current_font (); f.add_alternate (gc.get_name (), replacement.get_name (), tag); - MainWindow.tabs.close_display (this); + update_rows (); + GlyphCanvas.redraw (); } else { TabContent.show_text_input (listener); }