The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Redraw moving canvas and keep OTF feature tab open

These changes was commited to the Birdfont repository Sun, 12 Jun 2016 20:30:27 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
author Johan Mattsson <johan.mattsson.m@gmail.com>
Sun, 12 Jun 2016 20:30:27 +0000 (22:30 +0200)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Sun, 12 Jun 2016 20:30:27 +0000 (22:30 +0200)
commit 36e61894b6b261ccd1a39c6df80fa6b6e46d3934
tree 71808bc3e3aa3cc3c187d55b81a0be8754beeec6
parent c091a5d2951e910e920c15a06fd227ff35d0e92f
Redraw moving canvas and keep OTF feature tab open

libbirdfont/Glyph.vala
libbirdfont/OtfFeatureTable.vala
libbirdfont/OverviewTools.vala
--- a/libbirdfont/Glyph.vala +++ b/libbirdfont/Glyph.vala @@ -1874,7 +1874,7 @@ private void move_view_offset (double x, double y) { view_offset_x = move_offset_x + (pointer_begin_x - x) * (1/view_zoom); view_offset_y = move_offset_y + (pointer_begin_y - y) * (1/view_zoom); - redraw_area (0, 0, allocation.width, allocation.height); + GlyphCanvas.redraw (); } public void store_undo_state (bool clear_redo = false) {
--- a/libbirdfont/OtfFeatureTable.vala +++ b/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); }
--- a/libbirdfont/OverviewTools.vala +++ b/libbirdfont/OverviewTools.vala @@ -279,15 +279,16 @@ public void add_new_alternate (Tool tool) { OverView o = MainWindow.get_overview (); OverViewItem oi = o.selected_item; - GlyphCollection gc; + GlyphCollection? gc; tool.set_selected (false); - if (oi.glyphs == null || ((!) oi.glyphs).is_unassigned ()) { - return; + gc = (!) oi.glyphs; + + if (oi.glyphs != null && ((!) oi.glyphs).is_unassigned ()) { + gc = null; } - gc = (!) oi.glyphs; MainWindow.tabs.add_tab (new OtfFeatureTable (gc)); }