diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/App.vue | 2 | ||||
| -rw-r--r-- | src/components/Settings.vue | 17 | ||||
| -rw-r--r-- | src/lib.ts | 15 |
3 files changed, 26 insertions, 8 deletions
diff --git a/src/App.vue b/src/App.vue index d93e327..e875413 100644 --- a/src/App.vue +++ b/src/App.vue @@ -45,7 +45,7 @@ const defaultLayoutOptions: LayoutOptions = { maxTileSz: 200, //px layoutType: 'sweep', //'sqr' | 'rect' | 'sweep' rectMode: 'auto first-row', //'horz' | 'vert' | 'linear' | 'auto' | 'auto first-row' - rectSepLeaves: true, + rectSepLeaves: 'none', //'none' | 'start' | 'end' sweepMode: 'left', //'left' | 'top' | 'shorter' | 'auto' sweptNodesPrio: 'pow-2/3', //'linear' | 'sqrt' | 'pow-2/3' sweepingToParent: true, diff --git a/src/components/Settings.vue b/src/components/Settings.vue index 97b08d1..30ff0c3 100644 --- a/src/components/Settings.vue +++ b/src/components/Settings.vue @@ -83,8 +83,21 @@ export default defineComponent({ </div> <hr class="border-stone-400"/> <div> - <label> <input type="checkbox" v-model="layoutOptions.rectSepLeaves" - @change="onLayoutOptChg"/> Rect leaves to start </label> + Rect leaf separation + <ul> + <li> + <label> <input type="radio" v-model="layoutOptions.rectSepLeaves" value="none" + @change="onLayoutOptChg"/> None </label> + </li> + <li> + <label> <input type="radio" v-model="layoutOptions.rectSepLeaves" value="start" + @change="onLayoutOptChg"/> To start </label> + </li> + <li> + <label> <input type="radio" v-model="layoutOptions.rectSepLeaves" value="end" + @change="onLayoutOptChg"/> To end </label> + </li> + </ul> </div> <hr class="border-stone-400"/> <div> @@ -144,7 +144,7 @@ export type LayoutOptions = { layoutType: 'sqr' | 'rect' | 'sweep'; // The LayoutFn function to use rectMode: 'horz' | 'vert' | 'linear' | 'auto' | 'auto first-row'; // Rect layout in 1 row, 1 column, 1 row or column, or multiple rows (with/without first-row-heuristic) - rectSepLeaves: boolean; // Rect layout moves leaf nodes to start + rectSepLeaves: 'none' | 'start' | 'end'; // Rect layout moves leaf nodes none/to_start/to_end sweepMode: 'left' | 'top' | 'shorter' | 'auto'; // Sweep to left, top, shorter-side, or to minimise empty space sweptNodesPrio: 'linear' | 'sqrt' | 'pow-2/3'; // Specifies allocation of space to swept-vs-remaining nodes sweepingToParent: boolean; // Allow swept nodes to occupy empty space in a parent's swept-leaves area @@ -344,7 +344,7 @@ let rectLayout: LayoutFn = function (node, pos, dims, showHeader, allowCollapse, } // Reorder children if applicable let oldNode: LayoutNode, oldChildIdxs: number[]; - if (opts.rectSepLeaves){ // Change 'node' to leaves-to-start version, and store old-child-order indices + if (opts.rectSepLeaves != 'none'){ // Change 'node' to leaves-moved version, and store old-child-order indices oldNode = node; let leaves: LayoutNode[] = [], nonLeaves: LayoutNode[] = []; let leafIdxs = [] as number[], nonLeafIdxs = [] as number[]; @@ -357,8 +357,13 @@ let rectLayout: LayoutFn = function (node, pos, dims, showHeader, allowCollapse, nonLeafIdxs.push(idx); } }); - node = new LayoutNode(node.tolNode, leaves.concat(...nonLeaves)); - oldChildIdxs = leafIdxs.concat(...nonLeafIdxs); + if (opts.rectSepLeaves == 'start'){ + node = new LayoutNode(node.tolNode, leaves.concat(...nonLeaves)); + oldChildIdxs = leafIdxs.concat(...nonLeafIdxs); + } else { + node = new LayoutNode(node.tolNode, nonLeaves.concat(...leaves)); + oldChildIdxs = nonLeafIdxs.concat(...leafIdxs); + } } // Try finding arrangement with low empty space // Done by searching possible rows groupings, allocating within rows using dCounts, and trimming empty space @@ -549,7 +554,7 @@ let rectLayout: LayoutFn = function (node, pos, dims, showHeader, allowCollapse, return false; } // Create layout - if (opts.rectSepLeaves){ // Restore old 'node', and reorder 'usedTree's children to match + if (opts.rectSepLeaves != 'none'){ // Restore old 'node', and reorder 'usedTree's children to match node = oldNode!; let usedChildren = [...usedTree.children]; range(numChildren).forEach(idx => usedTree!.children[oldChildIdxs[idx]] = usedChildren[idx]); |
