Skip to content

Commit 92171d8

Browse files
author
Benjamin Pasero
committed
grid - some centered layout cleanup
1 parent 6a1ca40 commit 92171d8

8 files changed

Lines changed: 14 additions & 43 deletions

File tree

src/vs/base/browser/ui/centered/centeredViewLayout.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
.monaco-workbench > .part.editor > .content .centered-view-layout {
6+
.centered-view-layout {
77
height: 100%;
88
}

src/vs/workbench/browser/parts/editor/baseEditor.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,6 @@ export abstract class BaseEditor extends Panel implements IEditor {
143143
this._group = group;
144144
}
145145

146-
/**
147-
* Subclasses can set this to false if it does not make sense to center editor input.
148-
*/
149-
supportsCenteredLayout(): boolean {
150-
return true;
151-
}
152-
153146
protected getEditorMemento<T>(storageService: IStorageService, editorGroupService: IEditorGroupsService, key: string, limit: number = 10): IEditorMemento<T> {
154147
const mementoKey = `${this.getId()}${key}`;
155148

src/vs/workbench/browser/parts/editor/binaryEditor.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,6 @@ export abstract class BaseBinaryResourceEditor extends BaseEditor {
116116
return this.metadata;
117117
}
118118

119-
public supportsCenteredLayout(): boolean {
120-
return false;
121-
}
122-
123119
public clearInput(): void {
124120

125121
// Clear Meta

src/vs/workbench/browser/parts/editor/editorPart.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,13 @@ export class EditorPart extends Part implements EditorGroupsServiceImpl, IEditor
8989
private mostRecentActiveGroups: GroupIdentifier[] = [];
9090

9191
private container: HTMLElement;
92+
private centeredLayoutWidget: CenteredViewLayout;
9293
private gridWidget: SerializableGrid<IEditorGroupView>;
9394

9495
private _whenRestored: TPromise<void>;
9596
private whenRestoredComplete: TValueCallback<void>;
9697

9798
private previousUIState: IEditorPartUIState;
98-
private centeredViewLayout: CenteredViewLayout;
9999

100100
constructor(
101101
id: string,
@@ -708,7 +708,7 @@ export class EditorPart extends Part implements EditorGroupsServiceImpl, IEditor
708708

709709
const separatorBorderStyle = { separatorBorder: this.gridSeparatorBorder };
710710
this.gridWidget.style(separatorBorderStyle);
711-
this.centeredViewLayout.styles(separatorBorderStyle);
711+
this.centeredLayoutWidget.styles(separatorBorderStyle);
712712
}
713713

714714
createContentArea(parent: HTMLElement): HTMLElement {
@@ -720,7 +720,7 @@ export class EditorPart extends Part implements EditorGroupsServiceImpl, IEditor
720720

721721
// Grid control with center layout
722722
this.doCreateGridControl();
723-
this.centeredViewLayout = new CenteredViewLayout(this.container, this.getGridAsView(), this.globalMemento[EditorPart.EDITOR_PART_CENTERED_VIEW_STORAGE_KEY]);
723+
this.centeredLayoutWidget = this._register(new CenteredViewLayout(this.container, this.getGridAsView(), this.globalMemento[EditorPart.EDITOR_PART_CENTERED_VIEW_STORAGE_KEY]));
724724

725725
// Drop support
726726
this._register(this.instantiationService.createInstance(EditorDropTarget, this, this.container));
@@ -741,11 +741,11 @@ export class EditorPart extends Part implements EditorGroupsServiceImpl, IEditor
741741
}
742742

743743
centerLayout(active: boolean): void {
744-
this.centeredViewLayout.activate(active);
744+
this.centeredLayoutWidget.activate(active);
745745
}
746746

747747
isLayoutCentered(): boolean {
748-
return this.centeredViewLayout.isActive();
748+
return this.centeredLayoutWidget.isActive();
749749
}
750750

751751
private doCreateGridControl(): void {
@@ -801,6 +801,7 @@ export class EditorPart extends Part implements EditorGroupsServiceImpl, IEditor
801801
}
802802

803803
private doCreateGridControlWithState(serializedGrid: ISerializedGrid, activeGroupId: GroupIdentifier, editorGroupViewsToReuse?: IEditorGroupView[]): void {
804+
804805
// Determine group views to reuse if any
805806
let reuseGroupViews: IEditorGroupView[];
806807
if (editorGroupViewsToReuse) {
@@ -839,9 +840,10 @@ export class EditorPart extends Part implements EditorGroupsServiceImpl, IEditor
839840
this.gridWidget = gridWidget;
840841

841842
if (gridWidget) {
842-
if (this.centeredViewLayout) {
843-
this.centeredViewLayout.resetView(this.getGridAsView());
843+
if (this.centeredLayoutWidget) {
844+
this.centeredLayoutWidget.resetView(this.getGridAsView());
844845
}
846+
845847
this._onDidSizeConstraintsChange.input = gridWidget.onDidChange;
846848
}
847849

@@ -999,7 +1001,7 @@ export class EditorPart extends Part implements EditorGroupsServiceImpl, IEditor
9991001

10001002
// Layout Grid
10011003
try {
1002-
this.centeredViewLayout.layout(this.dimension.width, this.dimension.height);
1004+
this.centeredLayoutWidget.layout(this.dimension.width, this.dimension.height);
10031005
} catch (error) {
10041006
this.gridError(error);
10051007
}
@@ -1024,7 +1026,9 @@ export class EditorPart extends Part implements EditorGroupsServiceImpl, IEditor
10241026
this.memento[EditorPart.EDITOR_PART_UI_STATE_STORAGE_KEY] = uiState;
10251027
}
10261028
}
1027-
this.globalMemento[EditorPart.EDITOR_PART_CENTERED_VIEW_STORAGE_KEY] = this.centeredViewLayout.state;
1029+
1030+
// Persist centered view state
1031+
this.globalMemento[EditorPart.EDITOR_PART_CENTERED_VIEW_STORAGE_KEY] = this.centeredLayoutWidget.state;
10281032

10291033
// Forward to all groups
10301034
this.groupViews.forEach(group => group.shutdown());
@@ -1042,7 +1046,6 @@ export class EditorPart extends Part implements EditorGroupsServiceImpl, IEditor
10421046
if (this.gridWidget) {
10431047
this.gridWidget.dispose();
10441048
}
1045-
this.centeredViewLayout.dispose();
10461049

10471050
super.dispose();
10481051
}

src/vs/workbench/browser/parts/editor/media/titlecontrol.css

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@
1111
flex: 1;
1212
}
1313

14-
.monaco-workbench > .part.editor > .content .editor-group-container.centered > .title .title-label {
15-
flex-direction: row;
16-
justify-content: center;
17-
}
18-
1914
.monaco-workbench > .part.editor > .content .editor-group-container > .title .title-label a,
2015
.monaco-workbench > .part.editor > .content .editor-group-container > .title .tabs-container > .tab .tab-label a {
2116
text-decoration: none;

src/vs/workbench/browser/parts/editor/sideBySideEditor.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,6 @@ export class SideBySideEditor extends BaseEditor {
151151
return this.detailsEditor;
152152
}
153153

154-
supportsCenteredLayout(): boolean {
155-
return false;
156-
}
157-
158154
private updateInput(oldInput: SideBySideEditorInput, newInput: SideBySideEditorInput, options: EditorOptions, token: CancellationToken): Thenable<void> {
159155
if (!newInput.matches(oldInput)) {
160156
if (oldInput) {

src/vs/workbench/browser/parts/editor/textDiffEditor.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,6 @@ export class TextDiffEditor extends BaseTextEditor implements ITextDiffEditor {
163163
}
164164
}
165165

166-
public supportsCenteredLayout(): boolean {
167-
return false;
168-
}
169-
170166
private restoreTextDiffEditorViewState(input: EditorInput): boolean {
171167
if (input instanceof DiffEditorInput) {
172168
const resource = this.toDiffEditorViewStateResource(input);

src/vs/workbench/parts/preferences/browser/preferencesEditor.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,6 @@ export class PreferencesEditor extends BaseEditor {
205205
super.clearInput();
206206
}
207207

208-
public supportsCenteredLayout(): boolean {
209-
return false;
210-
}
211-
212208
protected setEditorVisible(visible: boolean, group: IEditorGroup): void {
213209
this.sideBySidePreferencesWidget.setEditorVisible(visible, group);
214210
super.setEditorVisible(visible, group);
@@ -1053,10 +1049,6 @@ export class DefaultPreferencesEditor extends BaseTextEditor {
10531049
this.getControl().layout(dimension);
10541050
}
10551051

1056-
public supportsCenteredLayout(): boolean {
1057-
return false;
1058-
}
1059-
10601052
protected getAriaLabel(): string {
10611053
return nls.localize('preferencesAriaLabel', "Default preferences. Readonly text editor.");
10621054
}

0 commit comments

Comments
 (0)