diff options
author | Vsevolod Kukol <sevoku@microsoft.com> | 2016-09-22 13:17:38 +0300 |
---|---|---|
committer | Vsevolod Kukol <sevoku@microsoft.com> | 2016-09-22 15:29:17 +0300 |
commit | f6ec5af75daa476dda709c8f7329f4f660cae96a (patch) | |
tree | 29618ca10728ebb2780d310022226b0cbd4b4003 /Xwt.Gtk/Xwt.GtkBackend/ButtonBackend.cs | |
parent | 3a405624a9aecf5c2871b90547f539abcf9eeb80 (diff) |
[Gtk] Optimize horizontal Button alignment
Move the button content slightly to the left,
if a Button is wider than its natural size, has text
and an image on the left side.
Diffstat (limited to 'Xwt.Gtk/Xwt.GtkBackend/ButtonBackend.cs')
-rwxr-xr-x | Xwt.Gtk/Xwt.GtkBackend/ButtonBackend.cs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/Xwt.Gtk/Xwt.GtkBackend/ButtonBackend.cs b/Xwt.Gtk/Xwt.GtkBackend/ButtonBackend.cs index 2d79e341..488e2c51 100755 --- a/Xwt.Gtk/Xwt.GtkBackend/ButtonBackend.cs +++ b/Xwt.Gtk/Xwt.GtkBackend/ButtonBackend.cs @@ -139,9 +139,9 @@ namespace Xwt.GtkBackend contentWidget.ShowAll (); Widget.Label = null; Widget.Image = contentWidget; - if (expandButtonContent) { - var alignment = Widget.Child as Gtk.Alignment; - if (alignment != null) { + var alignment = Widget.Child as Gtk.Alignment; + if (alignment != null) { + if (expandButtonContent) { var box = alignment.Child as Gtk.Box; if (box != null) { alignment.Xscale = 1; @@ -149,6 +149,11 @@ namespace Xwt.GtkBackend if (labelWidget != null) labelWidget.Xalign = 0; } + } else if (position == ContentPosition.Left && (contentWidget is Gtk.Box)) { + // in case the button is wider than its natural size and has text and an image on the left, + // optimize its alignment to make the text more centered. + // FIXME: more sophisticated size calculation + alignment.Xalign = 0.475f; } } if (labelWidget != null) { |