Clone in a terminal:
Commit 7b948f5
Johan Mattsson - 2015-04-07T10:36:08+00:00
7b948f5613f00fda422529e7855dbb7690025460johan.mattsson.m@gmail.com

Set lsb and rsb from text input

Changed files (2)

Diff

diff --git a/libbirdfont/Glyph.vala b/libbirdfont/Glyph.valaindex 02bd971..fd799c6 100644--- a/libbirdfont/Glyph.vala+++ b/libbirdfont/Glyph.vala@@ -434,6 +434,7 @@ public class Glyph : FontDisplay { 		}); 					 		left_line = new Line ("left", left_limit, true);+		left_line.lsb = true; 		left_line.position_updated.connect ((pos) => { 			left_limit = pos; 			update_other_spacing_classes ();@@ -443,6 +444,7 @@ public class Glyph : FontDisplay { 		left_line.position_updated (left_limit); 		 		right_line = new Line ("right", right_limit, true);+		right_line.rsb = true; 		right_line.position_updated.connect ((pos) => { 			right_limit = pos; 			update_other_spacing_classes ();@@ -482,7 +484,7 @@ public class Glyph : FontDisplay { 			add_line (guide); 		} 	}-+	 	public double get_left_side_bearing () { 		double x1, y1, x2, y2; 		diff --git a/libbirdfont/Line.vala b/libbirdfont/Line.valaindex 113f158..7cf69ca 100644--- a/libbirdfont/Line.vala+++ b/libbirdfont/Line.vala@@ -43,6 +43,9 @@ public class Line : GLib.Object { 	bool visible = true; 	bool moveable = true; 	+	public bool rsb = false;+	public bool lsb = false;+	 	public Line (string label = "No label set", double position = 10, bool vertical = false) { 		this.label = label; 		this.vertical = vertical;@@ -135,19 +138,43 @@ public class Line : GLib.Object { 			if (button == 3 || KeyBindings.has_shift ()) { 				move = false; 				text_input = true;		-				position = @"$pos";-+				+				g = MainWindow.get_current_glyph ();+				if (lsb) {+					position = @"$(g.get_left_side_bearing ())";+				} else if (rsb) {+					position = @"$(g.get_right_side_bearing ())";+				} else {+					position = @"$pos";+				}+			 				listener = new TextListener (t_("Position"), position, t_("Move")); 				 				listener.signal_text_input.connect ((text) => { 					string submitted_value; 					double parsed_value;+					Glyph glyph;+					double x1, y1, x2, y2; 					+					glyph = MainWindow.get_current_glyph (); 					submitted_value = text.replace (",", "."); 					parsed_value = double.parse (submitted_value); 					-					pos = parsed_value;+					if (lsb) {+						if (glyph.boundaries (out x1, out y1, out x2, out y2)) {+							parsed_value = x1 - parsed_value;+						} else {+							parsed_value = glyph.right_limit - parsed_value;+						}+					} else if (rsb) {+						if (glyph.boundaries (out x1, out y1, out x2, out y2)) {+							parsed_value += x2;+						} else {+							parsed_value = glyph.left_limit - parsed_value;+						}+					} 					+					pos = parsed_value; 					position_updated (parsed_value); 					GlyphCanvas.redraw (); 				});

Contact

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