skylights1
skylights1

Reputation: 11

SWT application with a GLCanvas not resizing properly

I'm making an application that is some sort of drawing program, and to that end I am attempting to use SWT with a GLCanvas widget in the shell. This is a snippet of it that shows the problem I'm having:

    shell = new Shell();

    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 2;

    shell.setLayout(gridLayout);
    shell.setSize(1000, 800);
    shell.setText(APPLICATION_NAME);

    Label label = new Label(shell, SWT.NONE);
    label.setText("Test");

    Composite composite = new Composite(shell, SWT.NONE);
    GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
    composite.setLayoutData(gridData);
    composite.setLayout(new FillLayout(SWT.HORIZONTAL));

    GLData data = new GLData();
    data.doubleBuffer = true;

    canvas = new GLCanvas(composite, SWT.NO_BACKGROUND, data);

When I resize the window from this code, it does not display properly. The GLCanvas flickers, but it's also as if there's a step in the drawing where it draws the GLCanvas to the screen before it's been resized to properly fill the remaining white space. This has the effect where, for example, while the window is being resized to the left, the GLCanvas is smaller than it should be. Inversely, while the window is being resized to the right, the GLCanvas is larger than it should be and extends off into the right of the window.

I've tried setting the style of the canvas from SWT.NONE to SWT.NO_BACKGROUND to SWT.DOUBLE_BUFFERED to SWT.NO_REDRAW_RESIZE and it had no effect on this problem.

How can fix this behavior?

Upvotes: 1

Views: 130

Answers (0)

Related Questions