Add 'select all points' method to ShapeState struct (#1386)

* Added select all points method to ShapeState struct

* Map select_all_points functions to shortcut

* Make SelectAllPoints action relevant in the current context only

* Refactor select_all_points to only select anchors

* Fix(editor): enable selected point update after selection change via clicking
This commit is contained in:
Prikshit Gautam
2023-09-04 19:35:43 -07:00
committed by GitHub
parent 56f20f2e6d
commit ad9ccaa800
3 changed files with 26 additions and 1 deletions
@@ -57,6 +57,7 @@ pub enum PathToolMessage {
alt_mirror_angle: Key,
shift_mirror_distance: Key,
},
SelectAllPoints,
SelectedPointUpdated,
SelectedPointXChanged {
new_x: f64,
@@ -139,19 +140,22 @@ impl<'a> MessageHandler<ToolMessage, &mut ToolActionHandlerData<'a>> for PathToo
Delete,
NudgeSelectedPoints,
Enter,
SelectAllPoints,
),
Dragging => actions!(PathToolMessageDiscriminant;
InsertPoint,
DragStop,
PointerMove,
Delete,
SelectAllPoints,
),
DrawingBox => actions!(PathToolMessageDiscriminant;
InsertPoint,
DragStop,
PointerMove,
Delete,
Enter
Enter,
SelectAllPoints,
),
}
}
@@ -424,6 +428,7 @@ impl Fsm for PathToolFsmState {
if clicked_selected {
shape_editor.deselect_all();
shape_editor.select_point(&document.document_legacy, input.mouse.position, SELECTION_THRESHOLD, false);
tool_data.refresh_overlays(document, shape_editor, shape_overlay, responses);
}
}
@@ -469,6 +474,11 @@ impl Fsm for PathToolFsmState {
shape_editor.move_selected_points(&document.document_legacy, (delta_x, delta_y).into(), true, responses);
PathToolFsmState::Ready
}
(_, PathToolMessage::SelectAllPoints) => {
shape_editor.select_all_points(&document.document_legacy);
tool_data.refresh_overlays(document, shape_editor, shape_overlay, responses);
PathToolFsmState::Ready
}
(_, PathToolMessage::SelectedPointXChanged { new_x }) => {
if let Some(SingleSelectedPoint { coordinates, id, ref layer_path }) = tool_data.single_selected_point {
shape_editor.reposition_control_point(&id, responses, &document.document_legacy, DVec2::new(new_x, coordinates.y), layer_path);