Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimeon Andreev2018-05-02 05:31:49 +0000
committerSimeon Andreev2018-05-02 14:46:26 +0000
commit6f7c898268e4449ff992db1dc518e7df9420ae6e (patch)
tree701c9acc7e3d3dc55759f9da4f1aea9cda26c015
parent0ad2d427485d841e1f02fc8736b2e98fee0a27d2 (diff)
downloadeclipse.platform.swt-6f7c898268e4449ff992db1dc518e7df9420ae6e.tar.gz
eclipse.platform.swt-6f7c898268e4449ff992db1dc518e7df9420ae6e.tar.xz
eclipse.platform.swt-6f7c898268e4449ff992db1dc518e7df9420ae6e.zip
Bug 534204 - [GTK3] cramped vertical scale has no trough
The orignal fix for bug 534204 (change 121927) addressed only horizontal scales. I.e. despite the fix, if a vertical scale has little rendering space due to resizing or small width hint, it will not draw its trough. This change aims to fix also vertical scales. Change-Id: Ifc6a01ba185b854b832cf9d8c5014d0b035615db Signed-off-by: Simeon Andreev <simeon.danailov.andreev@gmail.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scale.java7
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug534204_Scale_has_no_trough.java (renamed from tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug534204_Scale_has_no_line.java)35
2 files changed, 27 insertions, 15 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scale.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scale.java
index f9bed26d71..22e8bc3e84 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scale.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scale.java
@@ -396,7 +396,12 @@ Point resizeCalculationsGTK3(long /*int*/ widget, int width, int height) {
GtkRequisition naturalSize = new GtkRequisition();
GtkRequisition minimumSize = new GtkRequisition();
GTK.gtk_widget_get_preferred_size(handle, minimumSize, naturalSize);
- size.y = Math.max(size.y, minimumSize.height);
+ if ((style & SWT.VERTICAL) != 0) {
+ size.x = Math.max(size.x, minimumSize.width);
+ }
+ if ((style & SWT.HORIZONTAL) != 0) {
+ size.y = Math.max(size.y, minimumSize.height);
+ }
}
return size;
}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug534204_Scale_has_no_line.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug534204_Scale_has_no_trough.java
index 913a182d96..413fea4e1e 100644
--- a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug534204_Scale_has_no_line.java
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug534204_Scale_has_no_trough.java
@@ -17,7 +17,6 @@ package org.eclipse.swt.tests.gtk.snippets;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Scale;
@@ -30,28 +29,36 @@ import org.eclipse.swt.widgets.Shell;
* Steps to reproduce:
* <ol>
* <li>Run the snippet.</li>
+ * <li>Reduce the height of the snippet to its minimum by resizing. </li>
+ * <li>Observe that the horizontal scales have no trough. </li>
+ * <li>Resize the snippet back to its original state. </li>
+ * <li>Reduce the width of the snippet to its minimum by resizing.</li>
+ * <li>Observe that the vertical scales have no trough. </li>
* </ol>
- * Expected results: The shell contains a scale with a line and a trough.
- * Actual results: The shell contains a scale with a tough but without a line.
+ * Expected results: The shell contains scales, each with a slider and a trough.
+ * Actual results: After shrinking, the shell contains scales with no trough.
*/
-public class Bug534204_Scale_has_no_line {
+public class Bug534204_Scale_has_no_trough {
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
- shell.setSize(300, 100);
- shell.setText("Bug 534204 scale has only trough and no line");
+ shell.setSize(300, 300);
+ shell.setText("Bug 534204 scale has no trough");
shell.setLayout(new FillLayout(SWT.VERTICAL));
- Composite main = new Composite(shell, SWT.NONE);
- GridLayout gridLayout = new GridLayout(1, false);
- main.setLayout(gridLayout);
+ Composite composite = new Composite(shell, SWT.NONE);
+ composite.setLayout(new FillLayout());
- Scale scale = new Scale(main, SWT.NONE);
- GridData gd = new GridData();
- gd.widthHint = 200;
- gd.heightHint = 18;
- scale.setLayoutData(gd);
+ Composite horizontal = new Composite(composite, SWT.NONE);
+ horizontal.setLayout(new FillLayout(SWT.VERTICAL));
+ new Scale(horizontal, SWT.HORIZONTAL);
+ new Scale(horizontal, SWT.HORIZONTAL).setSelection(100);
+
+ Composite vertical = new Composite(composite, SWT.NONE);
+ vertical.setLayout(new FillLayout());
+ new Scale(vertical, SWT.VERTICAL);
+ new Scale(vertical, SWT.VERTICAL).setSelection(100);
shell.open();
while (!shell.isDisposed()) {

Back to the top