Commit 232ab49
more grid fixes
Changed files (4)
modifiedlibbirdfont/Glyph.valamodifiedlibbirdfont/GridTool.valamodifiedlibbirdfont/Line.valamodifiedlibbirdfont/PenTool.vala
Diff
@@ -1390,7 +1390,7 @@ public class Glyph : FontDisplay { cr.save (); draw_background_color (cr, 1); cr.restore ();-+ if (background_image != null && background_image_visible) { ((!)background_image).draw (cr, allocation, view_offset_x, view_offset_y, view_zoom); }@@ -176,7 +176,7 @@ class GridTool : Tool { ypos.move_line_to (x, y, g.allocation); } else { xpos = new Line ("", x, Line.VERTICAL);- ypos = new Line ("", y, Line.HORIZONTAL);+ ypos = new Line ("", -y, Line.HORIZONTAL); } m = double.MAX;@@ -204,13 +204,17 @@ class GridTool : Tool { if (!coordinate) { x = Glyph.reverse_path_coordinate_x (xmin.get_pos ());- y = Glyph.reverse_path_coordinate_y (-ymin.get_pos ());+ y = Glyph.reverse_path_coordinate_y (ymin.get_pos ()); } else { x = xmin.get_pos ();- y = ymin.get_pos ();+ y = -ymin.get_pos (); } } + public static void set_visible (bool v) {+ visible = v;+ }+ public static bool is_visible () { return visible; }@@ -160,7 +160,7 @@ public class Line : GLib.Object { swap_lines (); } - if (is_vertical ()) {+ if (is_vertical ()) { // over line handle y if (ay > g.allocation.height - 10) { p = get_coordinate ();@@ -175,7 +175,7 @@ public class Line : GLib.Object { set_active (a); - } else {+ } else { // over line handle x if (ax > g.allocation.width - 10) { p = get_coordinate (); c = ay * ivz + g.view_offset_y;@@ -45,6 +45,8 @@ public class PenTool : Tool { public static double precision = 1; private static ImageSurface? tie_icon = null; + /** First move action must move the current point in to the grid. */+ bool first_move_action = false; /** Move curve handle instead of control point. */ private bool last_selected_is_handle = false;@@ -76,6 +78,8 @@ public class PenTool : Tool { }); press_action.connect ((self, b, x, y) => {+ first_move_action = true;+ if (GridTool.is_visible ()) { tie_pixels (ref x, ref y); }@@ -162,7 +166,7 @@ public class PenTool : Tool { double coordinate_x, coordinate_y; double px = 0; double py = 0;- + control_point_event (x, y); curve_active_corner_event (x, y); set_default_handle_positions ();@@ -684,6 +688,19 @@ public class PenTool : Tool { if (distance < CONTACT_SURFACE) { set_active_edit_point (ep);+ + if (first_move_action && GridTool.is_visible () && move_selected) {+ double coordinate_x = e.x;+ double coordinate_y = e.y;+ GridTool.tie_coordinate (ref coordinate_x, ref coordinate_y);+ int px = Glyph.reverse_path_coordinate_x (coordinate_x);+ int py = Glyph.reverse_path_coordinate_y (coordinate_y);+ + last_point_x += Glyph.reverse_path_coordinate_x (e.x) - px;+ last_point_y += Glyph.reverse_path_coordinate_y (e.y) - py;+ + first_move_action = false;+ } } }