Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Williams2018-06-21 18:56:39 +0000
committerEric Williams2018-06-22 14:31:41 +0000
commitd66c8ad361070566ae297cc068d3073821e16ffd (patch)
tree5da1fb41203e7e582273f4a1b0db78f337204c44 /bundles
parent5dd0799eda89f9eb8bd4403b9bbabffa515566c9 (diff)
downloadeclipse.platform.swt-d66c8ad361070566ae297cc068d3073821e16ffd.tar.gz
eclipse.platform.swt-d66c8ad361070566ae297cc068d3073821e16ffd.tar.xz
eclipse.platform.swt-d66c8ad361070566ae297cc068d3073821e16ffd.zip
Bug 534768: [GTK3] GridLayout GridData width hint doesnt work correctly
Use the minimum width for SWT.WRAP Labels on GTK3, as larger labels will have a very big natural width. This negates the wrapping effect all together and makes the parent widget quite large (i.e., Snippet335). Tested on GTK3.22 using Snippet335 and a child Eclipse. No AllNonBrowser JUnit tests fail. Change-Id: Ibdd39756d6e8790ab7e8bcd0bfcefe914a6ec039 Signed-off-by: Eric Williams <ericwill@redhat.com>
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java21
1 files changed, 21 insertions, 0 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java
index ea08a3c726..c52a1ccf92 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java
@@ -114,6 +114,27 @@ void addRelation (Control control) {
}
@Override
+Point computeNativeSize (long /*int*/ h, int wHint, int hHint, boolean changed) {
+ int width = wHint, height = hHint;
+ /*
+ * Feature in GTK3: Labels with long text have an extremely large natural width.
+ * As a result, such Labels created with SWT.WRAP end up being too big. The fix
+ * is to use the minimum width instead of the natural width when SWT.WRAP is specified.
+ * In all other cases, use the natural width. See bug 534768.
+ */
+ boolean wrapGTK3 = GTK.GTK3 && labelHandle != 0 && (style & SWT.WRAP) != 0 && GTK.gtk_widget_get_visible (labelHandle);
+ if (wrapGTK3 && wHint == SWT.DEFAULT && hHint == SWT.DEFAULT) {
+ GtkRequisition naturalSize = new GtkRequisition ();
+ GtkRequisition minimumSize = new GtkRequisition ();
+ GTK.gtk_widget_get_preferred_size(h, minimumSize, naturalSize);
+ width = minimumSize.width;
+ height = naturalSize.height;
+ return new Point(width, height);
+ } else {
+ return super.computeNativeSize(h, wHint, hHint, changed);
+ }
+}
+@Override
Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
checkWidget ();
if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;

Back to the top