diff --git a/src/vs/base/browser/ui/grid/grid.ts b/src/vs/base/browser/ui/grid/grid.ts index d8bb81bbb87fe23e62fa73b6082c7123aac7d537..5339c78a34f22eb915936332722c77943176b473 100644 --- a/src/vs/base/browser/ui/grid/grid.ts +++ b/src/vs/base/browser/ui/grid/grid.ts @@ -120,7 +120,7 @@ export class Grid implements IDisposable { this.gridview = new GridView(container); this.disposables.push(this.gridview); - this.gridview.onDidSashReset(this.onDidSashReset, this, this.disposables); + this.gridview.onDidSashReset(this.doResetViewSize, this, this.disposables); this._addView(view, 0, [0]); } @@ -202,6 +202,12 @@ export class Grid implements IDisposable { return getLocationOrientation(this.orientation, location); } + resetViewSize(view: T): void { + const location = this.getViewLocation(view); + + this.doResetViewSize(location); + } + private getViewLocation(view: T): number[] { const element = this.views.get(view); @@ -212,7 +218,7 @@ export class Grid implements IDisposable { return getGridLocation(element); } - private onDidSashReset(location: number[]): void { + private doResetViewSize(location: number[]): void { if (this.sashResetSizing === Sizing.Split) { const orientation = getLocationOrientation(this.orientation, location); const firstViewSize = getSize(this.gridview.getViewSize(location), orientation); diff --git a/src/vs/workbench/browser/parts/editor/editorActions.ts b/src/vs/workbench/browser/parts/editor/editorActions.ts index fd6b7ed170482970a3af6e52a251915966506f11..4e21d299feca17b720f493994316b47f574754d9 100644 --- a/src/vs/workbench/browser/parts/editor/editorActions.ts +++ b/src/vs/workbench/browser/parts/editor/editorActions.ts @@ -18,12 +18,13 @@ import { IPartService } from 'vs/workbench/services/part/common/partService'; import { Position, IEditor, Direction, IResourceInput, IEditorInput, POSITIONS } from 'vs/platform/editor/common/editor'; import { IHistoryService } from 'vs/workbench/services/history/common/history'; import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; -import { IEditorGroupService, GroupArrangement } from 'vs/workbench/services/group/common/groupService'; +import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService'; import { ICommandService } from 'vs/platform/commands/common/commands'; import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles'; import { IWindowsService } from 'vs/platform/windows/common/windows'; import { CLOSE_EDITOR_COMMAND_ID, NAVIGATE_IN_GROUP_ONE_PREFIX, NAVIGATE_ALL_EDITORS_GROUP_PREFIX, NAVIGATE_IN_GROUP_THREE_PREFIX, NAVIGATE_IN_GROUP_TWO_PREFIX } from 'vs/workbench/browser/parts/editor/editorCommands'; -import { INextEditorGroupsService, GroupDirection as SplitDirection, INextEditorGroup } from 'vs/workbench/services/group/common/nextEditorGroupsService'; +import { INextEditorGroupsService, GroupDirection as SplitDirection, INextEditorGroup, GroupsArrangement } from 'vs/workbench/services/group/common/nextEditorGroupsService'; +import { INextEditorService } from 'vs/workbench/services/editor/common/nextEditorService'; // TODo@grid this action should be removed in favour of the split vertical/horizontal actions export class SplitEditorAction extends Action { @@ -874,12 +875,12 @@ export class MinimizeOtherGroupsAction extends Action { public static readonly ID = 'workbench.action.minimizeOtherEditors'; public static readonly LABEL = nls.localize('minimizeOtherEditorGroups', "Minimize Other Editor Groups"); - constructor(id: string, label: string, @IEditorGroupService private editorGroupService: IEditorGroupService) { + constructor(id: string, label: string, @INextEditorGroupsService private editorGroupService: INextEditorGroupsService) { super(id, label); } public run(): TPromise { - this.editorGroupService.arrangeGroups(GroupArrangement.MINIMIZE_OTHERS); + this.editorGroupService.arrangeGroups(GroupsArrangement.MINIMIZE_OTHERS); return TPromise.as(false); } @@ -890,12 +891,12 @@ export class EvenGroupWidthsAction extends Action { public static readonly ID = 'workbench.action.evenEditorWidths'; public static readonly LABEL = nls.localize('evenEditorGroups', "Even Editor Group Widths"); - constructor(id: string, label: string, @IEditorGroupService private editorGroupService: IEditorGroupService) { + constructor(id: string, label: string, @INextEditorGroupsService private editorGroupService: INextEditorGroupsService) { super(id, label); } public run(): TPromise { - this.editorGroupService.arrangeGroups(GroupArrangement.EVEN); + this.editorGroupService.arrangeGroups(GroupsArrangement.EVEN); return TPromise.as(false); } @@ -909,16 +910,17 @@ export class MaximizeGroupAction extends Action { constructor( id: string, label: string, - @IWorkbenchEditorService private editorService: IWorkbenchEditorService, - @IEditorGroupService private editorGroupService: IEditorGroupService, + @INextEditorService private editorService: INextEditorService, + @INextEditorGroupsService private editorGroupService: INextEditorGroupsService, @IPartService private partService: IPartService ) { super(id, label); } public run(): TPromise { - if (this.editorService.getActiveEditor()) { - this.editorGroupService.arrangeGroups(GroupArrangement.MINIMIZE_OTHERS); + if (this.editorService.activeEditor) { + this.editorGroupService.arrangeGroups(GroupsArrangement.MINIMIZE_OTHERS); + return this.partService.setSideBarHidden(true); } diff --git a/src/vs/workbench/browser/parts/editor/editorPart.ts b/src/vs/workbench/browser/parts/editor/editorPart.ts index 3566956d49f85e03bacf71f0811239558a9483a5..e715e41988048feb226e4843d580c1da0b04b7e9 100644 --- a/src/vs/workbench/browser/parts/editor/editorPart.ts +++ b/src/vs/workbench/browser/parts/editor/editorPart.ts @@ -304,14 +304,6 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService //#endregion - //#region TODO@grid group arrangement - - public arrangeGroups(arrangement: GroupArrangement): void { - this.editorGroupsControl.arrangeGroups(arrangement); - } - - //#endregion - //#region TODO@grid group orientation public get onGroupOrientationChanged(): Event { @@ -1175,6 +1167,10 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService return editor; } + public arrangeGroups(arrangement: GroupArrangement): void { + this.editorGroupsControl.arrangeGroups(arrangement); + } + private doSetInput(group: EditorGroup, editor: BaseEditor, input: EditorInput, options: EditorOptions, monitor: ProgressMonitor): TPromise { // Emit Input-Changed Event as appropiate diff --git a/src/vs/workbench/browser/parts/editor2/nextEditorPart.ts b/src/vs/workbench/browser/parts/editor2/nextEditorPart.ts index 370b1942c89e9bc28adb050fb09b06826ec96fa8..36b02d06c0593a2669cbd0fe214faa214905a9bd 100644 --- a/src/vs/workbench/browser/parts/editor2/nextEditorPart.ts +++ b/src/vs/workbench/browser/parts/editor2/nextEditorPart.ts @@ -11,14 +11,14 @@ import { Part } from 'vs/workbench/browser/part'; import { Dimension, isAncestor, toggleClass, addClass, clearNode } from 'vs/base/browser/dom'; import { Event, Emitter, once } from 'vs/base/common/event'; import { contrastBorder, editorBackground } from 'vs/platform/theme/common/colorRegistry'; -import { INextEditorGroupsService, GroupDirection, IAddGroupOptions } from 'vs/workbench/services/group/common/nextEditorGroupsService'; +import { INextEditorGroupsService, GroupDirection, IAddGroupOptions, GroupsArrangement } from 'vs/workbench/services/group/common/nextEditorGroupsService'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { Direction, SerializableGrid, Sizing, ISerializedGrid, Orientation, ISerializedNode } from 'vs/base/browser/ui/grid/grid'; import { GroupIdentifier, IWorkbenchEditorConfiguration } from 'vs/workbench/common/editor'; import { values } from 'vs/base/common/map'; import { EDITOR_GROUP_BORDER } from 'vs/workbench/common/theme'; import { distinct } from 'vs/base/common/arrays'; -import { INextEditorGroupsAccessor, INextEditorGroupView, INextEditorPartOptions, getEditorPartOptions, impactsEditorPartOptions, INextEditorPartOptionsChangeEvent } from 'vs/workbench/browser/parts/editor2/editor2'; +import { INextEditorGroupsAccessor, INextEditorGroupView, INextEditorPartOptions, getEditorPartOptions, impactsEditorPartOptions, INextEditorPartOptionsChangeEvent, EDITOR_MAX_DIMENSIONS, EDITOR_MIN_DIMENSIONS } from 'vs/workbench/browser/parts/editor2/editor2'; import { NextEditorGroupView } from 'vs/workbench/browser/parts/editor2/nextEditorGroupView'; import { IConfigurationService, IConfigurationChangeEvent } from 'vs/platform/configuration/common/configuration'; import { IDisposable, dispose, toDisposable } from 'vs/base/common/lifecycle'; @@ -205,6 +205,35 @@ export class NextEditorPart extends Part implements INextEditorGroupsService, IN return groupView; } + arrangeGroups(arrangement: GroupsArrangement): void { + if (this.count < 2) { + return; // require at least 2 groups to show + } + + // Even all group sizes + if (arrangement === GroupsArrangement.EVEN) { + this.groups.forEach(group => { + this.gridWidget.resetViewSize(group); + }); + } + + // Maximize the current active group + else { + this.groups.forEach(group => { + const orientation = this.gridWidget.getOrientation(group); + + let newSize: number; + if (this.activeGroup === group) { + newSize = orientation === Orientation.HORIZONTAL ? EDITOR_MAX_DIMENSIONS.width : EDITOR_MAX_DIMENSIONS.height; + } else { + newSize = orientation === Orientation.HORIZONTAL ? EDITOR_MIN_DIMENSIONS.width : EDITOR_MIN_DIMENSIONS.height; + } + + this.gridWidget.resizeView(group, newSize); + }); + } + } + addGroup(location: INextEditorGroupView | GroupIdentifier, direction: GroupDirection, options?: IAddGroupOptions): INextEditorGroupView { const locationView = this.assertGroupView(location); diff --git a/src/vs/workbench/services/group/common/nextEditorGroupsService.ts b/src/vs/workbench/services/group/common/nextEditorGroupsService.ts index c9ff54d83e5654236f743f770eae67f4063b0b80..1b7a47f7c37168f04845b3f934673405d81657a2 100644 --- a/src/vs/workbench/services/group/common/nextEditorGroupsService.ts +++ b/src/vs/workbench/services/group/common/nextEditorGroupsService.ts @@ -19,6 +19,20 @@ export enum GroupDirection { RIGHT } +export enum GroupsArrangement { + + /** + * Make the current active group consume the maximum + * amount of space possible. + */ + MINIMIZE_OTHERS, + + /** + * Size all groups evenly. + */ + EVEN +} + export interface IMoveEditorOptions { index?: number; inactive?: boolean; @@ -98,6 +112,11 @@ export interface INextEditorGroupsService { */ resizeGroup(group: INextEditorGroup | GroupIdentifier, sizeDelta: number): INextEditorGroup; + /** + * Arrange all groups according to the provided arrangement. + */ + arrangeGroups(arrangement: GroupsArrangement): void; + /** * Add a new group to the editor area. A new group is added by splitting a provided one in * one of the four directions.