[Eclipse Forms] Incorrect size computation with ColumnLayout in ScrolledForm [message #1792867] |
Wed, 25 July 2018 09:06 |
Eclipse User |
|
|
|
Hello,
I use a ColumnLayout with flexible number of columns (between 1 and 3) in a ScrolledForm. It works fine, except for the vertical scrollbar of the ScrolledForm. It looks like no matter how many columns are used currently, the scrollbar is sized like there is a single column only.
Have a look at the attached screenshots, it will clarify the issue.


Here is a MWE that I used to obtain the screenshots.
package debugeditor;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.ui.forms.widgets.*;
public class Debug {
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
FormToolkit toolkit = new FormToolkit(display);
ScrolledForm form = toolkit.createScrolledForm(shell);
ColumnLayout layout = new ColumnLayout();
layout.minNumColumns = 1;
layout.maxNumColumns = 3;
form.getBody().setLayout(layout);
for (int i = 0; i < 15; i++) {
createDummySection(toolkit, form.getBody(), i);
}
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
toolkit.dispose();
display.dispose();
}
private static void createDummySection(FormToolkit toolkit, Composite parent, int n) {
Section section = toolkit.createSection(parent,
Section.DESCRIPTION | Section.TITLE_BAR | Section.EXPANDED | Section.TWISTIE);
Composite sectionBody = toolkit.createComposite(section);
sectionBody.setLayout(new GridLayout(1, true));
section.setClient(sectionBody);
section.setLayoutData(new ColumnLayoutData());
for (int i = 0; i < 3; i++) {
toolkit.createLabel(sectionBody, "LOREM IPSUM DOLOR SIT AMET -- Label " + n + " / " + i);
}
}
}
It seems to me that the ColumnLayout.computeSize() is always called with a relatively small wHint, thus it assumes that a single column layout will be used and it returns the size accordingly. However, when the ColumnLayout.layout() is called and the actual layout is performed, the layout() method will take the real size of its parent client area into account, thus it is possible to use a multi-column layout if the parent composite is wide enough.
Am I missing something in my code or is this a bug?
Thanks,
Daniel
|
|
|
Powered by
FUDForum. Page generated in 0.02371 seconds