Clone in a terminal:
Commit 3dea094
Johan Mattsson - 2012-09-11T19:13:41+00:00
3dea094671c9e459cc7cbfc0f97eb0da05c6de75johan.mattsson.m@gmail.com

position is updated when background image is cut and larger control points

Changed files (10)

Diff

diff --git a/icons/active_edit_point.png b/icons/active_edit_point.pngindex d70f061..798215d 100644Binary files a/icons/active_edit_point.png and b/icons/active_edit_point.png differdiff --git a/icons/edit_point.png b/icons/edit_point.pngindex 1e2d681..098bace 100644Binary files a/icons/edit_point.png and b/icons/edit_point.png differdiff --git a/icons/edit_point_handle.png b/icons/edit_point_handle.pngindex c93103d..9688a84 100644Binary files a/icons/edit_point_handle.png and b/icons/edit_point_handle.png differdiff --git a/icons/paste_path.png b/icons/paste_path.pngdeleted file mode 100644index fc8f962..0000000Binary files a/icons/paste_path.png and /dev/null differdiff --git a/icons/path2826.png b/icons/path2826.pngdeleted file mode 100644index b71e970..0000000Binary files a/icons/path2826.png and /dev/null differdiff --git a/icons/path2863.png b/icons/path2863.pngdeleted file mode 100644index 8fafb68..0000000Binary files a/icons/path2863.png and /dev/null differdiff --git a/src/CutBackgroundTool.vala b/src/CutBackgroundTool.valaindex cfdccf6..aa27d18 100644--- a/src/CutBackgroundTool.vala+++ b/src/CutBackgroundTool.vala@@ -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); 	} }diff --git a/src/Glyph.vala b/src/Glyph.valaindex 8a1c603..77add90 100644--- a/src/Glyph.vala+++ b/src/Glyph.vala@@ -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 ();diff --git a/src/GlyphBackgroundImage.vala b/src/GlyphBackgroundImage.valaindex 6f5d2e1..4f627b0 100644--- a/src/GlyphBackgroundImage.vala+++ b/src/GlyphBackgroundImage.vala@@ -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 ();diff --git a/src/Path.vala b/src/Path.valaindex 8fbbe30..6ca5665 100644--- a/src/Path.vala+++ b/src/Path.vala@@ -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 ()); 		} 	} 

Contact

Email: johan.mattsson.m@gmail.com
Mastodon: typo.social/@birdfont
GitHub: johanmattssonm
LinkedIn: johan-mattsson-2ab324112