提交 2d4bf2d7 编写于 作者: B Benjamin Pasero

grid - implement resize() functionality

上级 a970588e
......@@ -196,6 +196,12 @@ export class Grid<T extends IView> implements IDisposable {
return this.gridview.getViews() as GridBranchNode<T>;
}
getOrientation(view: T): Orientation {
const location = this.getViewLocation(view);
return getLocationOrientation(this.orientation, location);
}
private getViewLocation(view: T): number[] {
const element = this.views.get(view);
......
......@@ -71,6 +71,9 @@ suite('Grid', function () {
grid.addView(view2, 200, view1, Direction.Up);
assert.deepEqual(view1.size, [800, 400]);
assert.deepEqual(view2.size, [800, 200]);
assert.equal(grid.getOrientation(view1), Orientation.VERTICAL);
assert.equal(grid.getOrientation(view2), Orientation.VERTICAL);
});
test('two views horizontally', function () {
......@@ -83,6 +86,9 @@ suite('Grid', function () {
grid.addView(view2, 300, view1, Direction.Right);
assert.deepEqual(view1.size, [500, 600]);
assert.deepEqual(view2.size, [300, 600]);
assert.equal(grid.getOrientation(view1), Orientation.HORIZONTAL);
assert.equal(grid.getOrientation(view2), Orientation.HORIZONTAL);
});
test('simple layout', function () {
......
......@@ -23,6 +23,7 @@ import { memoize } from 'vs/base/common/decorators';
import { NotificationsCenter } from 'vs/workbench/browser/parts/notifications/notificationsCenter';
import { NotificationsToasts } from 'vs/workbench/browser/parts/notifications/notificationsToasts';
import { Dimension, getClientArea, size, position, hide, show } from 'vs/base/browser/dom';
import { INextEditorGroupsService } from 'vs/workbench/services/group/common/nextEditorGroupsService';
const MIN_SIDEBAR_PART_WIDTH = 170;
const DEFAULT_SIDEBAR_PART_WIDTH = 300;
......@@ -108,7 +109,8 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal
@IEditorGroupService private editorGroupService: IEditorGroupService,
@IPartService private partService: IPartService,
@IViewletService private viewletService: IViewletService,
@IThemeService themeService: IThemeService
@IThemeService themeService: IThemeService,
@INextEditorGroupsService private nextEditorGroupsService: INextEditorGroupsService
) {
this.parent = parent;
this.workbenchContainer = workbenchContainer;
......@@ -153,11 +155,11 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal
}
private get editorCountForHeight(): number {
return Math.max(1, this.editorGroupService.getGroupOrientation() === 'horizontal' ? this.editorGroupService.getStacksModel().groups.length : 1);
return this.nextEditorGroupsService.count; /* TODO@grid revisit */
}
private get editorCountForWidth(): number {
return Math.max(1, this.editorGroupService.getGroupOrientation() === 'vertical' ? this.editorGroupService.getStacksModel().groups.length : 1);
return this.nextEditorGroupsService.count; /* TODO@grid revisit */
}
private get activitybarWidth(): number {
......@@ -781,10 +783,9 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal
}
} else {
const stacks = this.editorGroupService.getStacksModel();
const activeGroup = stacks.positionOfGroup(stacks.activeGroup);
const activeGroup = this.nextEditorGroupsService.activeGroup;
this.editorGroupService.resizeGroup(activeGroup, sizeChangePxWidth);
this.nextEditorGroupsService.resizeGroup(activeGroup, sizeChangePxWidth);
doLayout = false;
}
}
......
......@@ -312,14 +312,6 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
//#endregion
//#region TODO@grid resizeGroup()
public resizeGroup(position: Position, groupSizeChange: number): void {
this.editorGroupsControl.resizeGroup(position, groupSizeChange);
}
//#endregion
//#region TODO@grid group orientation
public get onGroupOrientationChanged(): Event<void> {
......@@ -535,6 +527,10 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
return this.doOpenEditors(editors, activePosition, ratio, sideBySide);
}
public resizeGroup(position: Position, groupSizeChange: number): void {
this.editorGroupsControl.resizeGroup(position, groupSizeChange);
}
private doOpenEditors(editors: { input: EditorInput, position?: Position, options?: EditorOptions }[], activePosition?: number, ratio?: number[], sideBySide?: boolean): TPromise<IEditor[]> {
// Find position if not provided already from calling side
......
......@@ -194,6 +194,17 @@ export class NextEditorPart extends Part implements INextEditorGroupsService, IN
return groupView;
}
resizeGroup(group: INextEditorGroupView | GroupIdentifier, sizeDelta: number): INextEditorGroupView {
const groupView = this.assertGroupView(group);
const currentSize = this.gridWidget.getViewSize(groupView);
const currentOrientation = this.gridWidget.getOrientation(groupView);
this.gridWidget.resizeView(groupView, currentOrientation === Orientation.HORIZONTAL ? currentSize.width + sizeDelta : currentSize.height + sizeDelta);
return groupView;
}
addGroup(location: INextEditorGroupView | GroupIdentifier, direction: GroupDirection, options?: IAddGroupOptions): INextEditorGroupView {
const locationView = this.assertGroupView(location);
......
......@@ -93,6 +93,11 @@ export interface INextEditorGroupsService {
*/
activateGroup(group: INextEditorGroup | GroupIdentifier): INextEditorGroup;
/**
* Resize the group given the provided size delta.
*/
resizeGroup(group: INextEditorGroup | GroupIdentifier, sizeDelta: number): INextEditorGroup;
/**
* Add a new group to the editor area. A new group is added by splitting a provided one in
* one of the four directions.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册