diff options
author | Lluis Sanchez <lluis@xamarin.com> | 2013-11-13 00:04:43 +0400 |
---|---|---|
committer | Lluis Sanchez <lluis@xamarin.com> | 2013-11-13 00:06:19 +0400 |
commit | ef54d065c721ce013d2dc96284629441aba1672b (patch) | |
tree | 952aeabcd4a034a587924807dfdae84be730e87a /Xwt.Gtk | |
parent | 31d15e6c9feb0f1c46a8531e0e4ffebb95f432b8 (diff) |
[GTK] Another fix for label alignment
Diffstat (limited to 'Xwt.Gtk')
-rw-r--r-- | Xwt.Gtk/Xwt.GtkBackend/LabelBackend.cs | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/Xwt.Gtk/Xwt.GtkBackend/LabelBackend.cs b/Xwt.Gtk/Xwt.GtkBackend/LabelBackend.cs index c9e7ea74..e7a7f691 100644 --- a/Xwt.Gtk/Xwt.GtkBackend/LabelBackend.cs +++ b/Xwt.Gtk/Xwt.GtkBackend/LabelBackend.cs @@ -175,15 +175,20 @@ namespace Xwt.GtkBackend Label.Layout.GetPixelSize (out unused, out wrapHeight); if (wrapWidth != args.Allocation.Width || oldHeight != wrapHeight) { wrapWidth = args.Allocation.Width; - // GTK renders the text using the calculated pixel width, not the allocated width. - // If the calculated width is smaller and text is not left aligned, then a gap is - // shown at the right of the label. We then have the adjust the allocation. - if (Label.Justify == Gtk.Justification.Right) - Label.Xpad = wrapWidth - unused; - else if (Label.Justify == Gtk.Justification.Center) - Label.Xpad = (wrapWidth - unused) / 2; Label.QueueResize (); } + // GTK renders the text using the calculated pixel width, not the allocated width. + // If the calculated width is smaller and text is not left aligned, then a gap is + // shown at the right of the label. We then have the adjust the allocation. + if (Label.Justify == Gtk.Justification.Right) { + var w = wrapWidth - unused; + if (w != Label.Xpad) + Label.Xpad = w; + } else if (Label.Justify == Gtk.Justification.Center) { + var w = (wrapWidth - unused) / 2; + if (w != Label.Xpad) + Label.Xpad = w; + } } void HandleLabelDynamicSizeRequest (object o, Gtk.SizeRequestedArgs args) |