The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Separate font transformation in overview tab

These changes was commited to the Birdfont repository Sun, 12 Jun 2016 16:56:54 +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, 12 Jun 2016 16:56:54 +0000 (18:56 +0200)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Sun, 12 Jun 2016 16:56:54 +0000 (18:56 +0200)
commit f2905a601ced0010d2ab6e9bcb96c81b8049ffa3
tree b7b8fb7e0e4764cb7d6249f57fcf0dabfcdd1c22
parent d7ff615329c69ae06f79065190d0890343da2043
Separate font transformation in overview tab

libbirdfont/OverviewTools.vala
--- a/libbirdfont/OverviewTools.vala +++ b/libbirdfont/OverviewTools.vala @@ -15,6 +15,11 @@ using Cairo; namespace BirdFont { + + public enum Transform { + SLANT, + SIZE + } public class OverviewTools : ToolCollection { @@ -38,7 +43,8 @@ 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")); + Expander transform_slant_expander = new Expander (t_("Transform")); + Expander transform_size_expander = new Expander (); Expander glyph_expander = new Expander (t_("Glyph")); Expander multi_master = new Expander (t_("Multi-Master")); @@ -93,44 +99,72 @@ skew = new SpinButton ("skew_overview", t_("Skew")); skew.set_big_number (true); skew.set_int_value ("0.000"); + + FontSettings settings = BirdFont.get_current_font ().settings; + string? skew_value = settings.get_setting ("skew_overview"); + + if (skew_value != null) { + skew.set_int_value ((!) skew_value); + } + skew.set_int_step (1); skew.set_min (-100); skew.set_max (100); skew.show_icon (true); skew.set_persistent (false); - skew.new_value_action.connect ((self) => { - resize.set_value_round (100, false, false); + transform_slant_expander.add_tool (skew); + + Tool transform_slant = new Tool ("transform_slant", t_("Transform")); + transform_slant.set_icon ("transform"); + transform_slant.select_action.connect ((self) => { + FontSettings fs = BirdFont.get_current_font ().settings; + fs.set_setting ("skew_overview", @"$(skew.get_value ())"); + transform_slant.selected = false; + + process_transform (Transform.SLANT); + + BirdFont.get_current_font ().touch (); }); - transform_expander.add_tool (skew); + transform_slant.selected = false; + transform_slant.set_persistent (false); + transform_slant_expander.add_tool (transform_slant); resize = new SpinButton ("resize_overview", t_("Resize")); resize.set_big_number (true); - resize.set_int_value ("0.000"); + resize.set_int_value ("100.0"); + + string? resize_value = settings.get_setting ("resize_overview"); + + if (resize_value != null) { + resize.set_int_value ((!) resize_value); + + if (resize.get_value () <= 0) { + resize.set_int_value ("100.0"); + } + } + resize.set_int_step (1); resize.set_min (0); resize.set_max (300); resize.show_icon (true); resize.set_persistent (false); - resize.new_value_action.connect ((self) => { - skew.set_value_round (0, false, false); - }); - transform_expander.add_tool (resize); + transform_size_expander.add_tool (resize); + + Tool transform_size = new Tool ("transform_size", t_("Transform")); + transform_size.set_icon ("transform"); + transform_size.select_action.connect ((self) => { + FontSettings fs = BirdFont.get_current_font ().settings; + fs.set_setting ("resize_overview", @"$(resize.get_value ())"); + transform_size.selected = false; - Tool transform = new Tool ("transform", t_("Transform")); - transform.select_action.connect ((self) => { - FontSettings fs = BirdFont.get_current_font ().settings; - - fs.set_setting ("skew_overview", @"$(skew.get_value ())"); - transform.selected = false; - - process_transform (); + process_transform (Transform.SIZE); BirdFont.get_current_font ().touch (); }); - transform.selected = false; - transform.set_persistent (false); - transform_expander.add_tool (transform); - + transform_size.selected = false; + transform_size.set_persistent (false); + transform_size_expander.add_tool (transform_size); + Tool alternate = new Tool ("alternate", t_("Create alternate")); alternate.select_action.connect (add_new_alternate); glyph_expander.add_tool (alternate); @@ -179,7 +213,8 @@ expanders.add (font_name); expanders.add (zoom_expander); expanders.add (character_sets); - expanders.add (transform_expander); + expanders.add (transform_slant_expander); + expanders.add (transform_size_expander); expanders.add (glyph_expander); if (BirdFont.has_argument ("--test")) { @@ -256,7 +291,7 @@ MainWindow.tabs.add_tab (new OtfFeatureTable (gc)); } - public void process_transform () { + public void process_transform (Transform transform) { OverView o; Glyph g; OverView.OverViewUndoItem ui; @@ -273,13 +308,17 @@ ui.glyphs.add (gc.copy_deep ()); g.add_help_lines (); - if (skew.get_value () != 0) { - DrawingTools.resize_tool.skew_glyph (g, -skew.get_value (), 0, false); + if (transform == Transform.SLANT) { + if (skew.get_value () != 0) { + DrawingTools.resize_tool.skew_glyph (g, -skew.get_value (), 0, false); + } } - if (resize.get_value () != 100) { - double scale = resize.get_value () / 100; - DrawingTools.resize_tool.resize_glyph (g, scale, scale, 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); + } } } }