grid: cleanup addView method
This commit is contained in:
parent
41bcc71334
commit
426b2f134a
4 changed files with 14 additions and 29 deletions
|
@ -89,7 +89,7 @@ export class Grid<T extends IView> implements IDisposable {
|
|||
this.gridview.layout(width, height);
|
||||
}
|
||||
|
||||
addView(referenceView: T, direction: Direction, newView: T, size: number): void {
|
||||
addView(newView: T, size: number, referenceView: T, direction: Direction): void {
|
||||
if (this.views.has(newView)) {
|
||||
throw new Error('Can\'t add same view twice');
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ suite('Grid', function () {
|
|||
assert.deepEqual(view1.size, [800, 600]);
|
||||
|
||||
const view2 = new TestView(50, Number.MAX_VALUE, 50, Number.MAX_VALUE);
|
||||
grid.addView(view1, Direction.Up, view2, 200);
|
||||
grid.addView(view2, 200, view1, Direction.Up);
|
||||
assert.deepEqual(view1.size, [800, 400]);
|
||||
assert.deepEqual(view2.size, [800, 200]);
|
||||
});
|
||||
|
@ -80,7 +80,7 @@ suite('Grid', function () {
|
|||
assert.deepEqual(view1.size, [800, 600]);
|
||||
|
||||
const view2 = new TestView(50, Number.MAX_VALUE, 50, Number.MAX_VALUE);
|
||||
grid.addView(view1, Direction.Right, view2, 300);
|
||||
grid.addView(view2, 300, view1, Direction.Right);
|
||||
assert.deepEqual(view1.size, [500, 600]);
|
||||
assert.deepEqual(view2.size, [300, 600]);
|
||||
});
|
||||
|
@ -92,25 +92,25 @@ suite('Grid', function () {
|
|||
assert.deepEqual(view1.size, [800, 600]);
|
||||
|
||||
const view2 = new TestView(50, Number.MAX_VALUE, 50, Number.MAX_VALUE);
|
||||
grid.addView(view1, Direction.Up, view2, 200);
|
||||
grid.addView(view2, 200, view1, Direction.Up);
|
||||
assert.deepEqual(view1.size, [800, 400]);
|
||||
assert.deepEqual(view2.size, [800, 200]);
|
||||
|
||||
const view3 = new TestView(50, Number.MAX_VALUE, 50, Number.MAX_VALUE);
|
||||
grid.addView(view1, Direction.Right, view3, 200);
|
||||
grid.addView(view3, 200, view1, Direction.Right);
|
||||
assert.deepEqual(view1.size, [600, 400]);
|
||||
assert.deepEqual(view2.size, [800, 200]);
|
||||
assert.deepEqual(view3.size, [200, 400]);
|
||||
|
||||
const view4 = new TestView(50, Number.MAX_VALUE, 50, Number.MAX_VALUE);
|
||||
grid.addView(view2, Direction.Left, view4, 200);
|
||||
grid.addView(view4, 200, view2, Direction.Left);
|
||||
assert.deepEqual(view1.size, [600, 400]);
|
||||
assert.deepEqual(view2.size, [600, 200]);
|
||||
assert.deepEqual(view3.size, [200, 400]);
|
||||
assert.deepEqual(view4.size, [200, 200]);
|
||||
|
||||
const view5 = new TestView(50, Number.MAX_VALUE, 50, Number.MAX_VALUE);
|
||||
grid.addView(view1, Direction.Down, view5, 100);
|
||||
grid.addView(view5, 100, view1, Direction.Down);
|
||||
assert.deepEqual(view1.size, [600, 300]);
|
||||
assert.deepEqual(view2.size, [600, 200]);
|
||||
assert.deepEqual(view3.size, [200, 400]);
|
||||
|
|
|
@ -115,10 +115,10 @@ export class NextEditorPart extends Part implements INextEditorGroupsService {
|
|||
|
||||
// Add to grid widget
|
||||
this.gridWidget.addView(
|
||||
newGroupView,
|
||||
direction === Direction.DOWN ? fromGroupView.dimension.height / 2 : fromGroupView.dimension.width / 2 /* TODO@grid what size? */,
|
||||
fromGroupView,
|
||||
this.toGridViewDirection(direction),
|
||||
newGroupView,
|
||||
direction === Direction.DOWN ? fromGroupView.dimension.height / 2 : fromGroupView.dimension.width / 2 /* TODO@grid what size? */
|
||||
);
|
||||
|
||||
// Check for options
|
||||
|
|
|
@ -117,38 +117,23 @@
|
|||
debug(grid);
|
||||
console.log('-------');
|
||||
const view2 = createView();
|
||||
grid.addView(view1, Direction.Up, view2, 400);
|
||||
grid.addView(view2, 400, view1, Direction.Up);
|
||||
debug(grid);
|
||||
console.log('-------');
|
||||
const view3 = createView();
|
||||
grid.addView(view1, Direction.Right, view3, 400);
|
||||
grid.addView(view3, 400, view1, Direction.Right);
|
||||
debug(grid);
|
||||
console.log('-------');
|
||||
const view4 = createView();
|
||||
grid.addView(view2, Direction.Left, view4, 200);
|
||||
grid.addView(view4, 200, view2, Direction.Left);
|
||||
debug(grid);
|
||||
console.log('-------');
|
||||
const view5 = createView();
|
||||
grid.addView(view1, Direction.Down, view5, 200);
|
||||
grid.addView(view5, 200, view1, Direction.Down);
|
||||
debug(grid);
|
||||
console.log('-------');
|
||||
// const view5 = createView();
|
||||
// grid.addView(view2, Direction.Down, view5, 200);
|
||||
// debug(grid);
|
||||
// console.log('-------');
|
||||
// grid.addView(createView(), 400, [1]);
|
||||
// debug(grid);
|
||||
// console.log('-------');
|
||||
// grid.addView(createView(), 300, [1, 1]);
|
||||
// debug(grid);
|
||||
// console.log('-------');
|
||||
// grid.addView(createView(), 200, [1, 1, 1]);
|
||||
// debug(grid);
|
||||
// console.log('-------');
|
||||
// grid.addView(createView(), 100, [1, 1, 1, 1]);
|
||||
// debug(grid);
|
||||
// console.log('-------');
|
||||
// grid.addView(createView(), 50, [1, 1, 1, 2]);
|
||||
// grid.addView(view5, 200, view2, Direction.Down);
|
||||
// debug(grid);
|
||||
// console.log('-------');
|
||||
|
||||
|
|
Loading…
Reference in a new issue