Clone in a terminal:
Commit aac657f
Johan Mattsson - 2015-10-07T13:37:35+00:00
aac657fe3f55a2ce17ca9961346253ccd33d5a67johan.mattsson.m@gmail.com

Process stroke in background thread and bug fixes

Changed files (5)

Diff

diff --git a/libbirdfont/OverView.vala b/libbirdfont/OverView.valaindex 12ebb25..2f8cf96 100644--- a/libbirdfont/OverView.vala+++ b/libbirdfont/OverView.vala@@ -549,8 +549,8 @@ public class OverView : FontDisplay { 	 	public override void draw (WidgetAllocation allocation, Context cr) { 		-		if (this.allocation.width == allocation.width-			|| this.allocation.height == allocation.height+		if (this.allocation.width != allocation.width+			|| this.allocation.height != allocation.height 			|| this.allocation.width == 0) { 			this.allocation = allocation; 			update_item_list ();@@ -816,6 +816,8 @@ public class OverView : FontDisplay { 				return; 			 			case Key.UP:+				get_selected_item ().selected = false;+			 				key_up (); 				selected_item = get_selected_item (); 				@@ -828,6 +830,8 @@ public class OverView : FontDisplay { 				return; 				 			case Key.RIGHT:+				get_selected_item ().selected = false;+			 				key_right (); 				selected_item = get_selected_item (); 				@@ -840,6 +844,8 @@ public class OverView : FontDisplay { 				return; 				 			case Key.LEFT:+				get_selected_item ().selected = false;+				 				key_left (); 				selected_item = get_selected_item (); 				@@ -852,6 +858,8 @@ public class OverView : FontDisplay { 				return; 				 			case Key.DOWN:+				get_selected_item ().selected = false;+				 				key_down (); 				selected_item = get_selected_item (); 				@@ -864,6 +872,8 @@ public class OverView : FontDisplay { 				return; 				 			case Key.PG_UP:+				get_selected_item ().selected = false;+				 				for (int i = 0; i < rows; i++) { 					key_up (); 				}@@ -878,6 +888,8 @@ public class OverView : FontDisplay { 				return; 				 			case Key.PG_DOWN:+				get_selected_item ().selected = false;+				 				for (int i = 0; i < rows; i++) { 					key_down (); 				}diff --git a/libbirdfont/OverViewItem.vala b/libbirdfont/OverViewItem.valaindex bf7083b..6312d5a 100644--- a/libbirdfont/OverViewItem.vala+++ b/libbirdfont/OverViewItem.vala@@ -114,11 +114,16 @@ public class OverViewItem : GLib.Object { 			g = (!) glyphs; 			version_menu.set_position (x + width - 21, y + height - 18); 			a = version_menu.menu_item_action (px, py); // select one item on the menu+			 			if (a) { 				return s; 			} 			 			version_menu.menu_icon_action (px, py); // click in the open menu++			if (version_menu.menu_visible) {+				print("Menu is visible 222\n");+			} 		} 		 		info.set_position (x + width - 17, y + height - 22.5);@@ -158,6 +163,7 @@ public class OverViewItem : GLib.Object { 		 		draw_thumbnail (cr, glyphs, x, y + height); 	 		draw_caption (cr);+		draw_menu (cr); 	}  	public void adjust_scale () {@@ -273,7 +279,6 @@ public class OverViewItem : GLib.Object { 			label.draw_at_baseline (cr, x + 0.08 * width, y + height - 6); 		} 		-		draw_menu (cr); 		cr.restore (); 	} 	diff --git a/libbirdfont/Path.vala b/libbirdfont/Path.valaindex f861ef4..e1d9075 100644--- a/libbirdfont/Path.vala+++ b/libbirdfont/Path.vala@@ -53,8 +53,9 @@ public class Path : GLib.Object { 	/** Stroke width */ 	public double stroke = 0; 	public LineCap line_cap = LineCap.BUTT;-	PathList? full_stroke = null;+	public PathList? full_stroke = null; 	PathList? fast_stroke = null;+	StrokeTask? stroke_creator; 	 	/** Fill property for closed paths with stroke. */ 	public bool fill = false;@@ -2413,13 +2414,20 @@ public class Path : GLib.Object { 	} 	 	public void create_full_stroke () {-#if ANDROID == false-		if (stroke > 0) {-			full_stroke = StrokeTool.get_stroke (this, stroke);+		if (stroke <= 0) {+			return; 		}-#endif+		+		StrokeTask task = new StrokeTask (this);+		MainWindow.native_window.run_non_blocking_background_thread (task);+		+		if (stroke_creator != null) {+			((!) stroke_creator).cancel ();+		}+		+		stroke_creator = task; 	}-	+ 	public PathList get_stroke () { 		if (full_stroke == null) { 			full_stroke = StrokeTool.get_stroke (this, stroke);diff --git a/libbirdfont/Task.vala b/libbirdfont/Task.valaindex 3077edb..ce7088f 100644--- a/libbirdfont/Task.vala+++ b/libbirdfont/Task.vala@@ -19,11 +19,18 @@ public class Task : GLib.Object { 	public delegate void Runnable (); 	Runnable task; 	-	public Task (owned Runnable r) {-		task = (owned) r;+	public Task (owned Runnable? r) {+		if (r != null) {+			task = (!) ((owned) r);+		} 	} 	-	public void run () {+	public virtual void run () {+		if (task == null) {+			warning ("No task set.");+			return;+		}+		 		task (); 	} diff --git a/libbirdfont/VersionList.vala b/libbirdfont/VersionList.valaindex 4a47259..2d5c73d 100644--- a/libbirdfont/VersionList.vala+++ b/libbirdfont/VersionList.vala@@ -36,7 +36,7 @@ public class VersionList : GLib.Object { 	double width = 0; 	 	double menu_x = -1;	-	public bool menu_visible = false;+	public bool menu_visible { get; set; } 	Gee.ArrayList <MenuAction> actions = new Gee.ArrayList <MenuAction> (); 	const int item_height = 25; 	MenuDirection direction = MenuDirection.DROP_DOWN;@@ -47,6 +47,7 @@ public class VersionList : GLib.Object { 	public signal void add_glyph_item  (Glyph item);  	public VersionList (GlyphCollection gc) {+		menu_visible = false; 		MenuAction ma = add_item (t_("New version")); 		ma.has_delete_button = false; 		ma.action.connect ((self) => {@@ -432,8 +433,8 @@ public class VersionList : GLib.Object { 			} 		} 				-		if (x - width + 19 < 0) {-			menu_x = 30;+		if (x - width < 5) {+			menu_x = 5; 		} else { 			menu_x = x - width; 		}

Contact

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