Clone in a terminal:
Commit af9c2a4
Johan Mattsson - 2015-10-07T15:39:46+00:00
af9c2a48351c025e6e7d1d07214bcdf096b0dbe8johan.mattsson.m@gmail.com

Create strokes in background threads

Changed files (1)

Diff

diff --git a/libbirdfont/StrokeTask.vala b/libbirdfont/StrokeTask.valanew file mode 100644index 0000000..1bda518--- /dev/null+++ b/libbirdfont/StrokeTask.vala@@ -0,0 +1,57 @@+/*+    Copyright (C) 2015 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 {+	+class StrokeTask : Task {+	bool cancelled = false;+	Path original; // path in gui thread+	Path background_path; // path in background thread+	+	public StrokeTask (Path path) {+		base (null);+		original = path;+		background_path = path.copy ();+	}+	+	public void cancel () {+		lock (cancelled) {	+			cancelled = true;+		}+	}+	+	public override void run () {+		PathList stroke;+		double w;+		+		w = background_path.stroke;+		stroke = StrokeTool.get_stroke (background_path, w);++		IdleSource idle = new IdleSource (); +		idle.set_callback (() => {+			+			lock (cancelled) {			+				if (!cancelled) {+					original.full_stroke = stroke;+					GlyphCanvas.redraw ();+				}+			}+			+			return false;+		});+		idle.attach (null);		+	}+}++}

Contact

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