The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Store grid size in font

These changes was commited to the Birdfont repository Tue, 19 May 2015 09:29:47 +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>
Tue, 19 May 2015 09:29:47 +0000 (11:29 +0200)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Tue, 19 May 2015 09:29:47 +0000 (11:29 +0200)
commit 5219aa01fc7a1c40b9777fa5518ed6376a75c541
tree b738daa3a3b4ccb66d13ccfe12786880e800c80a
parent e92210f8c3b3db202f871ddfb83b001d8150e120
Store grid size in font

libbirdfont/DrawingTools.vala
libbirdfont/MenuTab.vala
--- a/libbirdfont/DrawingTools.vala +++ b/libbirdfont/DrawingTools.vala @@ -1461,17 +1461,27 @@ } public void parse_grid (string spin_button_value) { - SpinButton sb = add_new_grid (); - sb.set_value (spin_button_value); + SpinButton sb = add_new_grid (double.parse (spin_button_value), false); MainWindow.get_toolbox ().select_tool (sb); } - public static SpinButton add_new_grid (double size = 2) { + public static SpinButton add_new_grid (double size = 2, bool update_settings_in_font = true) { SpinButton grid_width = new SpinButton ("grid_width", t_("Set size for grid")); Toolbox tb = MainWindow.get_toolbox (); + + grid_width.set_value_round (size); grid_width.new_value_action.connect((self) => { + Font font = BirdFont.get_current_font (); + SpinButton w; + grid_width.select_action (grid_width); + font.grid_width.clear (); + + foreach (Tool t in grid_expander.tool) { + w = (SpinButton) t; + font.grid_width.add (w.get_display_value ()); + } }); grid_width.select_action.connect((self) => { @@ -1481,10 +1491,6 @@ }); grid_expander.add_tool (grid_width); - - GridTool.sizes.add (grid_width); - - grid_width.set_value_round (size); tb.update_expanders (); @@ -1492,6 +1498,15 @@ tb.select_tool (grid_width); grid_width.set_active (false); + + if (update_settings_in_font) { + GridTool.sizes.add (grid_width); + + foreach (Tool t in grid_expander.tool) { + SpinButton sb = (SpinButton) t; + BirdFont.get_current_font ().grid_width.add (sb.get_display_value ()); + } + } return grid_width; }
--- a/libbirdfont/MenuTab.vala +++ b/libbirdfont/MenuTab.vala @@ -200,7 +200,7 @@ DrawingTools.grid_expander.tool.clear (); foreach (string grid in f.grid_width) { - DrawingTools.add_new_grid (double.parse (grid)); + DrawingTools.add_new_grid (double.parse (grid), false); } string sw = f.settings.get_setting ("stroke_width");