The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Convert paths in background thread

These changes was commited to the Birdfont repository Fri, 24 Jun 2016 21:03:32 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
author Johan Mattsson <johan.mattsson.m@gmail.com>
Fri, 24 Jun 2016 21:03:32 +0000 (23:03 +0200)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Fri, 24 Jun 2016 21:03:32 +0000 (23:03 +0200)
commit 4327f43f965b4362596c4b3b93ca8206a752fd90
tree cb71fe551aca191c9737fe8a3c6befbbc11654b4
parent 52446ca04b7f55b4758fc31738997c5d741ebd5f
Convert paths in background thread

libbirdfont/MoveTool.vala
libbirdfont/OverviewTools.vala
libbirdfont/TransformTask.vala [new ]
--- a/libbirdfont/MoveTool.vala +++ b/libbirdfont/MoveTool.vala @@ -499,7 +499,6 @@ } 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 void convert_glyph_to_monochrome (Glyph glyph) { - Font font = BirdFont.get_current_font (); ObjectGroup embedded_paths; embedded_paths = new ObjectGroup ();
--- a/libbirdfont/OverviewTools.vala +++ b/libbirdfont/OverviewTools.vala @@ -305,55 +305,13 @@ 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) {
--- /dev/null +++ b/libbirdfont/TransformTask.vala @@ -1,1 +1,74 @@ + /* + 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 (); + } + } + + }