提交 f9911c74 编写于 作者: J Joao Moreno

Merge branch 'grid2x2'

......@@ -464,6 +464,7 @@ export class SerializableGrid<T extends ISerializableView> extends Grid<T> {
result.orientation = orientation;
result.restoreViews(firstLeaf.view, orientation, root);
result.initialLayoutContext = { width, height, root };
result.gridview.trySet2x2();
return result;
}
......
......@@ -9,7 +9,7 @@ import 'vs/css!./gridview';
import { Event, anyEvent, Emitter, mapEvent, Relay } from 'vs/base/common/event';
import { Orientation, Sash } from 'vs/base/browser/ui/sash/sash';
import { SplitView, IView as ISplitView, Sizing, ISplitViewStyles } from 'vs/base/browser/ui/splitview/splitview';
import { empty as EmptyDisposable, IDisposable } from 'vs/base/common/lifecycle';
import { empty as EmptyDisposable, IDisposable, toDisposable } from 'vs/base/common/lifecycle';
import { $, append } from 'vs/base/browser/dom';
import { tail2 as tail } from 'vs/base/common/arrays';
import { Color } from 'vs/base/common/color';
......@@ -288,6 +288,22 @@ class BranchNode implements ISplitView, IDisposable {
this._onDidChange.fire();
}
trySet2x2(other: BranchNode): IDisposable {
if (this.children.length !== 2 || other.children.length !== 2) {
return EmptyDisposable;
}
if (this.getChildSize(0) !== other.getChildSize(0)) {
return EmptyDisposable;
}
const mySash = this.splitview.sashes[0];
const otherSash = other.splitview.sashes[0];
mySash.linkedSash = otherSash;
otherSash.linkedSash = mySash;
return toDisposable(() => mySash.linkedSash = otherSash.linkedSash = undefined);
}
dispose(): void {
for (const child of this.children) {
child.dispose();
......@@ -409,6 +425,8 @@ export class GridView implements IDisposable {
private onDidSashResetRelay = new Relay<number[]>();
readonly onDidSashReset: Event<number[]> = this.onDidSashResetRelay.event;
private disposable2x2: IDisposable = EmptyDisposable;
private get root(): BranchNode {
return this._root;
}
......@@ -483,6 +501,9 @@ export class GridView implements IDisposable {
}
addView(view: IView, size: number | Sizing, location: number[]): void {
this.disposable2x2.dispose();
this.disposable2x2 = EmptyDisposable;
const [rest, index] = tail(location);
const [pathToParent, parent] = this.getNode(rest);
......@@ -512,6 +533,9 @@ export class GridView implements IDisposable {
}
removeView(location: number[], sizing?: Sizing): IView {
this.disposable2x2.dispose();
this.disposable2x2 = EmptyDisposable;
const [rest, index] = tail(location);
const [pathToParent, parent] = this.getNode(rest);
......@@ -709,6 +733,23 @@ export class GridView implements IDisposable {
return this.getNode(rest, child, path);
}
trySet2x2(): void {
this.disposable2x2.dispose();
this.disposable2x2 = EmptyDisposable;
if (this.root.children.length !== 2) {
return;
}
const [first, second] = this.root.children;
if (!(first instanceof BranchNode) || !(second instanceof BranchNode)) {
return;
}
this.disposable2x2 = first.trySet2x2(second);
}
dispose(): void {
this.onDidSashResetRelay.dispose();
this.root.dispose();
......
......@@ -96,6 +96,8 @@ export class Sash {
private readonly _onDidEnd = new Emitter<void>();
readonly onDidEnd: Event<void> = this._onDidEnd.event;
linkedSash: Sash | undefined = undefined;
private orthogonalStartSashDisposables: IDisposable[] = [];
private _orthogonalStartSash: Sash | undefined;
get orthogonalStartSash(): Sash | undefined { return this._orthogonalStartSash; }
......@@ -178,6 +180,11 @@ export class Sash {
let isMultisashResize = false;
if (this.linkedSash && !(e as any).__linkedSashEvent) {
(e as any).__linkedSashEvent = true;
this.linkedSash.onMouseDown(e);
}
if (!(e as any).__orthogonalSashEvent) {
let orthogonalSash: Sash | undefined;
......@@ -297,7 +304,6 @@ export class Sash {
const startY = event.pageY;
const altKey = event.altKey;
this._onDidStart.fire({
startX: startX,
currentX: startX,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册