(node, widget, show)
| 21 | const _origProps = {}; |
| 22 | |
| 23 | function toggleWidget(node, widget, show) { |
| 24 | if (!widget) return; |
| 25 | if (!_origProps[widget.name]) { |
| 26 | _origProps[widget.name] = { |
| 27 | origComputeSize: widget.computeSize, |
| 28 | }; |
| 29 | } |
| 30 | const origSize = node.size; |
| 31 | |
| 32 | widget.hidden = !show; |
| 33 | widget.computeSize = show |
| 34 | ? _origProps[widget.name].origComputeSize |
| 35 | : () => [0, -3.3]; |
| 36 | |
| 37 | widget.linkedWidgets?.forEach((w) => toggleWidget(node, w, show)); |
| 38 | |
| 39 | const height = show |
| 40 | ? Math.max(node.computeSize()[1], origSize[1]) |
| 41 | : node.computeSize()[1]; |
| 42 | node.setSize([node.size[0], height]); |
| 43 | |
| 44 | if (show) delete widget.computedHeight; |
| 45 | else widget.computedHeight = 0; |
| 46 | } |
| 47 | |
| 48 | function toggleModalityWidgets(node, prefix, enabled) { |
| 49 | for (const w of node.widgets) { |
no outgoing calls
no test coverage detected