Support for deleting points to break path (#1593)

* feat: break closed curve

* feat: update hotkeys and handles

* feat: break an open path

* feat: elegantly handle breaking at multi points in a subpath

* feat: handle break at end points

* feat: ctrl+delete to remove segments and break path

* fix: rm unused

* First code review pass

* fix: closed eclipse handles after breaking path

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
zhiyuan
2024-02-04 21:02:09 -08:00
committed by GitHub
co-authored by Keavon Chambers
parent a4a2680ac4
commit a412a77062
3 changed files with 162 additions and 1 deletions
@@ -32,7 +32,9 @@ pub enum PathToolMessage {
SelectionChanged,
// Tool-specific messages
BreakPath,
Delete,
DeleteAndBreakPath,
DragStart {
add_to_selection: Key,
},
@@ -159,6 +161,8 @@ impl<'a> MessageHandler<ToolMessage, &mut ToolActionHandlerData<'a>> for PathToo
NudgeSelectedPoints,
Enter,
SelectAllPoints,
BreakPath,
DeleteAndBreakPath,
),
Dragging => actions!(PathToolMessageDiscriminant;
InsertPoint,
@@ -166,6 +170,8 @@ impl<'a> MessageHandler<ToolMessage, &mut ToolActionHandlerData<'a>> for PathToo
PointerMove,
Delete,
SelectAllPoints,
BreakPath,
DeleteAndBreakPath,
),
DrawingBox => actions!(PathToolMessageDiscriminant;
InsertPoint,
@@ -174,6 +180,8 @@ impl<'a> MessageHandler<ToolMessage, &mut ToolActionHandlerData<'a>> for PathToo
Delete,
Enter,
SelectAllPoints,
BreakPath,
DeleteAndBreakPath,
),
}
}
@@ -418,6 +426,14 @@ impl Fsm for PathToolFsmState {
PathToolFsmState::Ready
}
(_, PathToolMessage::BreakPath) => {
shape_editor.break_path_at_selected_point(&document.network, responses);
PathToolFsmState::Ready
}
(_, PathToolMessage::DeleteAndBreakPath) => {
shape_editor.delete_point_and_break_path(&document.network, responses);
PathToolFsmState::Ready
}
(_, PathToolMessage::InsertPoint) => {
// First we try and flip the sharpness (if they have clicked on an anchor)
if !shape_editor.flip_sharp(&document.network, &document.metadata, input.mouse.position, SELECTION_TOLERANCE, responses) {