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:
parent
56f20f2e6d
commit
ad9ccaa800
|
|
@ -180,6 +180,7 @@ pub fn default_mapping() -> Mapping {
|
|||
entry!(KeyDown(Lmb); action_dispatch=PathToolMessage::DragStart { add_to_selection: Shift }),
|
||||
entry!(PointerMove; refresh_keys=[Alt, Shift], action_dispatch=PathToolMessage::PointerMove { alt_mirror_angle: Alt, shift_mirror_distance: Shift }),
|
||||
entry!(KeyDown(Delete); action_dispatch=PathToolMessage::Delete),
|
||||
entry!(KeyDown(KeyA); modifiers=[Control], action_dispatch=PathToolMessage::SelectAllPoints),
|
||||
entry!(KeyDown(Backspace); action_dispatch=PathToolMessage::Delete),
|
||||
entry!(KeyUp(Lmb); action_dispatch=PathToolMessage::DragStop { shift_mirror_distance: Shift }),
|
||||
entry!(KeyDown(Enter); action_dispatch=PathToolMessage::Enter {
|
||||
|
|
|
|||
|
|
@ -106,6 +106,20 @@ impl ShapeState {
|
|||
None
|
||||
}
|
||||
|
||||
pub fn select_all_points(&mut self, document: &Document) {
|
||||
for (layer_path, selected_layer_state) in self.selected_shape_state.iter_mut() {
|
||||
let Ok(layer) = document.layer(layer_path) else { continue };
|
||||
let Some(vector_data) = layer.as_vector_data() else { continue };
|
||||
|
||||
for group in vector_data.manipulator_groups() {
|
||||
selected_layer_state.select_point(ManipulatorPointId::new(group.id, SelectedType::Anchor));
|
||||
for selected_type in &[SelectedType::InHandle, SelectedType::OutHandle] {
|
||||
selected_layer_state.deselect_point(ManipulatorPointId::new(group.id, *selected_type));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn deselect_all(&mut self) {
|
||||
self.selected_shape_state.values_mut().for_each(|state| state.selected_points.clear());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue