Refactor path point addition to support insertion after a specific point
This commit is contained in:
@@ -10036,12 +10036,25 @@ export function App({
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const nextPoint = createAppendedScenePathPoint(selectedPath);
|
const insertAfterPointId = getPathPointInsertionAnchorId(
|
||||||
|
editorState.selection,
|
||||||
|
selectedPath,
|
||||||
|
editorState.activeSelectionId
|
||||||
|
);
|
||||||
|
const nextPoint =
|
||||||
|
insertAfterPointId === null
|
||||||
|
? createAppendedScenePathPoint(selectedPath)
|
||||||
|
: createScenePathPointAfter(selectedPath, insertAfterPointId);
|
||||||
|
const nextPointIndex =
|
||||||
|
insertAfterPointId === null
|
||||||
|
? selectedPath.points.length
|
||||||
|
: getScenePathPointIndex(selectedPath, insertAfterPointId) + 1;
|
||||||
|
|
||||||
store.executeCommand(
|
store.executeCommand(
|
||||||
createAddPathPointCommand({
|
createAddPathPointCommand({
|
||||||
pathId: selectedPath.id,
|
pathId: selectedPath.id,
|
||||||
point: nextPoint,
|
point: nextPoint,
|
||||||
|
insertAfterPointId: insertAfterPointId ?? undefined,
|
||||||
label: "Add path point"
|
label: "Add path point"
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@@ -10083,20 +10096,20 @@ export function App({
|
|||||||
latestActiveTransformSessionRef.current = nextTransformSession;
|
latestActiveTransformSessionRef.current = nextTransformSession;
|
||||||
store.setTransformSession(nextTransformSession);
|
store.setTransformSession(nextTransformSession);
|
||||||
setStatusMessage(
|
setStatusMessage(
|
||||||
`Appended path point ${selectedPath.points.length + 1}. Move the pointer, click or press Enter to place it.`
|
`Added path point ${nextPointIndex + 1}. Move the pointer, click or press Enter to place it.`
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setStatusMessage(
|
setStatusMessage(
|
||||||
transformTargetResult.message ??
|
transformTargetResult.message ??
|
||||||
"Appended path point, but could not start grab mode."
|
"Added path point, but could not start grab mode."
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setStatusMessage(
|
setStatusMessage(
|
||||||
`Appended path point ${selectedPath.points.length + 1} to ${getPathLabelById(selectedPath.id, pathList)}.`
|
`Added path point ${nextPointIndex + 1} to ${getPathLabelById(selectedPath.id, pathList)}.`
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setStatusMessage(getErrorMessage(error));
|
setStatusMessage(getErrorMessage(error));
|
||||||
|
|||||||
Reference in New Issue
Block a user