mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-10-05 06:58:12 +08:00
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:
@@ -180,6 +180,7 @@ pub fn default_mapping() -> Mapping {
|
|||||||
entry!(KeyDown(Lmb); action_dispatch=PathToolMessage::DragStart { add_to_selection: Shift }),
|
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!(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(Delete); action_dispatch=PathToolMessage::Delete),
|
||||||
|
entry!(KeyDown(KeyA); modifiers=[Control], action_dispatch=PathToolMessage::SelectAllPoints),
|
||||||
entry!(KeyDown(Backspace); action_dispatch=PathToolMessage::Delete),
|
entry!(KeyDown(Backspace); action_dispatch=PathToolMessage::Delete),
|
||||||
entry!(KeyUp(Lmb); action_dispatch=PathToolMessage::DragStop { shift_mirror_distance: Shift }),
|
entry!(KeyUp(Lmb); action_dispatch=PathToolMessage::DragStop { shift_mirror_distance: Shift }),
|
||||||
entry!(KeyDown(Enter); action_dispatch=PathToolMessage::Enter {
|
entry!(KeyDown(Enter); action_dispatch=PathToolMessage::Enter {
|
||||||
|
|||||||
@@ -106,6 +106,20 @@ impl ShapeState {
|
|||||||
None
|
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) {
|
pub fn deselect_all(&mut self) {
|
||||||
self.selected_shape_state.values_mut().for_each(|state| state.selected_points.clear());
|
self.selected_shape_state.values_mut().for_each(|state| state.selected_points.clear());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ pub enum PathToolMessage {
|
|||||||
alt_mirror_angle: Key,
|
alt_mirror_angle: Key,
|
||||||
shift_mirror_distance: Key,
|
shift_mirror_distance: Key,
|
||||||
},
|
},
|
||||||
|
SelectAllPoints,
|
||||||
SelectedPointUpdated,
|
SelectedPointUpdated,
|
||||||
SelectedPointXChanged {
|
SelectedPointXChanged {
|
||||||
new_x: f64,
|
new_x: f64,
|
||||||
@@ -139,19 +140,22 @@ impl<'a> MessageHandler<ToolMessage, &mut ToolActionHandlerData<'a>> for PathToo
|
|||||||
Delete,
|
Delete,
|
||||||
NudgeSelectedPoints,
|
NudgeSelectedPoints,
|
||||||
Enter,
|
Enter,
|
||||||
|
SelectAllPoints,
|
||||||
),
|
),
|
||||||
Dragging => actions!(PathToolMessageDiscriminant;
|
Dragging => actions!(PathToolMessageDiscriminant;
|
||||||
InsertPoint,
|
InsertPoint,
|
||||||
DragStop,
|
DragStop,
|
||||||
PointerMove,
|
PointerMove,
|
||||||
Delete,
|
Delete,
|
||||||
|
SelectAllPoints,
|
||||||
),
|
),
|
||||||
DrawingBox => actions!(PathToolMessageDiscriminant;
|
DrawingBox => actions!(PathToolMessageDiscriminant;
|
||||||
InsertPoint,
|
InsertPoint,
|
||||||
DragStop,
|
DragStop,
|
||||||
PointerMove,
|
PointerMove,
|
||||||
Delete,
|
Delete,
|
||||||
Enter
|
Enter,
|
||||||
|
SelectAllPoints,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -424,6 +428,7 @@ impl Fsm for PathToolFsmState {
|
|||||||
if clicked_selected {
|
if clicked_selected {
|
||||||
shape_editor.deselect_all();
|
shape_editor.deselect_all();
|
||||||
shape_editor.select_point(&document.document_legacy, input.mouse.position, SELECTION_THRESHOLD, false);
|
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);
|
shape_editor.move_selected_points(&document.document_legacy, (delta_x, delta_y).into(), true, responses);
|
||||||
PathToolFsmState::Ready
|
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 }) => {
|
(_, PathToolMessage::SelectedPointXChanged { new_x }) => {
|
||||||
if let Some(SingleSelectedPoint { coordinates, id, ref layer_path }) = tool_data.single_selected_point {
|
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);
|
shape_editor.reposition_control_point(&id, responses, &document.document_legacy, DVec2::new(new_x, coordinates.y), layer_path);
|
||||||
|
|||||||
Reference in New Issue
Block a user