Skip to content

Commit

Permalink
layout splitview views with absolute positioning
Browse files Browse the repository at this point in the history
related to #78167
  • Loading branch information
joaomoreno committed Sep 4, 2019
1 parent 3a5c7d9 commit fb85e28
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
15 changes: 3 additions & 12 deletions src/vs/base/browser/ui/splitview/splitview.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,15 @@
}

.monaco-split-view2 > .split-view-container {
display: flex;
width: 100%;
height: 100%;
white-space: nowrap;
}

.monaco-split-view2.vertical > .split-view-container {
flex-direction: column;
}

.monaco-split-view2.horizontal > .split-view-container {
flex-direction: row;
position: relative;
}

.monaco-split-view2 > .split-view-container > .split-view-view {
white-space: initial;
flex: none;
position: relative;
position: absolute;
}

.monaco-split-view2 > .split-view-container > .split-view-view:not(.visible) {
Expand Down Expand Up @@ -72,4 +63,4 @@
.monaco-split-view2.separator-border.vertical > .split-view-container > .split-view-view:not(:first-child)::before {
height: 1px;
width: 100%;
}
}
20 changes: 14 additions & 6 deletions src/vs/base/browser/ui/splitview/splitview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,13 @@ abstract class ViewItem {
}
}

layout(orthogonalSize: number | undefined): void {
layout(position: number, orthogonalSize: number | undefined): void {
this.layoutContainer(position);
this.view.layout(this.size, orthogonalSize);
}

abstract layoutContainer(position: number): void;

dispose(): IView {
this.disposable.dispose();
return this.view;
Expand All @@ -137,16 +140,16 @@ abstract class ViewItem {

class VerticalViewItem extends ViewItem {

layout(orthogonalSize: number | undefined): void {
super.layout(orthogonalSize);
layoutContainer(position: number): void {
this.container.style.top = `${position}px`;
this.container.style.height = `${this.size}px`;
}
}

class HorizontalViewItem extends ViewItem {

layout(orthogonalSize: number | undefined): void {
super.layout(orthogonalSize);
layoutContainer(position: number): void {
this.container.style.left = `${position}px`;
this.container.style.width = `${this.size}px`;
}
}
Expand Down Expand Up @@ -846,7 +849,12 @@ export class SplitView extends Disposable {
this.contentSize = this.viewItems.reduce((r, i) => r + i.size, 0);

// Layout views
this.viewItems.forEach(item => item.layout(this.orthogonalSize));
let position = 0;

for (const viewItem of this.viewItems) {
viewItem.layout(position, this.orthogonalSize);
position += viewItem.size;
}

// Layout sashes
this.sashItems.forEach(item => item.sash.layout());
Expand Down

0 comments on commit fb85e28

Please sign in to comment.