Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/xwt.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVsevolod Kukol <sevoku@microsoft.com>2016-09-22 13:17:38 +0300
committerVsevolod Kukol <sevoku@microsoft.com>2016-09-22 15:29:17 +0300
commitf6ec5af75daa476dda709c8f7329f4f660cae96a (patch)
tree29618ca10728ebb2780d310022226b0cbd4b4003 /Xwt.Gtk/Xwt.GtkBackend/ButtonBackend.cs
parent3a405624a9aecf5c2871b90547f539abcf9eeb80 (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-xXwt.Gtk/Xwt.GtkBackend/ButtonBackend.cs11
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) {