The Birdfont Source Code


All Repositories / birdfont.git / commitdiff – 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
[Tue, 19 May 2015 09:29:47 +0000]

Updated Files

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");