Merge from master

This commit is contained in:
Raj Musuku
2019-02-21 17:56:04 -08:00
parent 5a146e34fa
commit 666ae11639
11482 changed files with 119352 additions and 255574 deletions

View File

@@ -50,15 +50,15 @@ export interface ICenteredViewStyles extends ISplitViewStyles {
export class CenteredViewLayout {
private splitView: SplitView;
private splitView?: SplitView;
private width: number = 0;
private height: number = 0;
private style: ICenteredViewStyles;
private didLayout = false;
private emptyViews: ISplitViewView[];
private emptyViews: ISplitViewView[] | undefined;
private splitViewDisposables: IDisposable[] = [];
constructor(private container: HTMLElement, private view: IView, public readonly state: CenteredViewState = GOLDEN_RATIO) {
constructor(private container: HTMLElement, private view: IView, public readonly state: CenteredViewState = { leftMarginRatio: GOLDEN_RATIO.leftMarginRatio, rightMarginRatio: GOLDEN_RATIO.rightMarginRatio }) {
this.container.appendChild(this.view.element);
// Make sure to hide the split view overflow like sashes #52892
this.container.style.overflow = 'hidden';
@@ -84,6 +84,9 @@ export class CenteredViewLayout {
}
private resizeMargins(): void {
if (!this.splitView) {
return;
}
this.splitView.resizeView(0, this.state.leftMarginRatio * this.width);
this.splitView.resizeView(2, this.state.rightMarginRatio * this.width);
}
@@ -94,7 +97,7 @@ export class CenteredViewLayout {
styles(style: ICenteredViewStyles): void {
this.style = style;
if (this.splitView) {
if (this.splitView && this.emptyViews) {
this.splitView.style(this.style);
this.emptyViews[0].element.style.backgroundColor = this.style.background.toString();
this.emptyViews[1].element.style.backgroundColor = this.style.background.toString();
@@ -115,8 +118,10 @@ export class CenteredViewLayout {
});
this.splitViewDisposables.push(this.splitView.onDidSashChange(() => {
this.state.leftMarginRatio = this.splitView.getViewSize(0) / this.width;
this.state.rightMarginRatio = this.splitView.getViewSize(2) / this.width;
if (this.splitView) {
this.state.leftMarginRatio = this.splitView.getViewSize(0) / this.width;
this.state.rightMarginRatio = this.splitView.getViewSize(2) / this.width;
}
}));
this.splitViewDisposables.push(this.splitView.onDidSashReset(() => {
this.state.leftMarginRatio = GOLDEN_RATIO.leftMarginRatio;
@@ -130,15 +135,23 @@ export class CenteredViewLayout {
this.splitView.addView(this.emptyViews[0], this.state.leftMarginRatio * this.width, 0);
this.splitView.addView(this.emptyViews[1], this.state.rightMarginRatio * this.width, 2);
} else {
this.container.removeChild(this.splitView.el);
if (this.splitView) {
this.container.removeChild(this.splitView.el);
}
this.splitViewDisposables = dispose(this.splitViewDisposables);
this.splitView.dispose();
if (this.splitView) {
this.splitView.dispose();
}
this.splitView = undefined;
this.emptyViews = undefined;
this.container.appendChild(this.view.element);
}
}
isDefault(state: CenteredViewState): boolean {
return state.leftMarginRatio === GOLDEN_RATIO.leftMarginRatio && state.rightMarginRatio === GOLDEN_RATIO.rightMarginRatio;
}
dispose(): void {
this.splitViewDisposables = dispose(this.splitViewDisposables);