Commit 3dea094
position is updated when background image is cut and larger control points
Changed files (10)
modifiedicons/active_edit_point.pngmodifiedicons/edit_point.pngmodifiedicons/edit_point_handle.pngdeletedicons/paste_path.pngdeletedicons/path2826.pngdeletedicons/path2863.pngmodifiedsrc/CutBackgroundTool.valamodifiedsrc/Glyph.valamodifiedsrc/GlyphBackgroundImage.valamodifiedsrc/Path.vala
Diff
Binary files a/icons/active_edit_point.png and b/icons/active_edit_point.png differBinary files a/icons/edit_point.png and b/icons/edit_point.png differBinary files a/icons/edit_point_handle.png and b/icons/edit_point_handle.png differdeleted file mode 100644Binary files a/icons/paste_path.png and /dev/null differdeleted file mode 100644Binary files a/icons/path2826.png and /dev/null differdeleted file mode 100644Binary files a/icons/path2863.png and /dev/null differ@@ -50,10 +50,15 @@ class CutBackgroundTool : Tool { cut_background_is_moving = true; cut_background_is_visible = true; } else {- do_cut (); - cut_background_is_visible = false;- cut_background_is_moving = false;+ if (cut_background_is_visible) {+ do_cut ();+ cut_background_is_visible = false;+ cut_background_is_moving = false;+ } else {+ cut_background_is_moving = true;+ cut_background_is_visible = true;+ } } }); @@ -95,9 +100,6 @@ class CutBackgroundTool : Tool { tb.select_tab_name (glyph.get_name ()); glyph.set_background_visible (true);-- zoom_background = MainWindow.get_tool ("zoom_background_image");- zoom_background.select_action (zoom_background); }); }@@ -117,6 +119,7 @@ class CutBackgroundTool : Tool { void do_cut () { double x, y; int h, w;+ double wc, hc; Glyph g = MainWindow.get_current_glyph (); GlyphBackgroundImage? b = g.get_background_image ();@@ -136,9 +139,9 @@ class CutBackgroundTool : Tool { Surface sg = new Surface.similar (bg.get_img (), bg.get_img ().get_content (), bg.size_margin, bg.size_margin); Context cg = new Context (sg); - int wc = (int) ((bg.size_margin - bg.get_img ().get_width ()) / 2);- int hc = (int) ((bg.size_margin - bg.get_img ().get_height ()) / 2);-+ wc = bg.get_margin_width ();+ hc = bg.get_margin_height ();+ cg.set_source_rgba (1, 1, 1, 1); cg.rectangle (0, 0, bg.size_margin, bg.size_margin); cg.fill ();@@ -188,6 +191,7 @@ class CutBackgroundTool : Tool { File img_dir; File img_file; string fn;+ double wc, hc; img_dir = f.get_backgrounds_folder ().get_child ("parts"); @@ -205,16 +209,15 @@ class CutBackgroundTool : Tool { fn = newbg.get_sha1 () + ".png"; img_file.set_display_name (fn); - // set position for the new background- newbg = new GlyphBackgroundImage ((!) f.get_backgrounds_folder ().get_child ("parts").get_child (fn).get_path ()); - newbg.img_x = g.path_coordinate_x (fmin (x1, x2));- newbg.img_y = g.path_coordinate_y (fmin (y1, y2));- - newbg.img_x = 100;- newbg.img_y = 100;+ // set position for the new background+ wc = newbg.get_margin_width ();+ hc = newbg.get_margin_height (); + newbg.img_x = g.path_coordinate_x (fmin (x1, x2)) - wc - 0.5;+ newbg.img_y = g.path_coordinate_y (fmin (y1, y2)) + hc + 0.5;+ new_image (newbg); } }@@ -135,8 +135,6 @@ class Glyph : FontDisplay { } } - // ((!) p).set_selected (true);- active_paths.append ((!) p); } }@@ -248,14 +246,6 @@ class Glyph : FontDisplay { bg = (!) b; - default_img_offset_x = -get_width () / 2;- default_img_offset_y = get_height () / 4;-- default_img_offset_x = 0;- default_img_offset_y = 0;- - bg.set_img_offset (default_img_offset_x, default_img_offset_y);- background_image = bg; Supplement.get_current_font ().touch ();@@ -91,6 +91,14 @@ class GlyphBackgroundImage { } + public double get_margin_width () {+ return ((size_margin - get_img ().get_width ()) / 2.0);+ }++ public double get_margin_height () {+ return ((size_margin - get_img ().get_height ()) / 2.0);+ }+ public void set_img_offset (double x, double y) { img_offset_x = x; img_offset_y = y;@@ -274,7 +282,7 @@ class GlyphBackgroundImage { Surface st; Context ct; - int wc, hc;+ double wc, hc; if (unlikely (get_img ().status () != Cairo.Status.SUCCESS)) { stderr.printf (@"Background image is invalid. (\"$path\")\n");@@ -286,9 +294,9 @@ class GlyphBackgroundImage { sg = new Surface.similar (get_img (), get_img ().get_content (), size_margin, size_margin); cg = new Context (sg); - wc = (int) ((size_margin - get_img ().get_width ()) / 2);- hc = (int) ((size_margin - get_img ().get_height ()) / 2);-+ wc = get_margin_width ();+ hc = get_margin_height ();+ cg.set_source_rgba (1, 1, 1, 1); cg.rectangle (0, 0, size_margin, size_margin); cg.fill ();@@ -213,8 +213,8 @@ class Path { get_line_points (e, en, out ax, out ay, out bx, out by); - cr.set_source_rgba (0.4, 0.4, 0.4, alpha);- cr.set_line_width (1 * (1/g.view_zoom));+ cr.set_source_rgba (0/255.0, 0/255.0, 0/255.0, 1);+ cr.set_line_width (1.7 * (1/g.view_zoom)); cr.line_to (ax, ay); cr.line_to (bx, by);@@ -240,13 +240,13 @@ class Path { img_left = (e.get_left_handle ().active) ? (!) active_edit_point_handle_image : (!) edit_point_handle_image; if (!(is_open () && e == points.last ().data)) {- draw_img_center (cr, img_right, e.get_right_handle ().x (), e.get_right_handle ().y ()); draw_line (handle_right, e, cr, 0.15);+ draw_img_center (cr, img_right, e.get_right_handle ().x (), e.get_right_handle ().y ()); } if (!(is_open () && e == points.first ().data)) {- draw_img_center (cr, img_left, e.get_left_handle ().x (), e.get_left_handle ().y ()); draw_line (handle_left, e, cr, 0.15);+ draw_img_center (cr, img_left, e.get_left_handle ().x (), e.get_left_handle ().y ()); } }