The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Fix spin button

These changes was commited to the Birdfont repository Thu, 28 May 2015 22:04:14 +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>
Thu, 28 May 2015 22:04:14 +0000 (00:04 +0200)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Thu, 28 May 2015 22:04:14 +0000 (00:04 +0200)
commit e3d0bcb62cb41afba779730304f513d57c48067f
tree cbac4523e5ebc5b5758e8ed695207f6d291687ec
parent 7b0a2ed390d6c4991f3734f1da1a50058ce695a0
Fix spin button

libbirdfont/SpinButton.vala
--- a/libbirdfont/SpinButton.vala +++ b/libbirdfont/SpinButton.vala @@ -396,26 +396,25 @@ return (negative) ? -r : r; } - public string get_short_display_value () { - + public string get_short_display_value () { if (!big_number) { return @"$n0.$n1$n2$n3"; } if (negative) { if (n0 == 0 && n1 == 0) { - return @" -$n2.$n3$n4"; + return @"-$n2.$n3$n4"; } if (n0 == 0) { - return @" -$n1$n2.$n3"; + return @"-$n1$n2.$n3"; } - return @" -$n0$n1$n2"; + return @"-$n0$n1$n2"; } if (n0 == 0 && n1 == 0) { - return @" $n2.$n3$n4"; + return @"$n2.$n3$n4"; } if (n0 == 0) { @@ -448,7 +447,9 @@ public override void draw (Context cr) { double scale = Toolbox.get_scale (); double text_height = 14 * scale; - Text text = new Text (get_short_display_value (), text_height); + string display_value = get_short_display_value (); + Text text = new Text (display_value, text_height); + double text_x = x + (w - text.get_sidebearing_extent ()) / 2; double text_y = y + (h - text_height) / 2;