Issue #588 Fixed bug with participant resizing window
Change-Id: I9a4fca76fdc0f81a8f55135402efcf187c684915 Former-commit-id:7d02ae3404
[formerly7d02ae3404
[formerly c31c62f94799322fc5811c8f38afdb01c9c49c2c]] Former-commit-id:a709f9a491
Former-commit-id:900b55f292
This commit is contained in:
parent
4ffa120f8d
commit
e24c82a6b7
1 changed files with 30 additions and 10 deletions
|
@ -62,10 +62,16 @@ public class CollaborationEditor extends AbstractEditor {
|
||||||
|
|
||||||
private String sessionId;
|
private String sessionId;
|
||||||
|
|
||||||
|
private Composite wrapperComp;
|
||||||
|
|
||||||
private Composite canvasComp;
|
private Composite canvasComp;
|
||||||
|
|
||||||
private ScrolledComposite scrollable;
|
private ScrolledComposite scrollable;
|
||||||
|
|
||||||
|
private Rectangle scrollableBounds;
|
||||||
|
|
||||||
|
private Rectangle canvasBounds;
|
||||||
|
|
||||||
private CollaborationInputHandler inputHandler = new CollaborationInputHandler();
|
private CollaborationInputHandler inputHandler = new CollaborationInputHandler();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -78,29 +84,36 @@ public class CollaborationEditor extends AbstractEditor {
|
||||||
| SWT.V_SCROLL);
|
| SWT.V_SCROLL);
|
||||||
scrollable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
|
scrollable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
|
||||||
true));
|
true));
|
||||||
// Sets background color of scrollable composite to white
|
|
||||||
scrollable.setBackground(scrollable.getDisplay()
|
|
||||||
.getSystemColor(SWT.COLOR_WHITE));
|
|
||||||
|
|
||||||
// Composite for canvas (fixed size)
|
// Composite for canvas comp
|
||||||
canvasComp = new Composite(scrollable, SWT.NONE);
|
wrapperComp = new Composite(scrollable, SWT.NONE);
|
||||||
GridLayout gl = new GridLayout(1, false);
|
GridLayout gl = new GridLayout(1, false);
|
||||||
gl.marginHeight = 0;
|
gl.marginHeight = 0;
|
||||||
gl.marginWidth = 0;
|
gl.marginWidth = 0;
|
||||||
|
// Sets background color of wrapper composite to white
|
||||||
|
wrapperComp.setBackground(wrapperComp.getDisplay()
|
||||||
|
.getSystemColor(SWT.COLOR_WHITE));
|
||||||
|
wrapperComp.setSize(1000, 1000);
|
||||||
|
|
||||||
|
canvasComp = new Composite(wrapperComp, SWT.NONE);
|
||||||
canvasComp.setLayout(gl);
|
canvasComp.setLayout(gl);
|
||||||
canvasComp.setSize(1000, 1000);
|
canvasComp.setSize(1000, 1000);
|
||||||
|
|
||||||
// Set canvasComp as content on scrollable
|
// Set canvasComp as content on scrollable
|
||||||
scrollable.setContent(canvasComp);
|
scrollable.setContent(wrapperComp);
|
||||||
scrollable.addListener(SWT.Resize, new Listener() {
|
scrollable.addListener(SWT.Resize, new Listener() {
|
||||||
@Override
|
@Override
|
||||||
public void handleEvent(Event event) {
|
public void handleEvent(Event event) {
|
||||||
setCanvasSize(canvasComp.getBounds());
|
scrollableBounds = ((Composite) event.widget)
|
||||||
|
.getBounds();
|
||||||
|
setCanvasSize(canvasBounds);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
IDisplayPane pane = addPane(renderableDisplay, canvasComp);
|
IDisplayPane pane = addPane(renderableDisplay, canvasComp);
|
||||||
canvasComp.layout();
|
canvasComp.layout();
|
||||||
|
scrollableBounds = scrollable.getBounds();
|
||||||
|
canvasBounds = canvasComp.getBounds();
|
||||||
return pane;
|
return pane;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -130,12 +143,16 @@ public class CollaborationEditor extends AbstractEditor {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCanvasSize(Rectangle bounds) {
|
public void setCanvasSize(Rectangle bounds) {
|
||||||
|
canvasBounds = bounds;
|
||||||
canvasComp.setSize(bounds.width, bounds.height);
|
canvasComp.setSize(bounds.width, bounds.height);
|
||||||
|
|
||||||
// This code centers the GLCanvas in the scrollable composite
|
Rectangle scrollableBounds = new Rectangle(this.scrollableBounds.x,
|
||||||
|
this.scrollableBounds.y, this.scrollableBounds.width,
|
||||||
|
this.scrollableBounds.height);
|
||||||
|
|
||||||
|
// Subtract size of scroll bars if visible
|
||||||
ScrollBar vertical = scrollable.getVerticalBar();
|
ScrollBar vertical = scrollable.getVerticalBar();
|
||||||
ScrollBar horizon = scrollable.getHorizontalBar();
|
ScrollBar horizon = scrollable.getHorizontalBar();
|
||||||
Rectangle scrollableBounds = scrollable.getBounds();
|
|
||||||
if (vertical.isVisible()) {
|
if (vertical.isVisible()) {
|
||||||
scrollableBounds.width -= vertical.getSize().x;
|
scrollableBounds.width -= vertical.getSize().x;
|
||||||
}
|
}
|
||||||
|
@ -143,10 +160,13 @@ public class CollaborationEditor extends AbstractEditor {
|
||||||
scrollableBounds.height -= horizon.getSize().y;
|
scrollableBounds.height -= horizon.getSize().y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wrapperComp.setSize(
|
||||||
|
Math.max(canvasBounds.width, scrollableBounds.width),
|
||||||
|
Math.max(canvasBounds.height, scrollableBounds.height));
|
||||||
canvasComp.setLocation(
|
canvasComp.setLocation(
|
||||||
Math.max(0, (scrollableBounds.width - bounds.width) / 2),
|
Math.max(0, (scrollableBounds.width - bounds.width) / 2),
|
||||||
Math.max(0, (scrollableBounds.height - bounds.height) / 2));
|
Math.max(0, (scrollableBounds.height - bounds.height) / 2));
|
||||||
|
wrapperComp.layout();
|
||||||
canvasComp.layout();
|
canvasComp.layout();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue