mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-12-23 10:11:54 +00:00
Add quick measurement between objects and artboards (#3274)
This commit is contained in:
parent
9dd715e4e9
commit
ca70fd8380
2 changed files with 18 additions and 3 deletions
|
|
@ -1759,6 +1759,20 @@ impl DocumentMessageHandler {
|
|||
})
|
||||
}
|
||||
|
||||
/// Find layers (including artboards) under the location in viewport space that was clicked, listed by their depth in the layer tree hierarchy.
|
||||
pub fn click_list_with_artboards<'a>(&'a self, ipp: &InputPreprocessorMessageHandler) -> impl Iterator<Item = LayerNodeIdentifier> + use<'a> {
|
||||
self.click_xray(ipp)
|
||||
.skip_while(|&layer| layer == LayerNodeIdentifier::ROOT_PARENT)
|
||||
.scan(true, |last_had_children, layer| {
|
||||
if *last_had_children {
|
||||
*last_had_children = layer.has_children(self.network_interface.document_metadata());
|
||||
Some(layer)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub fn click_list_no_parents<'a>(&'a self, ipp: &InputPreprocessorMessageHandler) -> impl Iterator<Item = LayerNodeIdentifier> + use<'a> {
|
||||
self.click_xray(ipp)
|
||||
.filter(move |&layer| !self.network_interface.is_artboard(&layer.to_node(), &[]) && !layer.has_children(self.network_interface.document_metadata()))
|
||||
|
|
|
|||
|
|
@ -660,10 +660,11 @@ impl Fsm for SelectToolFsmState {
|
|||
// TODO: Don't use `Key::MouseMiddle` directly, instead take it as a variable from the input mappings list like in all other places; or find a better way than checking the key state
|
||||
if !matches!(self, Self::Drawing { .. }) && !input.keyboard.get(Key::MouseMiddle as usize) {
|
||||
// Get the layer the user is hovering over
|
||||
let click = document.click(input);
|
||||
// Artboards are included since they're needed for quick measurement, but will be filtered out for selection later on
|
||||
let click = document.click_list_with_artboards(input).last();
|
||||
let not_selected_click = click.filter(|&hovered_layer| !document.network_interface.selected_nodes().selected_layers_contains(hovered_layer, document.metadata()));
|
||||
if let Some(layer) = not_selected_click {
|
||||
if overlay_context.visibility_settings.hover_outline() {
|
||||
if overlay_context.visibility_settings.hover_outline() && !document.network_interface.is_artboard(&layer.to_node(), &[]) {
|
||||
let layer_to_viewport = document.metadata().transform_to_viewport(layer);
|
||||
let mut hover_overlay_draw = |layer: LayerNodeIdentifier, color: Option<&str>| {
|
||||
if layer.has_children(document.metadata()) {
|
||||
|
|
@ -707,7 +708,7 @@ impl Fsm for SelectToolFsmState {
|
|||
.network_interface
|
||||
.selected_nodes()
|
||||
.selected_visible_and_unlocked_layers(&document.network_interface)
|
||||
// Exclude layers that are artboards
|
||||
// Exclude layers that are artboards from the selection bounding box
|
||||
.filter(|layer| !document.network_interface.is_artboard(&layer.to_node(), &[]))
|
||||
// For each remaining layer, try to get its document-space bounding box and convert it to a Rect
|
||||
.filter_map(|layer| document.metadata().bounding_box_document(layer).map(Rect::from_box))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue