From 2dc0dafa5a001649d7b5b3e5555b01c4c4ca3994 Mon Sep 17 00:00:00 2001 From: mathuo <6710312+mathuo@users.noreply.github.com> Date: Tue, 20 Aug 2024 22:00:21 +0100 Subject: [PATCH] feat: addGroup initial sizes --- .../src/dockview/dockviewComponent.ts | 14 +++++++++++++- .../src/dockview/dockviewGroupPanelModel.ts | 2 ++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/packages/dockview-core/src/dockview/dockviewComponent.ts b/packages/dockview-core/src/dockview/dockviewComponent.ts index b06410090..517f7c8b1 100644 --- a/packages/dockview-core/src/dockview/dockviewComponent.ts +++ b/packages/dockview-core/src/dockview/dockviewComponent.ts @@ -1640,7 +1640,12 @@ export class DockviewComponent ); const group = this.createGroup(options); - this.doAddGroup(group, relativeLocation); + const size = + this.getLocationOrientation(relativeLocation) === + Orientation.VERTICAL + ? options.initialHeight + : options.initialWidth; + this.doAddGroup(group, relativeLocation, size); if (!options.skipSetActive) { this.doSetGroupAndPanelActive(group); } @@ -1654,6 +1659,13 @@ export class DockviewComponent } } + private getLocationOrientation(location: number[]) { + return location.length % 2 == 0 && + this.gridview.orientation === Orientation.HORIZONTAL + ? Orientation.HORIZONTAL + : Orientation.VERTICAL; + } + removeGroup( group: DockviewGroupPanel, options?: diff --git a/packages/dockview-core/src/dockview/dockviewGroupPanelModel.ts b/packages/dockview-core/src/dockview/dockviewGroupPanelModel.ts index ae3c07ae3..1d02d4d33 100644 --- a/packages/dockview-core/src/dockview/dockviewGroupPanelModel.ts +++ b/packages/dockview-core/src/dockview/dockviewGroupPanelModel.ts @@ -52,6 +52,8 @@ interface CoreGroupOptions { hideHeader?: boolean; skipSetActive?: boolean; constraints?: Partial; + initialWidth?: number; + initialHeight?: number; } export interface GroupOptions extends CoreGroupOptions {