Clone in a terminal:
Commit 36e6189
Johan Mattsson - 2016-06-12T20:30:27+00:00
36e61894b6b261ccd1a39c6df80fa6b6e46d3934johan.mattsson.m@gmail.com

Redraw moving canvas and keep OTF feature tab open

Changed files (3)

Diff

diff --git a/libbirdfont/Glyph.vala b/libbirdfont/Glyph.valaindex ec079df..5711f91 100644--- a/libbirdfont/Glyph.vala+++ b/libbirdfont/Glyph.vala@@ -1874,7 +1874,7 @@ public class Glyph : FontDisplay { 	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) {diff --git a/libbirdfont/OtfFeatureTable.vala b/libbirdfont/OtfFeatureTable.valaindex 89dc8d9..f4bdc4a 100644--- a/libbirdfont/OtfFeatureTable.vala+++ b/libbirdfont/OtfFeatureTable.vala@@ -26,7 +26,7 @@ public class OtfFeatureTable : Table { 	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 @@ public class OtfFeatureTable : Table { 	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 @@ public class OtfFeatureTable : Table { 		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 class OtfFeatureTable : Table { 	}	  	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 @@ public class OtfFeatureTable : Table { 			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 @@ public class OtfFeatureTable : Table { 			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); 		}		diff --git a/libbirdfont/OverviewTools.vala b/libbirdfont/OverviewTools.valaindex d9f2713..524ef10 100644--- a/libbirdfont/OverviewTools.vala+++ b/libbirdfont/OverviewTools.vala@@ -279,15 +279,16 @@ public class OverviewTools : ToolCollection  { 	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)); 	} 	

Contact

Email: johan.mattsson.m@gmail.com
Mastodon: typo.social/@birdfont
GitHub: johanmattssonm
LinkedIn: johan-mattsson-2ab324112