(
view: IGridView,
size: number | Sizing,
location: number[]
)
| 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( |
no test coverage detected