feat(workbench): drag control markings as elements
This commit is contained in:
1 parent
834470cfa1
commit
31552a5b6f
9 files changed
+244
-75
No files matched your search
@@ -170,6 +170,20 @@ function App() {
|
||||
* element box and its controls hang off this.
|
||||
*/
|
||||
const [element, setElement] = useState<ElementSelection | null>(null);
|
||||
const visibleEditHandles = useMemo(() => {
|
||||
if (!element || element.kind === 'lane-maneuver') return editHandles;
|
||||
const constraintKind = specOfKind(element.kind).constraintKind;
|
||||
// Control markings use the selected outline itself as their drag target,
|
||||
// exactly like lane-maneuver. Keep the selected control in the index so the
|
||||
// outline can resolve its semantics, while the layer hides its duplicate dot.
|
||||
return editHandles.filter(
|
||||
(handle) =>
|
||||
!handle.kind.startsWith('junction-cross') ||
|
||||
(handle.kind === constraintKind &&
|
||||
handle.anchor.type === 'junction-crossing' &&
|
||||
String(handle.anchor.crossingId) === String(element.crossingNodeId)),
|
||||
);
|
||||
}, [editHandles, element]);
|
||||
/**
|
||||
* The selected element as something to draw and grab.
|
||||
*
|
||||
@@ -189,7 +203,7 @@ function App() {
|
||||
const layer = specOfKind(element.kind).layer;
|
||||
const drawn = preview?.[layer] ?? state.layers[layer];
|
||||
const bounds = orientedBoundsOf(groupMembers(drawn?.features ?? [], element.elementId));
|
||||
return bounds ? { handleId: handle.handleId, bounds } : null;
|
||||
return bounds ? { handleId: handle.handleId, bounds, hideOtherHandles: true } : null;
|
||||
}, [editMode, element, editHandles, state, preview]);
|
||||
const laneSelectionBounds = useMemo<Coordinate[] | null>(() => {
|
||||
if (!element || element.kind !== 'lane-maneuver' || !state || !element.featureIds.length) return null;
|
||||
@@ -785,7 +799,7 @@ function App() {
|
||||
onSignalDragEnd={finishSignalMove}
|
||||
onSignalRotate={rotateSignal}
|
||||
onSignalRotateEnd={finishSignalRotate}
|
||||
handles={editHandles}
|
||||
handles={visibleEditHandles}
|
||||
ranges={editRanges}
|
||||
element={elementOutline}
|
||||
laneSelectionBounds={laneSelectionBounds}
|
||||
|
||||
Reference in new issue
Block a user