Skip to content

Commit 26378a8

Browse files
committed
grid: fix missing box calculations
1 parent 83b1a1c commit 26378a8

1 file changed

Lines changed: 25 additions & 19 deletions

File tree

src/vs/base/browser/ui/grid/gridview.ts

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ export interface IGridViewOptions {
119119

120120
interface ILayoutContext {
121121
readonly orthogonalSize: number;
122-
readonly orthogonalOffset: number;
122+
readonly absoluteOffset: number;
123+
readonly absoluteOrthogonalOffset: number;
123124
}
124125

125126
class BranchNode implements ISplitView<ILayoutContext>, IDisposable {
@@ -134,11 +135,8 @@ class BranchNode implements ISplitView<ILayoutContext>, IDisposable {
134135
private _orthogonalSize: number;
135136
get orthogonalSize(): number { return this._orthogonalSize; }
136137

137-
private _offset: number = 0;
138-
get offset(): number { return this._offset; }
139-
140-
private _orthogonalOffset: number = 0;
141-
get orthogonalOffset(): number { return this._orthogonalOffset; }
138+
private absoluteOffset: number = 0;
139+
private absoluteOrthogonalOffset: number = 0;
142140

143141
private _styles: IGridViewStyles;
144142
get styles(): IGridViewStyles { return this._styles; }
@@ -151,6 +149,14 @@ class BranchNode implements ISplitView<ILayoutContext>, IDisposable {
151149
return this.orientation === Orientation.HORIZONTAL ? this.orthogonalSize : this.size;
152150
}
153151

152+
get top(): number {
153+
return this.orientation === Orientation.HORIZONTAL ? this.absoluteOffset : this.absoluteOrthogonalOffset;
154+
}
155+
156+
get left(): number {
157+
return this.orientation === Orientation.HORIZONTAL ? this.absoluteOrthogonalOffset : this.absoluteOffset;
158+
}
159+
154160
get minimumSize(): number {
155161
return this.children.length === 0 ? 0 : Math.max(...this.children.map(c => c.minimumOrthogonalSize));
156162
}
@@ -232,7 +238,7 @@ class BranchNode implements ISplitView<ILayoutContext>, IDisposable {
232238
if (!childDescriptors) {
233239
// Normal behavior, we have no children yet, just set up the splitview
234240
this.splitview = new SplitView(this.element, { orientation, styles, proportionalLayout });
235-
this.splitview.layout(size, { orthogonalSize, orthogonalOffset: 0 });
241+
this.splitview.layout(size, { orthogonalSize, absoluteOffset: 0, absoluteOrthogonalOffset: 0 });
236242
} else {
237243
// Reconstruction behavior, we want to reconstruct a splitview
238244
const descriptor = {
@@ -291,10 +297,13 @@ class BranchNode implements ISplitView<ILayoutContext>, IDisposable {
291297
// branch nodes should flip the normal/orthogonal directions
292298
this._size = ctx.orthogonalSize;
293299
this._orthogonalSize = size;
300+
this.absoluteOffset = ctx.absoluteOffset + offset;
301+
this.absoluteOrthogonalOffset = ctx.absoluteOrthogonalOffset;
294302

295303
this.splitview.layout(ctx.orthogonalSize, {
296304
orthogonalSize: size,
297-
orthogonalOffset: offset
305+
absoluteOffset: this.absoluteOrthogonalOffset,
306+
absoluteOrthogonalOffset: this.absoluteOffset
298307
});
299308
}
300309

@@ -533,11 +542,8 @@ class LeafNode implements ISplitView<ILayoutContext>, IDisposable {
533542
private _orthogonalSize: number;
534543
get orthogonalSize(): number { return this._orthogonalSize; }
535544

536-
private _offset: number = 0;
537-
get offset(): number { return this._offset; }
538-
539-
private _orthogonalOffset: number = 0;
540-
get orthogonalOffset(): number { return this._orthogonalOffset; }
545+
private absoluteOffset: number = 0;
546+
private absoluteOrthogonalOffset: number = 0;
541547

542548
readonly onDidSashReset: Event<number[]> = Event.None;
543549

@@ -586,11 +592,11 @@ class LeafNode implements ISplitView<ILayoutContext>, IDisposable {
586592
}
587593

588594
get top(): number {
589-
return this.orientation === Orientation.HORIZONTAL ? this.offset : this.orthogonalOffset;
595+
return this.orientation === Orientation.HORIZONTAL ? this.absoluteOffset : this.absoluteOrthogonalOffset;
590596
}
591597

592598
get left(): number {
593-
return this.orientation === Orientation.HORIZONTAL ? this.orthogonalOffset : this.offset;
599+
return this.orientation === Orientation.HORIZONTAL ? this.absoluteOrthogonalOffset : this.absoluteOffset;
594600
}
595601

596602
get element(): HTMLElement {
@@ -655,9 +661,9 @@ class LeafNode implements ISplitView<ILayoutContext>, IDisposable {
655661
}
656662

657663
this._size = size;
658-
this._offset = offset;
659664
this._orthogonalSize = ctx.orthogonalSize;
660-
this._orthogonalOffset = ctx.orthogonalOffset;
665+
this.absoluteOffset = ctx.absoluteOffset + offset;
666+
this.absoluteOrthogonalOffset = ctx.absoluteOrthogonalOffset;
661667
this.view.layout(this.width, this.height, this.top, this.left);
662668
}
663669

@@ -745,7 +751,7 @@ export class GridView implements IDisposable {
745751

746752
const { size, orthogonalSize } = this._root;
747753
this.root = flipNode(this._root, orthogonalSize, size);
748-
this.root.layout(size, 0, { orthogonalSize, orthogonalOffset: 0 });
754+
this.root.layout(size, 0, { orthogonalSize, absoluteOffset: 0, absoluteOrthogonalOffset: 0 });
749755
}
750756

751757
get width(): number { return this.root.width; }
@@ -801,7 +807,7 @@ export class GridView implements IDisposable {
801807
this.firstLayoutController.isLayoutEnabled = true;
802808

803809
const [size, orthogonalSize] = this.root.orientation === Orientation.HORIZONTAL ? [height, width] : [width, height];
804-
this.root.layout(size, 0, { orthogonalSize, orthogonalOffset: 0 });
810+
this.root.layout(size, 0, { orthogonalSize, absoluteOffset: 0, absoluteOrthogonalOffset: 0 });
805811
}
806812

807813
addView(view: IView, size: number | Sizing, location: number[]): void {

0 commit comments

Comments
 (0)