|
@@ -162,6 +162,7 @@ const renderSingleLinearPoint = (
|
|
appState: AppState,
|
|
appState: AppState,
|
|
renderConfig: RenderConfig,
|
|
renderConfig: RenderConfig,
|
|
point: Point,
|
|
point: Point,
|
|
|
|
+ radius: number,
|
|
isSelected: boolean,
|
|
isSelected: boolean,
|
|
isPhantomPoint = false,
|
|
isPhantomPoint = false,
|
|
) => {
|
|
) => {
|
|
@@ -173,10 +174,7 @@ const renderSingleLinearPoint = (
|
|
} else if (isPhantomPoint) {
|
|
} else if (isPhantomPoint) {
|
|
context.fillStyle = "rgba(177, 151, 252, 0.7)";
|
|
context.fillStyle = "rgba(177, 151, 252, 0.7)";
|
|
}
|
|
}
|
|
- const { POINT_HANDLE_SIZE } = LinearElementEditor;
|
|
|
|
- const radius = appState.editingLinearElement
|
|
|
|
- ? POINT_HANDLE_SIZE
|
|
|
|
- : POINT_HANDLE_SIZE / 2;
|
|
|
|
|
|
+
|
|
fillCircle(
|
|
fillCircle(
|
|
context,
|
|
context,
|
|
point[0],
|
|
point[0],
|
|
@@ -205,32 +203,61 @@ const renderLinearPointHandles = (
|
|
if (!centerPoint) {
|
|
if (!centerPoint) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+ const { POINT_HANDLE_SIZE } = LinearElementEditor;
|
|
|
|
+ const radius = appState.editingLinearElement
|
|
|
|
+ ? POINT_HANDLE_SIZE
|
|
|
|
+ : POINT_HANDLE_SIZE / 2;
|
|
points.forEach((point, idx) => {
|
|
points.forEach((point, idx) => {
|
|
const isSelected =
|
|
const isSelected =
|
|
!!appState.editingLinearElement?.selectedPointsIndices?.includes(idx);
|
|
!!appState.editingLinearElement?.selectedPointsIndices?.includes(idx);
|
|
- renderSingleLinearPoint(context, appState, renderConfig, point, isSelected);
|
|
|
|
|
|
+
|
|
|
|
+ renderSingleLinearPoint(
|
|
|
|
+ context,
|
|
|
|
+ appState,
|
|
|
|
+ renderConfig,
|
|
|
|
+ point,
|
|
|
|
+ radius,
|
|
|
|
+ isSelected,
|
|
|
|
+ );
|
|
});
|
|
});
|
|
|
|
|
|
- if (!appState.editingLinearElement && points.length < 3) {
|
|
|
|
|
|
+ if (points.length < 3) {
|
|
if (appState.selectedLinearElement.midPointHovered) {
|
|
if (appState.selectedLinearElement.midPointHovered) {
|
|
const centerPoint = LinearElementEditor.getMidPoint(
|
|
const centerPoint = LinearElementEditor.getMidPoint(
|
|
appState.selectedLinearElement,
|
|
appState.selectedLinearElement,
|
|
)!;
|
|
)!;
|
|
- highlightPoint(centerPoint, context, appState, renderConfig);
|
|
|
|
-
|
|
|
|
- renderSingleLinearPoint(
|
|
|
|
- context,
|
|
|
|
- appState,
|
|
|
|
- renderConfig,
|
|
|
|
- centerPoint,
|
|
|
|
- false,
|
|
|
|
- );
|
|
|
|
|
|
+ // The order of renderingSingleLinearPoint and highLight points is different
|
|
|
|
+ // inside vs outside editor as hover states are different,
|
|
|
|
+ // in editor when hovered the original point is not visible as hover state fully covers it whereas outside the
|
|
|
|
+ // editor original point is visible and hover state is just an outer circle.
|
|
|
|
+ if (appState.editingLinearElement) {
|
|
|
|
+ renderSingleLinearPoint(
|
|
|
|
+ context,
|
|
|
|
+ appState,
|
|
|
|
+ renderConfig,
|
|
|
|
+ centerPoint,
|
|
|
|
+ radius,
|
|
|
|
+ false,
|
|
|
|
+ );
|
|
|
|
+ highlightPoint(centerPoint, context, renderConfig);
|
|
|
|
+ } else {
|
|
|
|
+ highlightPoint(centerPoint, context, renderConfig);
|
|
|
|
+ renderSingleLinearPoint(
|
|
|
|
+ context,
|
|
|
|
+ appState,
|
|
|
|
+ renderConfig,
|
|
|
|
+ centerPoint,
|
|
|
|
+ radius,
|
|
|
|
+ false,
|
|
|
|
+ );
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
renderSingleLinearPoint(
|
|
renderSingleLinearPoint(
|
|
context,
|
|
context,
|
|
appState,
|
|
appState,
|
|
renderConfig,
|
|
renderConfig,
|
|
centerPoint,
|
|
centerPoint,
|
|
|
|
+ POINT_HANDLE_SIZE / 2,
|
|
false,
|
|
false,
|
|
true,
|
|
true,
|
|
);
|
|
);
|
|
@@ -243,7 +270,6 @@ const renderLinearPointHandles = (
|
|
const highlightPoint = (
|
|
const highlightPoint = (
|
|
point: Point,
|
|
point: Point,
|
|
context: CanvasRenderingContext2D,
|
|
context: CanvasRenderingContext2D,
|
|
- appState: AppState,
|
|
|
|
renderConfig: RenderConfig,
|
|
renderConfig: RenderConfig,
|
|
) => {
|
|
) => {
|
|
context.fillStyle = "rgba(105, 101, 219, 0.4)";
|
|
context.fillStyle = "rgba(105, 101, 219, 0.4)";
|
|
@@ -280,7 +306,7 @@ const renderLinearElementPointHighlight = (
|
|
context.save();
|
|
context.save();
|
|
context.translate(renderConfig.scrollX, renderConfig.scrollY);
|
|
context.translate(renderConfig.scrollX, renderConfig.scrollY);
|
|
|
|
|
|
- highlightPoint(point, context, appState, renderConfig);
|
|
|
|
|
|
+ highlightPoint(point, context, renderConfig);
|
|
context.restore();
|
|
context.restore();
|
|
};
|
|
};
|
|
|
|
|