The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Skew selected glyphs in overview

These changes was commited to the Birdfont repository Sun, 28 Jun 2015 14:19:46 +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>
Sun, 28 Jun 2015 14:19:46 +0000 (16:19 +0200)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Sun, 28 Jun 2015 14:19:46 +0000 (16:19 +0200)
commit d44dbd33d82ecc6552d98b18d87e288262c7106e
tree 6a71dd41d4dcb82804c681b3d607e420e08e8306
parent 5050aacbdf803a5a839ae72dc078db6cb21f27a4
Skew selected glyphs in overview

libbirdfont/Glyph.vala
libbirdfont/GlyphCollection.vala
libbirdfont/OverView.vala
libbirdfont/OverviewTools.vala
libbirdfont/ResizeTool.vala
resources/icons.bf
--- a/libbirdfont/Glyph.vala +++ b/libbirdfont/Glyph.vala @@ -1870,6 +1870,7 @@ g.empty = empty; g.open = open; + g.version_id = version_id; return g; }
--- a/libbirdfont/GlyphCollection.vala +++ b/libbirdfont/GlyphCollection.vala @@ -22,7 +22,7 @@ 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 @@ 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;
--- a/libbirdfont/OverView.vala +++ b/libbirdfont/OverView.vala @@ -53,8 +53,8 @@ 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 @@ return; } - scroll_to_char (keyval); + if (!KeyBindings.has_ctrl () && !KeyBindings.has_logo ()) { + scroll_to_char (keyval); + } + selected_item = get_selected_item (); selected_items.clear ();
--- a/libbirdfont/OverviewTools.vala +++ b/libbirdfont/OverviewTools.vala @@ -28,11 +28,14 @@ public ZoomBar zoom_bar; 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 @@ 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 () {
--- a/libbirdfont/ResizeTool.vala +++ b/libbirdfont/ResizeTool.vala @@ -394,14 +394,29 @@ 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,22 +424,24 @@ } glyph.selection_boundaries (out nx, out y, out nw, out h); - + dx = -(nx - x); foreach (Path p in glyph.active_paths) { p.move (dx, 0); 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 (); + } } } }
--- a/resources/icons.bf +++ b/resources/icons.bf @@ -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> @@ -1347,6 +1348,18 @@ <path data="B 1.3468332665,0.1692575111 C 1.2834691572,0.1602054954 1.2201050479,0.1511534798 1.1567409385,0.1421014642 C 1.1070920961,0.1350087724 1.0574432537,0.1279160807 1.0077944113,0.1208233889 C 0.7470657585,0.0835764385 0.4863371057,0.0463294877 0.2256084529,0.0090825377 C -0.6241753702,-0.1123003320 -1.5096183688,0.1115089735 -2.3359943542,0.2729492001 C -3.4004133519,0.5612696324 -3.7172783914,0.6183436368 -4.7787316153,1.0327653911 C -5.2463420640,1.2153339096 -5.7008121032,1.4299187072 -6.1618523471,1.6284953653 C -6.6425428268,1.8819967608 -7.1350656555,2.1142299243 -7.6039237861,2.3889995517 C -8.6119100846,2.9797198602 -9.6343004883,3.6915539228 -10.5071329930,4.4688625568 C -11.0284791729,4.9331519648 -11.5004218221,5.4501083349 -11.9970662367,5.9407312239 C -11.2511325125,6.6067514032 -10.5051987884,7.2727715825 -9.7592650643,7.9387917617 C -9.3121787102,7.4998261524 -8.8875727112,7.0367251640 -8.4180060021,6.6218949337 C -7.3166971806,5.6489635414 -6.0661691868,4.9572991233 -4.7715057649,4.2868663668 C -4.3811325485,4.1217977241 -3.9961806796,3.9432703596 -3.6003861157,3.7916604387 C -2.7068413247,3.4493862706 -2.4515150191,3.4059024729 -1.5604711864,3.1709767735 C -1.2999914674,3.1224748141 -1.0413931870,3.0624674772 -0.7790320294,3.0254708952 C -0.3230149753,2.9611661313 -0.0064729961,3.0063822819 -0.1986300432,2.9789346719 C 0.0620900847,3.0161804096 0.3228102140,3.0534261372 0.5835303426,3.0906718699 C 0.6331791850,3.0977645616 0.6828280274,3.1048572534 0.7324768698,3.1119499452 C 0.7958409791,3.1210019608 0.8592050885,3.1300539764 0.9225691978,3.1391059920 C 1.0639905540,2.1491564984 1.2054119102,1.1592070047 1.3468332665,0.1692575111" /> <path data="B 4.2435014141,28.6289531377 C 4.4414919998,27.9385972905 4.9864573070,27.4170730917 5.4304160570,26.8820957217 C 5.8151067004,26.5110574216 6.1843518342,26.1233074649 6.5844879871,25.7689808213 C 7.7343256032,24.7507821398 8.2790928341,24.4092011364 9.5383860502,23.5038451211 C 11.0923001362,22.5164733501 12.6445895686,21.5316130381 14.3530655191,20.8244674573 C 14.8799007902,20.6064080613 15.4268177692,20.4404397009 15.9636938943,20.2484258228 C 15.6951714433,19.2851523967 15.4266489923,18.3218789707 15.1581265413,17.3586055446 C 14.5482465162,17.5740206493 13.9272962458,17.7603428633 13.3284864658,18.0048508586 C 11.4123395935,18.7872583043 9.6751857181,19.8687659727 7.9328534951,20.9696262643 C 6.5486225393,21.9596419429 5.9547210229,22.3305407355 4.6857795333,23.4462870818 C 4.2250525495,23.8513920082 3.7979828515,24.2932430852 3.3540845106,24.7167210868 C 2.9954027154,25.1378590273 1.9915586379,26.2121124817 1.7591565861,26.8264996947 C 1.5143094385,27.4737872530 1.4203167488,28.1684806185 1.2508968301,28.8394710804 C 2.2484316914,28.7692984328 3.2459665527,28.6991257853 4.2435014141,28.6289531377" /> <path data="B 7.9082847141,33.4384896360 C 8.1062752999,32.7481337888 8.6512406071,32.2266095899 9.0951993571,31.6916322200 C 9.4798900004,31.3205939199 9.8491351343,30.9328439632 10.2492712871,30.5785173196 C 11.3991089032,29.5603186381 11.9438761341,29.2187376347 13.2031693502,28.3133816194 C 14.7570834362,27.3260098484 16.3093728686,26.3411495364 18.0178488191,25.6340039556 C 18.5446840902,25.4159445596 19.0916010692,25.2499761993 19.6284771943,25.0579623211 C 19.3599547433,24.0946888951 19.0914322923,23.1314154690 18.8229098414,22.1681420430 C 18.2130298162,22.3835571476 17.5920795458,22.5698793616 16.9932697658,22.8143873569 C 15.0771228935,23.5967948026 13.3399690181,24.6783024710 11.5976367951,25.7791627626 C 10.2134058394,26.7691784412 9.6195043229,27.1400772338 8.3505628333,28.2558235801 C 7.8898358496,28.6609285065 7.4627661516,29.1027795835 7.0188678107,29.5262575852 C 6.6601860155,29.9473955256 5.6563419380,31.0216489800 5.4239398862,31.6360361930 C 5.1790927386,32.2833237513 5.0851000489,32.9780171168 4.9156801302,33.6490075787 C 5.9132149915,33.5788349311 6.9107498528,33.5086622836 7.9082847141,33.4384896360" /> + </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> @@ -1571,6 +1584,7 @@ <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"/>