The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Set lsb and rsb from text input

These changes was commited to the Birdfont repository Tue, 07 Apr 2015 10:36:08 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
author Johan Mattsson <johan.mattsson.m@gmail.com>
Tue, 07 Apr 2015 10:36:08 +0000 (12:36 +0200)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Tue, 07 Apr 2015 10:36:08 +0000 (12:36 +0200)
commit 7b948f5613f00fda422529e7855dbb7690025460
tree 844e0d0e42a2a9d7ac60969cc5f32794840ac8f7
parent 4a861384004abe07dcc93f0eeed58edb17a446be
Set lsb and rsb from text input

libbirdfont/Glyph.vala
libbirdfont/Line.vala
--- a/libbirdfont/Glyph.vala +++ b/libbirdfont/Glyph.vala @@ -434,6 +434,7 @@ }); 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 @@ 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 @@ add_line (guide); } } - + public double get_left_side_bearing () { double x1, y1, x2, y2;
--- a/libbirdfont/Line.vala +++ b/libbirdfont/Line.vala @@ -42,6 +42,9 @@ 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; @@ -135,19 +138,43 @@ 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 (); });