MCPcopy
hub / github.com/mathuo/dockview / addView

Method addView

packages/dockview-core/src/gridview/gridview.ts:920–984  ·  view source on GitHub ↗
(
        view: IGridView,
        size: number | Sizing,
        location: number[]
    )

Source from the content-addressed store, hash-verified

918 }
919
920 public addView(
921 view: IGridView,
922 size: number | Sizing,
923 location: number[]
924 ): void {
925 if (this.hasMaximizedView()) {
926 this.exitMaximizedView();
927 }
928
929 const [rest, index] = tail(location);
930
931 const [pathToParent, parent] = this.getNode(rest);
932
933 if (parent instanceof BranchNode) {
934 const node = new LeafNode(
935 view,
936 orthogonal(parent.orientation),
937 parent.orthogonalSize
938 );
939 parent.addChild(node, size, index);
940 } else {
941 const [grandParent, ..._] = [...pathToParent].reverse();
942 const [parentIndex, ...__] = [...rest].reverse();
943
944 let newSiblingSize: number | Sizing = 0;
945
946 const newSiblingCachedVisibleSize =
947 grandParent.getChildCachedVisibleSize(parentIndex);
948 if (typeof newSiblingCachedVisibleSize === 'number') {
949 newSiblingSize = Sizing.Invisible(newSiblingCachedVisibleSize);
950 }
951
952 const child = grandParent.removeChild(parentIndex);
953 child.dispose();
954
955 const newParent = new BranchNode(
956 parent.orientation,
957 this.proportionalLayout,
958 this.styles,
959 parent.size,
960 parent.orthogonalSize,
961 this.locked,
962 this.margin
963 );
964 grandParent.addChild(newParent, parent.size, parentIndex);
965
966 const newSibling = new LeafNode(
967 parent.view,
968 grandParent.orientation,
969 parent.size
970 );
971 newParent.addChild(newSibling, newSiblingSize, 0);
972
973 if (typeof size !== 'number' && size.type === 'split') {
974 size = { type: 'split', index: 0 };
975 }
976
977 const node = new LeafNode(

Callers 13

_doAddPopoutGroupMethod · 0.45
_doAddFloatingGroupMethod · 0.45
_doMoveGroupMethod · 0.45
constructorMethod · 0.45
addTopViewMethod · 0.45
addBottomViewMethod · 0.45
constructorMethod · 0.45
addEdgeViewMethod · 0.45
addPaneMethod · 0.45
addChildMethod · 0.45
doAddGroupFunction · 0.45
splitview.spec.tsFile · 0.45

Calls 9

hasMaximizedViewMethod · 0.95
exitMaximizedViewMethod · 0.95
getNodeMethod · 0.95
addChildMethod · 0.95
tailFunction · 0.90
orthogonalFunction · 0.85
removeChildMethod · 0.80
disposeMethod · 0.65

Tested by

no test coverage detected