提交 52655b44 编写于 作者: J Joao Moreno

grid: automatic orientation

上级 162aa86f
......@@ -557,6 +557,10 @@ export enum Direction {
Right
}
function directionOrientation(direction: Direction): Orientation {
return direction === Direction.Up || direction === Direction.Down ? Orientation.VERTICAL : Orientation.HORIZONTAL;
}
export class SplitGridView<T extends IView> implements IDisposable {
private gridview: GridView;
......@@ -575,6 +579,12 @@ export class SplitGridView<T extends IView> implements IDisposable {
throw new Error('Can\'t add same view twice');
}
const orientation = directionOrientation(direction);
if (this.views.size === 1 && this.orientation !== orientation) {
this.orientation = orientation;
}
const referenceLocation = this.getViewLocation(view);
const location = getRelativeLocation(this.gridview.orientation, referenceLocation, direction);
......
......@@ -92,21 +92,21 @@
debug(grid);
console.log('-------');
const view2 = createView();
grid.splitView(view1, Direction.Down, view2, 400);
grid.splitView(view1, Direction.Up, view2, 400);
debug(grid);
console.log('-------');
const view3 = createView();
grid.splitView(view1, Direction.Right, view3, 400);
debug(grid);
console.log('-------');
const view4 = createView();
grid.splitView(view2, Direction.Left, view4, 200);
debug(grid);
console.log('-------');
const view5 = createView();
grid.splitView(view1, Direction.Down, view5, 200);
debug(grid);
console.log('-------');
// const view3 = createView();
// grid.splitView(view1, Direction.Right, view3, 400);
// debug(grid);
// console.log('-------');
// const view4 = createView();
// grid.splitView(view2, Direction.Left, view4, 200);
// debug(grid);
// console.log('-------');
// const view5 = createView();
// grid.splitView(view1, Direction.Down, view5, 200);
// debug(grid);
// console.log('-------');
// const view5 = createView();
// grid.splitView(view2, Direction.Down, view5, 200);
// debug(grid);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册