Commit aebfda5
move points relative to last position instead of absolute position
Changed files (4)
modifiedsrc/EditPointHandle.valamodifiedsrc/Font.valamodifiedsrc/Glyph.valamodifiedsrc/PenTool.vala
Diff
@@ -140,6 +140,13 @@ class EditPointHandle { } } + public void move_delta (double dx, double dy) {+ double px = px () + dx * Glyph.ivz ();+ double py = py () - dy * Glyph.ivz ();+ + move_to_coordinate (px, py);+ }+ public void move_to (double x, double y) { EditPoint.to_coordinate (ref x, ref y); move_to_coordinate (x, y);@@ -664,11 +664,6 @@ class Font : GLib.Object { double x1, x2, y1, y2; if (gl == null) {- print ("no glyph a\n");- glyph_cache.print_all ();- }-- if (gl == null) { gl = get_glyph_indice (4); } @@ -881,6 +881,18 @@ class Glyph : FontDisplay { move_selected_edit_point (x, y); } + public void move_selected_edit_point_delta (double dx, double dy) + requires (selected_point != null)+ {+ double px = ((!) selected_point).x + xc () - view_offset_x;+ double py = -1 * (((!) selected_point).y - yc () + view_offset_y);+ + px *= view_zoom;+ py *= view_zoom;+ + move_selected_edit_point (dx + px, dy + py);+ }+ public void move_selected_edit_point (double x, double y) { double xc, yc, xt, yt; double ivz = 1 / view_zoom;@@ -38,6 +38,9 @@ class PenTool : Tool { private static bool move_selected_handle = false; + private static double last_point_x = 0;+ private static double last_point_y = 0;+ public PenTool (string name) { base (name, "Edit path", 'p', CTRL); @@ -55,6 +58,9 @@ class PenTool : Tool { }); press_action.connect((self, b, x, y) => {+ last_point_x = x;+ last_point_y = y;+ press (b, x, y); }); @@ -104,22 +110,27 @@ class PenTool : Tool { if (move_selected_handle) { if (GridTool.is_visible ()) { GridTool.tie (ref x, ref y);+ selected_handle.set_point_type (PointType.CURVE);+ selected_handle.move_to (x, y);+ } else {+ selected_handle.set_point_type (PointType.CURVE);+ selected_handle.move_delta (x - last_point_x, y - last_point_y); } - selected_handle.set_point_type (PointType.CURVE);- selected_handle.move_to (x, y);- selected_handle.parent.recalculate_linear_handles (); // Fixa: redraw line only glyph.redraw_area (0, 0, glyph.allocation.width, glyph.allocation.height);+ + last_point_x = x;+ last_point_y = y; return; } // move edit point if (move_selected) {- glyph.move_selected_edit_point (x, y);+ glyph.move_selected_edit_point_delta (x - last_point_x, y - last_point_y); ep = (!) glyph.selected_point; if (tie_x_or_y_coordinates) {@@ -138,6 +149,9 @@ class PenTool : Tool { ep.recalculate_linear_handles (); }+ + last_point_x = x;+ last_point_y = y; } public void press (int button, int x, int y) {