.
1 /*
2 Copyright (C) 2015 Johan Mattsson
3
4 This library is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 3 of the
7 License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13 */
14
15 namespace BirdFont {
16
17 public class StrokeTask : Task {
18 Path original; // path in gui thread
19 Path background_path; // path in background thread
20
21 public StrokeTask (Path path) {
22 base (null, true);
23 original = path;
24 background_path = path.copy ();
25 }
26
27 public StrokeTask.none () {
28 base (null, true);
29 original = new Path ();
30 background_path = new Path ();
31 }
32
33 public override void run () {
34 PathList stroke;
35 double w;
36 StrokeTool tool = new StrokeTool.with_task (this);
37
38 w = background_path.stroke;
39
40 stroke = tool.get_stroke (background_path, w);
41
42 IdleSource idle = new IdleSource ();
43 idle.set_callback (() => {
44 if (!is_cancelled ()) {
45 original.full_stroke = stroke;
46 GlyphCanvas.redraw ();
47 }
48
49 return false;
50 });
51 idle.attach (null);
52 }
53 }
54
55 }
56