mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-23 07:38:13 +08:00
Add Box Selection to Path Tool (#1316)
* [WIP]feat: add bounding box to path tool * feat: draw bounding box for path tool - register Enter key for finalizing bounding box position - add (WIP)func to select all in bounding box area - add hint data for new state * fix: re-render shape overlays after selection * fix: maintain existing point selection with Shift key * feat: add Shift key support for Enter Key state * fix: set apt name for Enter state's keybind * refactor: remove unnecessary code * refactor: correct hints and remove unneeded code - correct DrawingBox state's footer hints - remove PathToolData's quad and bbox methods * refactor: remove duplicate mouse position vectors
This commit is contained in:
@@ -24,6 +24,9 @@ impl SelectedLayerState {
|
||||
pub fn deselect_point(&mut self, point: ManipulatorPointId) {
|
||||
self.selected_points.remove(&point);
|
||||
}
|
||||
pub fn clear_points(&mut self) {
|
||||
self.selected_points.clear();
|
||||
}
|
||||
}
|
||||
pub type SelectedShapeState = HashMap<Vec<LayerId>, SelectedLayerState>;
|
||||
#[derive(Debug, Default)]
|
||||
@@ -97,10 +100,6 @@ impl ShapeState {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
|
||||
// Deselect all points if no nearby point
|
||||
self.deselect_all();
|
||||
|
||||
None
|
||||
}
|
||||
|
||||
@@ -621,4 +620,28 @@ impl ShapeState {
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
pub fn select_all_in_quad(&mut self, document: &Document, quad: [DVec2; 2], clear_selection: bool) {
|
||||
for (layer_path, state) in &mut self.selected_shape_state {
|
||||
if clear_selection {
|
||||
state.clear_points()
|
||||
}
|
||||
|
||||
let Ok(layer) = document.layer(&layer_path) else {continue};
|
||||
let Some(vector_data) = layer.as_vector_data() else {continue};
|
||||
|
||||
let transform = document.multiply_transforms(layer_path).unwrap_or_default();
|
||||
|
||||
for manipulator_group in vector_data.manipulator_groups() {
|
||||
for selected_type in [SelectedType::Anchor, SelectedType::InHandle, SelectedType::OutHandle] {
|
||||
let Some(position) = selected_type.get_position(manipulator_group) else {continue};
|
||||
let transformed_position = transform.transform_point2(position);
|
||||
|
||||
if quad[0].min(quad[1]).cmple(transformed_position).all() && quad[0].max(quad[1]).cmpge(transformed_position).all() {
|
||||
state.select_point(ManipulatorPointId::new(manipulator_group.id, selected_type));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user