The Birdfont Source Code


All Repositories / birdfont.git / commitdiff – RSS feed

Lock grid and guides

These changes was commited to the Birdfont repository Fri, 26 Jun 2015 18:35:44 +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, 26 Jun 2015 18:35:44 +0000]

Updated Files

libbirdfont/DrawingTools.vala
libbirdfont/GridTool.vala
libbirdfont/Line.vala
libbirdfont/MenuTab.vala
libbirdfont/SpinButton.vala
resources/icons.bf
--- a/libbirdfont/DrawingTools.vala +++ b/libbirdfont/DrawingTools.vala @@ -78,7 +78,8 @@ public static Tool help_lines { get; set; } public static Tool xheight_help_lines { get; set; } public static Tool background_help_lines { get; set; } - public static Tool show_grid { get; set; } + public static GridTool show_grid { get; set; } + public static Tool lock_grid { get; set; } SpinButton x_coordinate; SpinButton y_coordinate; @@ -1062,6 +1063,26 @@ }); guideline_tools.add_tool (show_grid); grid_expander.visible = false; + + lock_grid = new Tool ("lock_grid", t_("Lock guides and grid")); + lock_grid.select_action.connect ((self) => { + SpinButton sb; + FontSettings fs; + + GridTool.lock_grid = !GridTool.lock_grid; + + foreach (Tool t in grid.tool) { + if (t is SpinButton) { + sb = (SpinButton) t; + sb.locked = GridTool.lock_grid; + } + } + + lock_grid.selected = GridTool.lock_grid; + fs = BirdFont.get_current_font ().settings; + fs.set_setting ("lock_grid", @"$(GridTool.lock_grid)"); + }); + guideline_tools.add_tool (lock_grid); // Zoom tools zoom_bar = new ZoomBar (); @@ -1527,12 +1548,14 @@ font.grid_width.clear (); foreach (Tool t in grid_expander.tool) { + return_if_fail (t is SpinButton); w = (SpinButton) t; font.grid_width.add (w.get_display_value ()); } }); grid_width.select_action.connect((self) => { + return_if_fail (self is SpinButton); SpinButton sb = (SpinButton) self; GridTool.set_grid_width (sb.get_value ()); GlyphCanvas.redraw ();
--- a/libbirdfont/GridTool.vala +++ b/libbirdfont/GridTool.vala @@ -17,7 +17,7 @@ namespace BirdFont { - class GridTool : Tool { + public class GridTool : Tool { static Gee.ArrayList<Line> horizontal; static Gee.ArrayList<Line> vertical; @@ -29,6 +29,9 @@ public static double size_y; public static Gee.ArrayList<SpinButton> sizes; + + /** Lock grid and guides. */ + public static bool lock_grid = false; public GridTool (string n) { string units;
--- a/libbirdfont/Line.vala +++ b/libbirdfont/Line.vala @@ -200,11 +200,6 @@ void redraw_line () { GlyphCanvas.redraw (); - } - - public void move_line_to (int x, int y, WidgetAllocation allocation) { - set_move (true); - event_move_to (x, y, allocation); } public bool event_move_to (int x, int y, WidgetAllocation allocation) { @@ -218,7 +213,7 @@ if (!moveable) { return false; } - + if (is_vertical ()) { // over line handle (y) if (y > g.allocation.height - 10) { p = pos; @@ -251,20 +246,22 @@ double np = pos; redraw_line (); // clear old position - if (is_vertical ()) { - pos = Glyph.path_coordinate_x (x); + if (!GridTool.lock_grid) { + if (is_vertical ()) { + pos = Glyph.path_coordinate_x (x); - if (GridTool.is_visible ()) { - GridTool.tie_coordinate (ref pos, ref none); + if (GridTool.is_visible ()) { + GridTool.tie_coordinate (ref pos, ref none); + } + redraw_line (); // draw at new position + } else { + pos = Glyph.path_coordinate_y (y); + + if (GridTool.is_visible ()) { + GridTool.tie_coordinate (ref none, ref pos); + } + redraw_line (); } - redraw_line (); // draw at new position - } else { - pos = Glyph.path_coordinate_y (y); - - if (GridTool.is_visible ()) { - GridTool.tie_coordinate (ref none, ref pos); - } - redraw_line (); } if (Math.fabs (np - pos) > 10) { @@ -419,10 +416,7 @@ cr.restore (); } - - - } }
--- a/libbirdfont/MenuTab.vala +++ b/libbirdfont/MenuTab.vala @@ -245,6 +245,11 @@ } DrawingTools.set_stroke_tool_visibility (); + + string lock_grid = f.settings.get_setting ("lock_grid"); + bool lg = bool.parse (lock_grid); + GridTool.lock_grid = lg; + DrawingTools.lock_grid.selected = GridTool.lock_grid; } // FIXME: background thread
--- a/libbirdfont/SpinButton.vala +++ b/libbirdfont/SpinButton.vala @@ -41,6 +41,9 @@ double last_active_time = 0; bool waiting_for_icon_switch = false; bool show_icon_tool_icon = false; + + /** Lock the button to a fixed value. */ + public bool locked = false; public SpinButton (string? name = null, string tip = "") { base (null , tip); @@ -70,12 +73,18 @@ } for (int i = 0; i < n; i++) { - if (py < 9) increase (); - if (py > 25) decrease (); + if (py < 9 && !locked) { + increase (); + } + + if (py > 25 && !locked) { + decrease (); + } } } - value_from_motion = true; + value_from_motion = !locked; + begin_y = ty; begin_value = get_int_value ();
--- a/resources/icons.bf +++ b/resources/icons.bf @@ -782,6 +782,15 @@ <layer name= "Layer" visible="true"> <path data="B 12.0000000000,47.9996000000 C 12.0000000000,44.0256000000 12.0000000000,40.0516000000 12.0000000000,36.0776000000 M 12.0000000000,24.0776000000 M 12.0000000000,8.0000000000 M -8.0000000000,8.0000000000 M -8.0000000000,24.0776000000 M -8.0000000000,36.0776000000 C -8.0000000000,40.0516000000 -8.0000000000,44.0256000000 -8.0000000000,47.9996000000 M 12.0000000000,47.9996000000" /> <path data="B -0.3189655172,32.8505747126 M -0.3189655172,30.5258747126 M -0.3189655172,28.0958747126 M -0.3189655172,15.5952747126 M -0.3189655172,10.7034356322 M -0.3189655172,8.0549167011 M 4.3821839081,8.0549167011 M 4.3821839081,10.7034356322 M 4.3821839081,15.5952747126 M 4.3821839081,28.0958747126 M 4.3821839081,30.5258747126 M 4.3821839081,32.8505747126 M -0.3189655172,32.8505747126" /> + </layer> + </glyph> + </collection> + <collection name="lock_grid"> + <selected id="0"/> + <glyph id="0" left="-28" right="28"> + <layer name= "Layer" visible="true"> + <path data="B -17.0578842315,28.2275449102 M -17.0578842315,5.0339321357 M 18.9421157685,5.0339321357 M 18.9421157685,28.2275449102 M 14.9421157685,32.2275449102 M 12.9421157685,32.2275449102 C 12.9421157685,38.9156663475 11.7104167802,42.6277601901 9.5877372967,45.1331446395 C 7.3376970441,47.7888521558 4.1048073946,49.0339321357 0.9421157685,49.0339321357 T C -2.3697594249,49.0339321357 -5.5966436591,47.6065397199 -7.8685490061,44.6564085537 C -9.8129725013,42.1315215196 -11.0578842315,38.6492949922 -11.0578842315,32.2275449102 M -13.0578842315,32.2275449102 M -17.0578842315,28.2275449102" /> + <path data="B 0.9421157685,45.6247504990 C 3.0955099958,45.6247504990 5.0387264990,44.9138823663 6.2629233977,43.6178377431 C 8.3891601165,41.3668128712 8.9421157685,37.3505326027 8.9421157685,32.2275449102 M 5.1421157685,32.2275449102 M -7.0578842315,32.2275449102 C -7.0578842315,36.6433734966 -6.7615353499,39.5277300307 -5.4742864127,41.8310568179 C -4.3126227376,43.9096687965 -2.3439738299,45.6247504990 0.9421157685,45.6247504990 T" /> </layer> </glyph> </collection> @@ -1548,6 +1557,7 @@ <ligature sequence="s e l e c t _ a l l" replacement="select_all"/> <ligature sequence="p o i n t _ t o o l" replacement="point_tool"/> <ligature sequence="f u l l _ g l y p h" replacement="full_glyph"/> + <ligature sequence="l o c k _ g r i d" replacement="lock_grid"/> <ligature sequence="s a v e _ f o n t" replacement="save_font"/> <ligature sequence="i n f o _ i c o n" replacement="info_icon"/> <ligature sequence="s h o w _ g r i d" replacement="show_grid"/>