diff options
author | Xi Yan | 2018-08-23 20:57:14 +0000 |
---|---|---|
committer | Xi Yan | 2018-08-27 14:50:43 +0000 |
commit | 57b0cb0c60b17c3703eea394daaa65dcb8acbecb (patch) | |
tree | 2234168d9b4bae11f9441871b974fe3410d54ad1 | |
parent | 3fa1b8d45f354bb7696d050522bcb960c64500e7 (diff) | |
download | eclipse.platform.swt-57b0cb0c60b17c3703eea394daaa65dcb8acbecb.tar.gz eclipse.platform.swt-57b0cb0c60b17c3703eea394daaa65dcb8acbecb.tar.xz eclipse.platform.swt-57b0cb0c60b17c3703eea394daaa65dcb8acbecb.zip |
Bug 538114 - [GTK3] Tree in ExpandBar has no content until resized or
collapsed/expanded
Internal widgets inside ExpandBar's control don't get sized properly
when first created. The fix is to always show the control before setting
any bounds.
Change-Id: Id247d69efad52801813453e0ce9715c8a2ce2d7e
Signed-off-by: Xi Yan <xixiyan@redhat.com>
2 files changed, 91 insertions, 0 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandItem.java index e522afcbcd..cbd7aa3b1d 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandItem.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandItem.java @@ -468,6 +468,13 @@ void resizeControl (int yScroll) { } // Bug 479242: Bound calculation is correct without needing to use yScroll in GTK3 if (GTK.GTK3) { + /* + * Bug 538114: ExpandBar has no content until resized or collapsed/expanded. + * When widget is first created inside ExpandItem's control, the size is allocated + * to be zero, and the widget is never shown during a layout operation, similar to + * Bug 487757. The fix is to show the control before setting any bounds. + */ + if (visible) GTK.gtk_widget_show(control.topHandle ()); control.setBounds (x, y, width, Math.max (0, height), true, true); } else { diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug538114_ExpandBarEmptyAll.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug538114_ExpandBarEmptyAll.java new file mode 100644 index 0000000000..12bf38709f --- /dev/null +++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug538114_ExpandBarEmptyAll.java @@ -0,0 +1,84 @@ +/******************************************************************************* + * Copyright (c) 2018 Red Hat and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Simeon Andreev - initial API and implementation + *******************************************************************************/ +package org.eclipse.swt.tests.gtk.snippets; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.ExpandBar; +import org.eclipse.swt.widgets.ExpandItem; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.List; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableItem; +import org.eclipse.swt.widgets.Tree; +import org.eclipse.swt.widgets.TreeItem; + +public class Bug538114_ExpandBarEmptyAll { + public static void main(String[] args) { + final Display display = new Display(); + Shell shell = new Shell(display); + shell.setSize(400, 600); + shell.setLayout(new FillLayout()); + shell.setText("ExpandBar Bug"); + + expandBar(shell); + + shell.open(); + + while (!shell.isDisposed()) { + if (!display.readAndDispatch()) + display.sleep(); + } + display.dispose(); + } + + private static void expandBar(Shell shell) { + ExpandBar bar = new ExpandBar(shell, SWT.NONE); + + Composite expandControl = new Composite(bar, SWT.NONE); + expandControl.setLayout(new FillLayout(SWT.VERTICAL)); + + ExpandItem expandItem = new ExpandItem(bar, SWT.NONE, 0); + expandItem.setText("expand"); + expandItem.setControl(expandControl); + expandItem.setExpanded(false); + expandItem.setHeight(shell.getSize().y - 50); + + Label listLabel = new Label(expandControl, SWT.NONE); + listLabel.setText("List"); + List list = new List(expandControl, SWT.NONE); + for (int i = 0; i < 3; ++i) { + list.add("list item " + i); + } + + Label tableLabel = new Label(expandControl, SWT.NONE); + tableLabel.setText("Table"); + Table table = new Table(expandControl, SWT.NONE); + for (int i = 0; i < 3; ++i) { + TableItem item1 = new TableItem(table, SWT.NONE); + item1.setText("table item " + i); + } + + Label treeLabel = new Label(expandControl, SWT.NONE); + treeLabel.setText("Table"); + Tree tree = new Tree(expandControl, SWT.NONE); + for (int i = 0; i < 3; ++i) { + TreeItem item1 = new TreeItem(tree, SWT.NONE); + item1.setText("tree item " + i); + } + } +}
\ No newline at end of file |