Commit d44dbd3
Skew selected glyphs in overview
Changed files (6)
modifiedlibbirdfont/Glyph.valamodifiedlibbirdfont/GlyphCollection.valamodifiedlibbirdfont/OverView.valamodifiedlibbirdfont/OverviewTools.valamodifiedlibbirdfont/ResizeTool.valamodifiedresources/icons.bf
Diff
@@ -1870,6 +1870,7 @@ public class Glyph : FontDisplay { g.empty = empty; g.open = open;+ g.version_id = version_id; return g; }@@ -22,7 +22,7 @@ public class GlyphCollection : GLib.Object { string name; bool unassigned = false; public Gee.ArrayList<Glyph> glyphs = new Gee.ArrayList<Glyph> ();- int selected;+ public int selected; public GlyphCollection (unichar unicode_character, string name) { this.unicode_character = unicode_character;@@ -147,7 +147,20 @@ public class GlyphCollection : GLib.Object { return n; }- ++ public GlyphCollection copy_deep () {+ GlyphCollection n = new GlyphCollection (unicode_character, name);+ + foreach (Glyph g in glyphs) {+ n.insert_glyph (g.copy (), false);+ }+ + n.selected = selected;+ n.unassigned = unassigned;+ + return n;+ }+ public int get_last_id () { return_val_if_fail (glyphs.size > 0, 0); return glyphs.get (glyphs.size - 1).version_id;@@ -53,8 +53,8 @@ public class OverView : FontDisplay { Gee.ArrayList<OverViewItem> visible_items = new Gee.ArrayList<OverViewItem> (); /** List of undo commands. */- Gee.ArrayList<OverViewUndoItem> undo_items = new Gee.ArrayList<OverViewUndoItem> ();- Gee.ArrayList<OverViewUndoItem> redo_items = new Gee.ArrayList<OverViewUndoItem> ();+ public Gee.ArrayList<OverViewUndoItem> undo_items = new Gee.ArrayList<OverViewUndoItem> ();+ public Gee.ArrayList<OverViewUndoItem> redo_items = new Gee.ArrayList<OverViewUndoItem> (); /** Show all characters that has been drawn. */ public bool all_available {@@ -852,7 +852,10 @@ public class OverView : FontDisplay { return; } - scroll_to_char (keyval);+ if (!KeyBindings.has_ctrl () && !KeyBindings.has_logo ()) {+ scroll_to_char (keyval);+ }+ selected_item = get_selected_item (); selected_items.clear ();@@ -29,10 +29,13 @@ public class OverviewTools : ToolCollection { public static Expander zoom_expander; + SpinButton skew;+ public OverviewTools () { Expander font_name = new Expander (); Expander character_sets = new Expander (t_("Character Sets")); Expander zoom_expander = new Expander (t_("Zoom"));+ Expander transform_expander = new Expander (t_("Transform")); expanders = new Gee.ArrayList<Expander> (); custom_character_sets = new Gee.ArrayList<LabelTool> ();@@ -82,9 +85,48 @@ public class OverviewTools : ToolCollection { character_sets.set_persistent (true); character_sets.set_unique (false); + skew = new SpinButton ("skew", t_("Skew"));+ skew.set_big_number (true);+ skew.set_int_value ("0.000");+ skew.set_int_step (1);+ skew.set_min (-100);+ skew.set_max (100);+ skew.show_icon (true);+ skew.set_persistent (false);+ transform_expander.add_tool (skew);+ + Tool transform = new Tool ("transform", t_("Transform"));+ transform.select_action.connect ((self) => {+ transform.selected = false;+ process_transform ();+ });+ transform.selected = false;+ transform.set_persistent (false);+ transform_expander.add_tool (transform);+ expanders.add (font_name); expanders.add (zoom_expander); expanders.add (character_sets);+ expanders.add (transform_expander);+ }+ + public void process_transform () {+ OverView o = get_overview ();+ Glyph g;+ OverView.OverViewUndoItem ui = new OverView.OverViewUndoItem ();+ + foreach (GlyphCollection gc in o.selected_items) {+ if (gc.length () > 0) {+ g = gc.get_current ();+ print (@"gc.selected: $(gc.selected)\n");+ ui.glyphs.add (gc.copy_deep ());+ g.add_help_lines ();+ DrawingTools.resize_tool.skew_glyph (g, -skew.get_value (), 0, false);+ }+ }+ + o.undo_items.add (ui);+ GlyphCanvas.redraw (); } public OverView get_overview () {@@ -394,14 +394,29 @@ public class ResizeTool : Tool { get_reseize_handle_position (out handle_x, out handle_y); return Path.distance (handle_x, x, handle_y, y) < 12 * MainWindow.units; }- + public void skew (double skew) { Glyph glyph = MainWindow.get_current_glyph ();+ skew_glyph (glyph, skew, last_skew, true);+ last_skew = skew;+ }+ + public void skew_glyph (Glyph glyph, double skew, double last_skew,+ bool selected_paths) {+ double dx, nx, nw, dw, x, y, w, h; double s = (skew - last_skew) / 100.0;- ++ if (!selected_paths) {+ glyph.clear_active_paths ();+ + foreach (Path path in glyph.get_visible_paths ()) {+ glyph.add_active_path (null, path);+ }+ }+ glyph.selection_boundaries (out x, out y, out w, out h);- + foreach (Path path in glyph.active_paths) { SvgParser.apply_matrix (path, 1, 0, s, 1, 0, 0); path.skew = skew;@@ -409,7 +424,7 @@ public class ResizeTool : Tool { } glyph.selection_boundaries (out nx, out y, out nw, out h);-+ dx = -(nx - x); foreach (Path p in glyph.active_paths) {@@ -417,12 +432,14 @@ public class ResizeTool : Tool { p.reset_stroke (); } - last_skew = skew;- dw = (nw - w); glyph.right_limit += dw; glyph.remove_lines ();- glyph.add_help_lines ();+ glyph.add_help_lines (); ++ if (!selected_paths) {+ glyph.clear_active_paths ();+ } } } @@ -14,6 +14,7 @@ <copyright>Copyright 2015 GNU Lesser General Public License</copyright> <weight>400</weight>+<units_per_em>1024</units_per_em> <horizontal> <top_limit>84.0000000000</top_limit>@@ -1350,6 +1351,18 @@ GNU Lesser General Public License</copyright> </layer> </glyph> </collection>+<collection name="transform">+ <selected id="0"/>+ <glyph id="0" left="-28" right="28">+ <layer name= "Layer" visible="true">+ <path data="B -14.0000000000,42.0000000000 M -14.0000000000,36.0000000000 M -14.0000000000,36.0000000000 M -20.0000000000,36.0000000000 M -20.0000000000,42.0000000000 M -14.0000000000,42.0000000000" />+ <path data="B -14.0000000000,32.9487179487 M -14.0000000000,26.9487179487 M -14.0000000000,26.9487179487 M -20.0000000000,26.9487179487 M -20.0000000000,32.9487179487 M -14.0000000000,32.9487179487" />+ <path data="B -14.0000000000,24.0000000000 M -14.0000000000,18.0000000000 M -14.0000000000,18.0000000000 M -20.0000000000,18.0000000000 M -20.0000000000,24.0000000000 M -14.0000000000,24.0000000000" />+ <path data="B -4.9487179487,42.0000000000 M -4.9487179487,18.0000000000 M -10.9487179487,18.0000000000 M -10.9487179487,42.0000000000 M -4.9487179487,42.0000000000" />+ <path data="B 6.0000000000,42.0000000000 M 6.0000000000,50.0000000000 M 8.0000000000,50.0000000000 M 22.0000000000,30.0000000000 M 8.0000000000,10.0000000000 M 6.0000000000,10.0000000000 M 6.0000000000,18.0000000000 M -2.0000000000,18.0000000000 M -2.0000000000,42.0000000000 M 6.0000000000,42.0000000000" />+ </layer>+ </glyph>+</collection> <collection name="ttf_units"> <selected id="1"/> <glyph id="1" left="-28" right="33.862433862433868">@@ -1571,6 +1584,7 @@ GNU Lesser General Public License</copyright> <ligature sequence="m e n u _ i c o n" replacement="menu_icon"/> <ligature sequence="o p e n _ f o n t" replacement="open_font"/> <ligature sequence="a d d _ l a y e r" replacement="add_layer"/>+<ligature sequence="t r a n s f o r m" replacement="transform"/> <ligature sequence="s e t t i n g s" replacement="settings"/> <ligature sequence="z o o m _ o u t" replacement="zoom_out"/> <ligature sequence="r o t a t i o n" replacement="rotation"/>