Clone in a terminal:
Commit 4327f43
Johan Mattsson - 2016-06-24T21:03:32+00:00
4327f43f965b4362596c4b3b93ca8206a752fd90johan.mattsson.m@gmail.com

Convert paths in background thread

Changed files (3)

Diff

diff --git a/libbirdfont/MoveTool.vala b/libbirdfont/MoveTool.valaindex 6d53feb..60d1f98 100644--- a/libbirdfont/MoveTool.vala+++ b/libbirdfont/MoveTool.vala@@ -499,7 +499,6 @@ public class MoveTool : Tool { 	}  	public void convert_svg_to_monochrome () {-		Font font = BirdFont.get_current_font (); 		ObjectGroup embedded_paths; 		Glyph glyph = MainWindow.get_current_glyph (); 		@@ -516,7 +515,6 @@ public class MoveTool : Tool { 	}  	public void convert_glyph_to_monochrome (Glyph glyph) {-		Font font = BirdFont.get_current_font (); 		ObjectGroup embedded_paths; 		 		embedded_paths = new ObjectGroup ();diff --git a/libbirdfont/OverviewTools.vala b/libbirdfont/OverviewTools.valaindex 8cbc939..7cc05fd 100644--- a/libbirdfont/OverviewTools.vala+++ b/libbirdfont/OverviewTools.vala@@ -305,55 +305,13 @@ public class OverviewTools : ToolCollection  { 		 		MainWindow.tabs.add_tab (new OtfFeatureTable (gc)); 	}-	-	public void process_transform (Transform transform) {-		OverView o;-		Glyph g;-		OverView.OverViewUndoItem ui;-		-		o = get_overview ();-		ui = new OverView.OverViewUndoItem ();-		-		Font f = BirdFont.get_current_font ();-		ui.alternate_sets = f.alternates.copy ();-		-		foreach (GlyphCollection gc in o.selected_items) {-			if (gc.length () > 0) {-				g = gc.get_current ();-				ui.glyphs.add (gc.copy_deep ());-				g.add_help_lines ();-				-				if (transform == Transform.SLANT) {-					if (skew.get_value () != 0) {-						DrawingTools.resize_tool.skew_glyph (g, -skew.get_value (), 0, false);-					}-				}-				-				if (transform == Transform.SIZE) {-					if (resize.get_value () != 100) {-						double scale = resize.get_value () / 100;-						DrawingTools.resize_tool.resize_glyph (g, scale, scale, false);-					}-				}-				-				if (transform == Transform.SVG_TO_TTF) {-					DrawingTools.move_tool.convert_glyph_to_monochrome (gc.get_current ());-				}-			}-		}-		-		foreach (OverViewItem item in o.visible_items) {-			item.clear_cache ();-			item.draw_glyph_from_font ();	-		}-		-		o.undo_items.add (ui);-		-		MainWindow.get_overview ().update_item_list ();-		GlyphCanvas.redraw ();++	public void process_transform (Transform transform) {	+		TransformTask task = new TransformTask (transform);+		MainWindow.run_blocking_task (task); 	} 	-	public OverView get_overview () {+	public static OverView get_overview () { 		FontDisplay fd = MainWindow.get_current_display (); 		 		if (fd is OverView || fd is GlyphSelection) {diff --git a/libbirdfont/TransformTask.vala b/libbirdfont/TransformTask.valanew file mode 100644index 0000000..6f99219--- /dev/null+++ b/libbirdfont/TransformTask.vala@@ -0,0 +1,73 @@+/*+	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.+*/++namespace BirdFont {++public class TransformTask : Task {+	static Transform transform;+	+	public TransformTask (Transform transform) {+		base (process_transform);+		TransformTask.transform = transform;+	}+	+	public static void process_transform () {+		OverView o;+		Glyph g;+		OverView.OverViewUndoItem ui;+		+		o = OverviewTools.get_overview ();+		ui = new OverView.OverViewUndoItem ();+		+		Font f = BirdFont.get_current_font ();+		ui.alternate_sets = f.alternates.copy ();+					+		foreach (GlyphCollection gc in o.selected_items) {+			if (gc.length () > 0) {+				g = gc.get_current ();+				ui.glyphs.add (gc.copy_deep ());+				g.add_help_lines ();+				+				if (transform == Transform.SLANT) {+					if (OverviewTools.skew.get_value () != 0) {+						DrawingTools.resize_tool.skew_glyph (g, -OverviewTools.skew.get_value (), 0, false);+					}+				}+				+				if (transform == Transform.SIZE) {+					if (OverviewTools.resize.get_value () != 100) {+						double scale = OverviewTools.resize.get_value () / 100;+						DrawingTools.resize_tool.resize_glyph (g, scale, scale, false);+					}+				}+				+				if (transform == Transform.SVG_TO_TTF) {+					DrawingTools.move_tool.convert_glyph_to_monochrome (gc.get_current ());+				}+			}+		}+		+		foreach (OverViewItem item in o.visible_items) {+			item.clear_cache ();+			item.draw_glyph_from_font ();	+		}+		+		o.undo_items.add (ui);+		+		MainWindow.get_overview ().update_item_list ();+		GlyphCanvas.redraw ();+	}+}++}	

Contact

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