From 92171d8cd4e3d27c656d771d8b3f03598388a5a2 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Tue, 19 Jun 2018 11:11:15 +0200 Subject: [PATCH] grid - some centered layout cleanup --- .../ui/centered/centeredViewLayout.css | 2 +- .../browser/parts/editor/baseEditor.ts | 7 ------ .../browser/parts/editor/binaryEditor.ts | 4 ---- .../browser/parts/editor/editorPart.ts | 23 +++++++++++-------- .../parts/editor/media/titlecontrol.css | 5 ---- .../browser/parts/editor/sideBySideEditor.ts | 4 ---- .../browser/parts/editor/textDiffEditor.ts | 4 ---- .../preferences/browser/preferencesEditor.ts | 8 ------- 8 files changed, 14 insertions(+), 43 deletions(-) diff --git a/src/vs/base/browser/ui/centered/centeredViewLayout.css b/src/vs/base/browser/ui/centered/centeredViewLayout.css index 854530732a0..f7ee1e90832 100644 --- a/src/vs/base/browser/ui/centered/centeredViewLayout.css +++ b/src/vs/base/browser/ui/centered/centeredViewLayout.css @@ -3,6 +3,6 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -.monaco-workbench > .part.editor > .content .centered-view-layout { +.centered-view-layout { height: 100%; } diff --git a/src/vs/workbench/browser/parts/editor/baseEditor.ts b/src/vs/workbench/browser/parts/editor/baseEditor.ts index 8e8d1e5d97e..040f588de89 100644 --- a/src/vs/workbench/browser/parts/editor/baseEditor.ts +++ b/src/vs/workbench/browser/parts/editor/baseEditor.ts @@ -143,13 +143,6 @@ export abstract class BaseEditor extends Panel implements IEditor { this._group = group; } - /** - * Subclasses can set this to false if it does not make sense to center editor input. - */ - supportsCenteredLayout(): boolean { - return true; - } - protected getEditorMemento(storageService: IStorageService, editorGroupService: IEditorGroupsService, key: string, limit: number = 10): IEditorMemento { const mementoKey = `${this.getId()}${key}`; diff --git a/src/vs/workbench/browser/parts/editor/binaryEditor.ts b/src/vs/workbench/browser/parts/editor/binaryEditor.ts index 47de56f9791..7a66f852922 100644 --- a/src/vs/workbench/browser/parts/editor/binaryEditor.ts +++ b/src/vs/workbench/browser/parts/editor/binaryEditor.ts @@ -116,10 +116,6 @@ export abstract class BaseBinaryResourceEditor extends BaseEditor { return this.metadata; } - public supportsCenteredLayout(): boolean { - return false; - } - public clearInput(): void { // Clear Meta diff --git a/src/vs/workbench/browser/parts/editor/editorPart.ts b/src/vs/workbench/browser/parts/editor/editorPart.ts index 53be6129449..aed922af57f 100644 --- a/src/vs/workbench/browser/parts/editor/editorPart.ts +++ b/src/vs/workbench/browser/parts/editor/editorPart.ts @@ -89,13 +89,13 @@ export class EditorPart extends Part implements EditorGroupsServiceImpl, IEditor private mostRecentActiveGroups: GroupIdentifier[] = []; private container: HTMLElement; + private centeredLayoutWidget: CenteredViewLayout; private gridWidget: SerializableGrid; private _whenRestored: TPromise; private whenRestoredComplete: TValueCallback; private previousUIState: IEditorPartUIState; - private centeredViewLayout: CenteredViewLayout; constructor( id: string, @@ -708,7 +708,7 @@ export class EditorPart extends Part implements EditorGroupsServiceImpl, IEditor const separatorBorderStyle = { separatorBorder: this.gridSeparatorBorder }; this.gridWidget.style(separatorBorderStyle); - this.centeredViewLayout.styles(separatorBorderStyle); + this.centeredLayoutWidget.styles(separatorBorderStyle); } createContentArea(parent: HTMLElement): HTMLElement { @@ -720,7 +720,7 @@ export class EditorPart extends Part implements EditorGroupsServiceImpl, IEditor // Grid control with center layout this.doCreateGridControl(); - this.centeredViewLayout = new CenteredViewLayout(this.container, this.getGridAsView(), this.globalMemento[EditorPart.EDITOR_PART_CENTERED_VIEW_STORAGE_KEY]); + this.centeredLayoutWidget = this._register(new CenteredViewLayout(this.container, this.getGridAsView(), this.globalMemento[EditorPart.EDITOR_PART_CENTERED_VIEW_STORAGE_KEY])); // Drop support this._register(this.instantiationService.createInstance(EditorDropTarget, this, this.container)); @@ -741,11 +741,11 @@ export class EditorPart extends Part implements EditorGroupsServiceImpl, IEditor } centerLayout(active: boolean): void { - this.centeredViewLayout.activate(active); + this.centeredLayoutWidget.activate(active); } isLayoutCentered(): boolean { - return this.centeredViewLayout.isActive(); + return this.centeredLayoutWidget.isActive(); } private doCreateGridControl(): void { @@ -801,6 +801,7 @@ export class EditorPart extends Part implements EditorGroupsServiceImpl, IEditor } private doCreateGridControlWithState(serializedGrid: ISerializedGrid, activeGroupId: GroupIdentifier, editorGroupViewsToReuse?: IEditorGroupView[]): void { + // Determine group views to reuse if any let reuseGroupViews: IEditorGroupView[]; if (editorGroupViewsToReuse) { @@ -839,9 +840,10 @@ export class EditorPart extends Part implements EditorGroupsServiceImpl, IEditor this.gridWidget = gridWidget; if (gridWidget) { - if (this.centeredViewLayout) { - this.centeredViewLayout.resetView(this.getGridAsView()); + if (this.centeredLayoutWidget) { + this.centeredLayoutWidget.resetView(this.getGridAsView()); } + this._onDidSizeConstraintsChange.input = gridWidget.onDidChange; } @@ -999,7 +1001,7 @@ export class EditorPart extends Part implements EditorGroupsServiceImpl, IEditor // Layout Grid try { - this.centeredViewLayout.layout(this.dimension.width, this.dimension.height); + this.centeredLayoutWidget.layout(this.dimension.width, this.dimension.height); } catch (error) { this.gridError(error); } @@ -1024,7 +1026,9 @@ export class EditorPart extends Part implements EditorGroupsServiceImpl, IEditor this.memento[EditorPart.EDITOR_PART_UI_STATE_STORAGE_KEY] = uiState; } } - this.globalMemento[EditorPart.EDITOR_PART_CENTERED_VIEW_STORAGE_KEY] = this.centeredViewLayout.state; + + // Persist centered view state + this.globalMemento[EditorPart.EDITOR_PART_CENTERED_VIEW_STORAGE_KEY] = this.centeredLayoutWidget.state; // Forward to all groups this.groupViews.forEach(group => group.shutdown()); @@ -1042,7 +1046,6 @@ export class EditorPart extends Part implements EditorGroupsServiceImpl, IEditor if (this.gridWidget) { this.gridWidget.dispose(); } - this.centeredViewLayout.dispose(); super.dispose(); } diff --git a/src/vs/workbench/browser/parts/editor/media/titlecontrol.css b/src/vs/workbench/browser/parts/editor/media/titlecontrol.css index 79479a2046f..da2df0dfeca 100644 --- a/src/vs/workbench/browser/parts/editor/media/titlecontrol.css +++ b/src/vs/workbench/browser/parts/editor/media/titlecontrol.css @@ -11,11 +11,6 @@ flex: 1; } -.monaco-workbench > .part.editor > .content .editor-group-container.centered > .title .title-label { - flex-direction: row; - justify-content: center; -} - .monaco-workbench > .part.editor > .content .editor-group-container > .title .title-label a, .monaco-workbench > .part.editor > .content .editor-group-container > .title .tabs-container > .tab .tab-label a { text-decoration: none; diff --git a/src/vs/workbench/browser/parts/editor/sideBySideEditor.ts b/src/vs/workbench/browser/parts/editor/sideBySideEditor.ts index 21922b1f46f..48230a73d7b 100644 --- a/src/vs/workbench/browser/parts/editor/sideBySideEditor.ts +++ b/src/vs/workbench/browser/parts/editor/sideBySideEditor.ts @@ -151,10 +151,6 @@ export class SideBySideEditor extends BaseEditor { return this.detailsEditor; } - supportsCenteredLayout(): boolean { - return false; - } - private updateInput(oldInput: SideBySideEditorInput, newInput: SideBySideEditorInput, options: EditorOptions, token: CancellationToken): Thenable { if (!newInput.matches(oldInput)) { if (oldInput) { diff --git a/src/vs/workbench/browser/parts/editor/textDiffEditor.ts b/src/vs/workbench/browser/parts/editor/textDiffEditor.ts index 22c0a7008c3..74753bc36cf 100644 --- a/src/vs/workbench/browser/parts/editor/textDiffEditor.ts +++ b/src/vs/workbench/browser/parts/editor/textDiffEditor.ts @@ -163,10 +163,6 @@ export class TextDiffEditor extends BaseTextEditor implements ITextDiffEditor { } } - public supportsCenteredLayout(): boolean { - return false; - } - private restoreTextDiffEditorViewState(input: EditorInput): boolean { if (input instanceof DiffEditorInput) { const resource = this.toDiffEditorViewStateResource(input); diff --git a/src/vs/workbench/parts/preferences/browser/preferencesEditor.ts b/src/vs/workbench/parts/preferences/browser/preferencesEditor.ts index aa23dcd4ca1..0eb68416f94 100644 --- a/src/vs/workbench/parts/preferences/browser/preferencesEditor.ts +++ b/src/vs/workbench/parts/preferences/browser/preferencesEditor.ts @@ -205,10 +205,6 @@ export class PreferencesEditor extends BaseEditor { super.clearInput(); } - public supportsCenteredLayout(): boolean { - return false; - } - protected setEditorVisible(visible: boolean, group: IEditorGroup): void { this.sideBySidePreferencesWidget.setEditorVisible(visible, group); super.setEditorVisible(visible, group); @@ -1053,10 +1049,6 @@ export class DefaultPreferencesEditor extends BaseTextEditor { this.getControl().layout(dimension); } - public supportsCenteredLayout(): boolean { - return false; - } - protected getAriaLabel(): string { return nls.localize('preferencesAriaLabel', "Default preferences. Readonly text editor."); }