diff options
| author | Terry Truong <terry06890@gmail.com> | 2022-03-21 20:24:43 +1100 |
|---|---|---|
| committer | Terry Truong <terry06890@gmail.com> | 2022-03-22 00:17:39 +1100 |
| commit | 959c1661784a9a4d08c18762aedc69e405e57506 (patch) | |
| tree | 9d4634400ac9ec1f6e12aa59b5a22e9d93dcc5a0 /src/lib.ts | |
| parent | 15c8b99f945183e8d17bb96774674c8ca0431da5 (diff) | |
Add more adaptive min-cell-size for rect-layout
Diffstat (limited to 'src/lib.ts')
| -rw-r--r-- | src/lib.ts | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -276,6 +276,12 @@ let rectLayout: LayoutFn = function (node, pos, dims, showHeader, opts, ownOpts? let rowBrks: number[] = []; // Will hold indices for nodes at which each row starts let lowestEmpSpc = Number.POSITIVE_INFINITY, usedEmpRight = 0, usedEmpBottom = 0; let tempTree: LayoutNode = node.cloneNodeTree(); // Holds tentative layouts for 'node' + const minCellDims = [ // Can situationally assume non-leaf children + opts.minTileSz + opts.tileSpacing + + (opts.layoutType == 'sweep' ? opts.tileSpacing*2 : 0), + opts.minTileSz + opts.tileSpacing + + (opts.layoutType == 'sweep' ? opts.tileSpacing*2 + opts.headerSz : 0) + ]; rowBrksLoop: while (true){ // Update rowBrks or exit loop @@ -334,13 +340,13 @@ let rectLayout: LayoutFn = function (node, pos, dims, showHeader, opts, ownOpts? let cellHs = rowsOfCnts.map(rowOfCnts => arraySum(rowOfCnts) / totalDCount * newDims[1]); // Check min-tile-size, attempting to reallocate space if needed for (let rowIdx = 0; rowIdx < rowsOfCnts.length; rowIdx++){ - let newWs = limitVals(cellWs[rowIdx], opts.minTileSz + opts.tileSpacing, Number.POSITIVE_INFINITY); + let newWs = limitVals(cellWs[rowIdx], minCellDims[0], Number.POSITIVE_INFINITY); if (newWs == null){ continue rowBrksLoop; } cellWs[rowIdx] = newWs; } - cellHs = limitVals(cellHs, opts.minTileSz + opts.tileSpacing, Number.POSITIVE_INFINITY)!; + cellHs = limitVals(cellHs, minCellDims[1], Number.POSITIVE_INFINITY)!; if (cellHs == null){ continue rowBrksLoop; } |
