-
Notifications
You must be signed in to change notification settings - Fork 187
Open
Description
Environment:
RHEL-10
GTK: 4.16
It seems like if there is a Group widget on shell it calculates wrong size/missing some widget in children list.
Please use the below example. Run this on GTK3 and GTK4 and observe the difference..
On GTK3 everything works fine a group with a label inside is rendered by default. But when enable GTK4 only group is shown with label inside and by default Button is hidden.
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.internal.gtk.GTK;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
public class SWTLabelShowcase {
public static void main(String[] args) {
System.out.println("Is GTK4 ? " + GTK.GTK4);
System.out.println("GTK major: " + GTK.gtk_get_major_version());
System.out.println("GTK minor: " + GTK.gtk_get_minor_version());
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("SWT Label API Showcase");
shell.setLayout(new GridLayout(1, true));
// ==== Simple Label ====
//If you remove this group definition and add labels onto shell directly it works fine.
Group gSimple = group(shell, "Simple Labels");
gSimple.setLayout(new GridLayout(1, false));
Label label1 = new Label(gSimple, SWT.NONE);
label1.setText("Simple label (default)");
// ==== Toggle visibility ====
Button btnToggle = new Button(shell, SWT.PUSH);
btnToggle.setText("Toggle image label visibility");
GridData gdToggle = new GridData(SWT.FILL, SWT.CENTER, true, false);
btnToggle.setLayoutData(gdToggle);
// If you uncomment below code. Above button will be visible and this button will be
// hidden by default
// Button dummy = new Button(shell, SWT.PUSH);
// dummy.setText("Dumy");
// dummy.setLayoutData(gdToggle);
// ==== Open shell ====
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
private static Group group(Composite parent, String title) {
Group g = new Group(parent, SWT.SHADOW_ETCHED_IN);
g.setText(title);
g.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
return g;
}
}
Metadata
Metadata
Assignees
Labels
No labels