The Birdfont Source Code


All Repositories / birdfont.git / commitdiff – RSS feed

Point type settings

These changes was commited to the Birdfont repository Fri, 08 May 2015 21:56:02 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
[Fri, 08 May 2015 21:56:02 +0000]

Updated Files

libbirdfont/BirdFont.vala
libbirdfont/DrawingTools.vala
libbirdfont/MenuTab.vala
libbirdfont/RecentFiles.vala
--- a/libbirdfont/BirdFont.vala +++ b/libbirdfont/BirdFont.vala @@ -577,9 +577,9 @@ if (!is_null (MainWindow.tools)) { MainWindow.get_drawing_tools ().remove_all_grid_buttons (); - MainWindow.get_drawing_tools ().add_new_grid (1); - MainWindow.get_drawing_tools ().add_new_grid (2); - MainWindow.get_drawing_tools ().add_new_grid (4); + DrawingTools.add_new_grid (1); + DrawingTools.add_new_grid (2); + DrawingTools.add_new_grid (4); } if (!is_null (Toolbox.background_tools)) {
--- a/libbirdfont/DrawingTools.vala +++ b/libbirdfont/DrawingTools.vala @@ -23,7 +23,7 @@ public Gee.ArrayList<Expander> expanders = new Gee.ArrayList<Expander> (); Expander draw_tools; - Expander grid_expander; + public static Expander grid_expander; Expander shape_tools; public static Expander draw_tool_modifiers; public static Expander stroke_expander; @@ -48,10 +48,10 @@ public static BackgroundTool move_background; public static Tool move_canvas; - Tool quadratic_points; - Tool cubic_points; - Tool double_points; - Tool convert_points; + static Tool quadratic_points; + static Tool cubic_points; + static Tool double_points; + static Tool convert_points; public static CutBackgroundTool cut_background; Tool show_bg; @@ -799,10 +799,10 @@ // edit stroke width object_stroke = new SpinButton ("object_stroke", t_("Stroke width")); + object_stroke.set_big_number (true); object_stroke.set_value_round (2); object_stroke.set_max (0.01); object_stroke.set_max (50); - object_stroke.set_big_number (true); object_stroke.new_value_action.connect((self) => { Font f; @@ -1314,7 +1314,9 @@ IdleSource idle = new IdleSource (); // Do this in idle, after the animation - idle.set_callback (() => { + idle.set_callback (() => { + Font f = BirdFont.get_current_font (); + quadratic_points.set_selected (false); cubic_points.set_selected (false); double_points.set_selected (false); @@ -1322,12 +1324,15 @@ switch (point_type) { case PointType.QUADRATIC: quadratic_points.set_selected (true); + f.settings.set_setting ("point_type", "quadratic"); break; case PointType.CUBIC: cubic_points.set_selected (true); + f.settings.set_setting ("point_type", "cubic"); break; case PointType.DOUBLE_CURVE: double_points.set_selected (true); + f.settings.set_setting ("point_type", "double_curve"); break; } @@ -1338,6 +1343,19 @@ }); idle.attach (null); + } + + public static void set_default_point_type (string type) { + if (type == "quadratic") { + quadratic_points.set_selected (true); + point_type = PointType.QUADRATIC; + } else if (type == "cubic") { + cubic_points.set_selected (true); + point_type = PointType.CUBIC; + } else if (type == "double_curve") { + double_points.set_selected (true); + point_type = PointType.DOUBLE_CURVE; + } } public override Gee.ArrayList<Expander> get_expanders () { @@ -1364,7 +1382,7 @@ MainWindow.get_toolbox ().select_tool (sb); } - public SpinButton add_new_grid (double size = 2) { + public static SpinButton add_new_grid (double size = 2) { SpinButton grid_width = new SpinButton ("grid_width", t_("Set size for grid")); Toolbox tb = MainWindow.get_toolbox ();
--- a/libbirdfont/MenuTab.vala +++ b/libbirdfont/MenuTab.vala @@ -194,6 +194,26 @@ idle.attach (null); } + public static void apply_font_setting (Font f) { + DrawingTools.background_scale.set_value (f.background_scale); + + DrawingTools.grid_expander.tool.clear (); + + foreach (string grid in f.grid_width) { + DrawingTools.add_new_grid (double.parse (grid)); + } + + string sw = f.settings.get_setting ("stroke_width"); + if (sw != ""){ + StrokeTool.stroke_width = double.parse (sw); + DrawingTools.object_stroke.set_value_round (StrokeTool.stroke_width); + } + + string pt = f.settings.get_setting ("point_type"); + print (@"PT: $pt\n"); + DrawingTools.set_default_point_type (pt); + } + public static void set_font_setting_from_tools (Font f) { string stroke_width; @@ -496,7 +516,7 @@ MenuTab.load_callback.file_loaded.connect (() => { Font f = BirdFont.get_current_font (); - MenuTab.set_font_setting_from_tools (f); + MenuTab.apply_font_setting (f); }); }
--- a/libbirdfont/RecentFiles.vala +++ b/libbirdfont/RecentFiles.vala @@ -220,11 +220,8 @@ DrawingTools.background_scale.set_value (f.background_scale); KerningTools.update_kerning_classes (); MenuTab.show_all_available_characters (); - }); - - MenuTab.load_callback.file_loaded.connect (() => { - Font f = BirdFont.get_current_font (); - MenuTab.set_font_setting_from_tools (f); + + MenuTab.apply_font_setting (f); }); dialog.signal_discard.connect (() => {