render and toggle split points for linear elements as well

This commit is contained in:
Preet 2023-10-23 21:15:25 -07:00
parent 4372e992e0
commit bf7c91536f
2 changed files with 18 additions and 14 deletions

View File

@ -3758,7 +3758,7 @@ class App extends React.Component<AppProps, AppState> {
const selectedElements = this.scene.getSelectedElements(this.state); const selectedElements = this.scene.getSelectedElements(this.state);
if (selectedElements.length === 1 && isLinearElement(selectedElements[0])) { if (selectedElements.length === 1 && isLinearElement(selectedElements[0])) {
if (selectedElements[0].roundness) { if (!event[KEYS.CTRL_OR_CMD]) {
const pointUnderCursorIndex = const pointUnderCursorIndex =
LinearElementEditor.getPointIndexUnderCursor( LinearElementEditor.getPointIndexUnderCursor(
selectedElements[0], selectedElements[0],

View File

@ -266,6 +266,16 @@ const renderSingleLinearPoint = (
} }
}; };
const isLinearPointAtIndexSquared = (
element: NonDeleted<ExcalidrawLinearElement>,
index: number,
) => {
const splitting = element.segmentSplitIndices
? element.segmentSplitIndices.includes(index)
: false;
return element.roundness ? splitting : !splitting;
};
const renderLinearPointHandles = ( const renderLinearPointHandles = (
context: CanvasRenderingContext2D, context: CanvasRenderingContext2D,
appState: InteractiveCanvasAppState, appState: InteractiveCanvasAppState,
@ -287,19 +297,13 @@ const renderLinearPointHandles = (
const isSelected = const isSelected =
!!appState.editingLinearElement?.selectedPointsIndices?.includes(idx); !!appState.editingLinearElement?.selectedPointsIndices?.includes(idx);
const segmented = element.roundness
? element.segmentSplitIndices
? element.segmentSplitIndices.includes(idx)
: false
: false;
renderSingleLinearPoint( renderSingleLinearPoint(
context, context,
appState, appState,
point, point,
radius, radius,
isSelected, isSelected,
segmented, isLinearPointAtIndexSquared(element, idx),
); );
}); });
@ -393,15 +397,15 @@ const renderLinearElementPointHighlight = (
element, element,
hoverPointIndex, hoverPointIndex,
); );
const segmented = element.roundness
? element.segmentSplitIndices
? element.segmentSplitIndices.includes(hoverPointIndex)
: false
: false;
context.save(); context.save();
context.translate(appState.scrollX, appState.scrollY); context.translate(appState.scrollX, appState.scrollY);
highlightPoint(point, context, appState, segmented); highlightPoint(
point,
context,
appState,
isLinearPointAtIndexSquared(element, hoverPointIndex),
);
context.restore(); context.restore();
}; };