Commit 35432e6
Lock grid and guides
Changed files (6)
modifiedlibbirdfont/DrawingTools.valamodifiedlibbirdfont/GridTool.valamodifiedlibbirdfont/Line.valamodifiedlibbirdfont/MenuTab.valamodifiedlibbirdfont/SpinButton.valamodifiedresources/icons.bf
Diff
@@ -78,7 +78,8 @@ public class DrawingTools : ToolCollection { 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;@@ -1063,6 +1064,26 @@ public class DrawingTools : ToolCollection { 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 (); zoom_bar.new_zoom.connect ((z) => {@@ -1527,12 +1548,14 @@ public class DrawingTools : ToolCollection { 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 ();@@ -17,7 +17,7 @@ using Math; namespace BirdFont { -class GridTool : Tool {+public class GridTool : Tool { static Gee.ArrayList<Line> horizontal; static Gee.ArrayList<Line> vertical;@@ -30,6 +30,9 @@ class GridTool : Tool { public static Gee.ArrayList<SpinButton> sizes; + /** Lock grid and guides. */+ public static bool lock_grid = false;+ public GridTool (string n) { string units; base (n, t_("Show grid"));@@ -200,11 +200,6 @@ public class Line : GLib.Object { 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 @@ public class Line : GLib.Object { if (!moveable) { return false; }-+ if (is_vertical ()) { // over line handle (y) if (y > g.allocation.height - 10) { p = pos;@@ -251,20 +246,22 @@ public class Line : GLib.Object { 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);- }- redraw_line (); // draw at new position- } else {- pos = Glyph.path_coordinate_y (y);- - if (GridTool.is_visible ()) {- GridTool.tie_coordinate (ref none, ref pos);+ 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 (); } if (Math.fabs (np - pos) > 10) {@@ -419,9 +416,6 @@ public class Line : GLib.Object { cr.restore (); }-- - } }@@ -245,6 +245,11 @@ public class MenuTab : FontDisplay { } 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@@ -42,6 +42,9 @@ public class SpinButton : Tool { 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 @@ public class SpinButton : Tool { } 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 ();@@ -785,6 +785,15 @@ GNU Lesser General Public License</copyright> </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> <collection unicode="U+6d"> <selected id="1"/> <glyph id="1" left="-28" right="28">@@ -1548,6 +1557,7 @@ GNU Lesser General Public License</copyright> <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"/>