();
readonly onDidRemoveView = this._onDidRemoveView.event;
+ get contentSize(): number {
+ return this._contentSize;
+ }
+
get size(): number {
return this._size;
}
@@ -137,7 +141,7 @@ export class Splitview {
return this.viewItems.length;
}
- public get proportions(): number[] | undefined {
+ public get proportions(): (number | undefined)[] | undefined {
return this._proportions ? [...this._proportions] : undefined;
}
@@ -242,7 +246,7 @@ export class Splitview {
});
// Initialize content size and proportions for first layout
- this.contentSize = this.viewItems.reduce((r, i) => r + i.size, 0);
+ this._contentSize = this.viewItems.reduce((r, i) => r + i.size, 0);
this.saveProportions();
}
}
@@ -654,7 +658,7 @@ export class Splitview {
}
public layout(size: number, orthogonalSize: number): void {
- const previousSize = Math.max(this.size, this.contentSize);
+ const previousSize = Math.max(this.size, this._contentSize);
this.size = size;
this.orthogonalSize = orthogonalSize;
@@ -675,14 +679,30 @@ export class Splitview {
highPriorityIndexes
);
} else {
+ let total = 0;
+
for (let i = 0; i < this.viewItems.length; i++) {
const item = this.viewItems[i];
+ const proportion = this.proportions[i];
- item.size = clamp(
- Math.round(this.proportions[i] * size),
- item.minimumSize,
- item.maximumSize
- );
+ if (typeof proportion === 'number') {
+ total += proportion;
+ } else {
+ size -= item.size;
+ }
+ }
+
+ for (let i = 0; i < this.viewItems.length; i++) {
+ const item = this.viewItems[i];
+ const proportion = this.proportions[i];
+
+ if (typeof proportion === 'number' && total > 0) {
+ item.size = clamp(
+ Math.round((proportion * size) / total),
+ item.minimumSize,
+ item.maximumSize
+ );
+ }
}
}
@@ -747,15 +767,15 @@ export class Splitview {
}
private saveProportions(): void {
- if (this.proportionalLayout && this.contentSize > 0) {
- this._proportions = this.viewItems.map(
- (i) => i.size / this.contentSize
+ if (this.proportionalLayout && this._contentSize > 0) {
+ this._proportions = this.viewItems.map((i) =>
+ i.visible ? i.size / this._contentSize : undefined
);
}
}
private layoutViews(): void {
- this.contentSize = this.viewItems.reduce((r, i) => r + i.size, 0);
+ this._contentSize = this.viewItems.reduce((r, i) => r + i.size, 0);
let sum = 0;
const x: number[] = [];
@@ -880,7 +900,7 @@ export class Splitview {
} else if (
snappedAfter &&
collapsesDown[index] &&
- (position < this.contentSize || this.endSnappingEnabled)
+ (position < this._contentSize || this.endSnappingEnabled)
) {
this.updateSash(sash, SashState.MAXIMUM);
} else {
diff --git a/packages/docs/sandboxes/demo-dockview/src/app.tsx b/packages/docs/sandboxes/demo-dockview/src/app.tsx
index 43a1c779f..fb59b38a1 100644
--- a/packages/docs/sandboxes/demo-dockview/src/app.tsx
+++ b/packages/docs/sandboxes/demo-dockview/src/app.tsx
@@ -13,7 +13,12 @@ import './app.scss';
const components = {
default: (props: IDockviewPanelProps<{ title: string }>) => {
- return {props.params.title}
;
+ return (
+
+ {props.params.title}
+
+
+ );
},
};
@@ -194,6 +199,11 @@ const LeftControls = (props: IDockviewHeaderActionsProps) => {
const PrefixHeaderControls = (props: IDockviewHeaderActionsProps) => {
return (
{
+ if (props.activePanel) {
+ props.containerApi.toggleFullscreen(props.activePanel);
+ }
+ }}
className="group-control"
style={{
display: 'flex',
@@ -233,20 +243,20 @@ const DockviewDemo = (props: { theme?: string }) => {
title: 'Panel 4',
position: { referencePanel: 'panel_3', direction: 'right' },
});
- event.api.addPanel({
- id: 'panel_5',
- component: 'default',
- title: 'Panel 5',
- position: { referencePanel: 'panel_3', direction: 'below' },
- });
- event.api.addPanel({
- id: 'panel_6',
- component: 'default',
- title: 'Panel 6',
- position: { referencePanel: 'panel_3', direction: 'right' },
- });
+ // event.api.addPanel({
+ // id: 'panel_5',
+ // component: 'default',
+ // title: 'Panel 5',
+ // position: { referencePanel: 'panel_3', direction: 'below' },
+ // });
+ // event.api.addPanel({
+ // id: 'panel_6',
+ // component: 'default',
+ // title: 'Panel 6',
+ // position: { referencePanel: 'panel_3', direction: 'right' },
+ // });
- event.api.getPanel('panel_1')!.api.setActive();
+ // event.api.getPanel('panel_1')!.api.setActive();
console.log(event.api.toJSON());
};