|
| 1 | +import React from "react"; |
1 | 2 | import { HoverOutlineHighlight, ReadonlySelectHightlight } from "../overlay"; |
2 | 3 | import { FrameTitle, FrameTitleProps } from "../frame-title"; |
3 | 4 | import type { XY, XYWH } from "../types"; |
@@ -62,65 +63,69 @@ export function HudSurface({ |
62 | 63 | }} |
63 | 64 | id="hud-surface" |
64 | 65 | > |
65 | | - {labelDisplayNodes && |
66 | | - labelDisplayNodes.map((node) => { |
67 | | - const absxy: XY = [node.absoluteX * zoom, node.absoluteY * zoom]; |
68 | | - return renderFrameTitle({ |
69 | | - id: node.id, |
70 | | - name: node.name, |
71 | | - xy: absxy, |
72 | | - wh: [node.width, node.height], |
73 | | - zoom: zoom, |
74 | | - selected: selectedNodes.some( |
75 | | - (selectedNode) => selectedNode.id === node.id |
76 | | - ), |
77 | | - onSelect: () => onSelectNode(node.id), |
78 | | - onHoverChange: (hv) => { |
79 | | - if (hv) { |
80 | | - onHoverNode(node.id); |
| 66 | + {!hide && ( |
| 67 | + <> |
| 68 | + {labelDisplayNodes && |
| 69 | + labelDisplayNodes.map((node) => { |
| 70 | + const absxy: XY = [node.absoluteX * zoom, node.absoluteY * zoom]; |
| 71 | + return renderFrameTitle({ |
| 72 | + id: node.id, |
| 73 | + name: node.name, |
| 74 | + xy: absxy, |
| 75 | + wh: [node.width, node.height], |
| 76 | + zoom: zoom, |
| 77 | + selected: selectedNodes.some( |
| 78 | + (selectedNode) => selectedNode.id === node.id |
| 79 | + ), |
| 80 | + onSelect: () => onSelectNode(node.id), |
| 81 | + onHoverChange: (hv) => { |
| 82 | + if (hv) { |
| 83 | + onHoverNode(node.id); |
| 84 | + } else { |
| 85 | + onHoverNode(null); |
| 86 | + } |
| 87 | + }, |
| 88 | + highlight: !![...highlights, ...selectedNodes].find( |
| 89 | + (n) => n.id === node.id |
| 90 | + ), |
| 91 | + }); |
| 92 | + })} |
| 93 | + {highlights && |
| 94 | + highlights.map((h) => { |
| 95 | + return ( |
| 96 | + <HoverOutlineHighlight |
| 97 | + key={h.id} |
| 98 | + type="xywhr" |
| 99 | + xywh={h.xywh} |
| 100 | + zoom={zoom} |
| 101 | + width={2} |
| 102 | + /> |
| 103 | + ); |
| 104 | + })} |
| 105 | + {selectedNodes && |
| 106 | + selectedNodes.map((s) => { |
| 107 | + const xywh: [number, number, number, number] = [ |
| 108 | + s.absoluteX, |
| 109 | + s.absoluteY, |
| 110 | + s.width, |
| 111 | + s.height, |
| 112 | + ]; |
| 113 | + if (readonly) { |
| 114 | + return ( |
| 115 | + <ReadonlySelectHightlight |
| 116 | + key={s.id} |
| 117 | + type="xywhr" |
| 118 | + xywh={xywh} |
| 119 | + zoom={zoom} |
| 120 | + width={1} |
| 121 | + /> |
| 122 | + ); |
81 | 123 | } else { |
82 | | - onHoverNode(null); |
| 124 | + // TODO: support non readonly canvas |
83 | 125 | } |
84 | | - }, |
85 | | - highlight: !![...highlights, ...selectedNodes].find( |
86 | | - (n) => n.id === node.id |
87 | | - ), |
88 | | - }); |
89 | | - })} |
90 | | - {highlights && |
91 | | - highlights.map((h) => { |
92 | | - return ( |
93 | | - <HoverOutlineHighlight |
94 | | - key={h.id} |
95 | | - type="xywhr" |
96 | | - xywh={h.xywh} |
97 | | - zoom={zoom} |
98 | | - width={2} |
99 | | - /> |
100 | | - ); |
101 | | - })} |
102 | | - {selectedNodes && |
103 | | - selectedNodes.map((s) => { |
104 | | - const xywh: [number, number, number, number] = [ |
105 | | - s.absoluteX, |
106 | | - s.absoluteY, |
107 | | - s.width, |
108 | | - s.height, |
109 | | - ]; |
110 | | - if (readonly) { |
111 | | - return ( |
112 | | - <ReadonlySelectHightlight |
113 | | - key={s.id} |
114 | | - type="xywhr" |
115 | | - xywh={xywh} |
116 | | - zoom={zoom} |
117 | | - width={1} |
118 | | - /> |
119 | | - ); |
120 | | - } else { |
121 | | - // TODO: support non readonly canvas |
122 | | - } |
123 | | - })} |
| 126 | + })} |
| 127 | + </> |
| 128 | + )} |
124 | 129 | </div> |
125 | 130 | ); |
126 | 131 | } |
|
0 commit comments