@@ -4,6 +4,7 @@ use crate::messages::portfolio::document::overlays::utility_types::OverlayContex
44use crate :: messages:: portfolio:: document:: utility_types:: document_metadata:: LayerNodeIdentifier ;
55use crate :: messages:: tool:: common_functionality:: auto_panning:: AutoPanning ;
66use crate :: messages:: tool:: common_functionality:: compass_rose:: Axis ;
7+ use crate :: messages:: tool:: common_functionality:: measure;
78use crate :: messages:: tool:: common_functionality:: resize:: Resize ;
89use crate :: messages:: tool:: common_functionality:: snapping;
910use crate :: messages:: tool:: common_functionality:: snapping:: SnapCandidatePoint ;
@@ -12,7 +13,7 @@ use crate::messages::tool::common_functionality::snapping::SnapManager;
1213use crate :: messages:: tool:: common_functionality:: transformation_cage:: * ;
1314use graph_craft:: document:: NodeId ;
1415use graphene_std:: Artboard ;
15- use graphene_std:: renderer:: Quad ;
16+ use graphene_std:: renderer:: { Quad , Rect } ;
1617use graphene_std:: table:: Table ;
1718
1819#[ derive( Default , ExtractField ) ]
@@ -241,6 +242,39 @@ impl Fsm for ArtboardToolFsmState {
241242 tool_data. bounding_box_manager . take ( ) ;
242243 }
243244
245+ // Measure with Alt held down between selected artboard and hovered layers/artboards
246+ // TODO: Don't use `Key::Alt` directly, instead take it as a variable from the input mappings list like in all other places
247+ let alt_pressed = input. keyboard . get ( Key :: Alt as usize ) ;
248+ let quick_measurement_enabled = overlay_context. visibility_settings . quick_measurement ( ) ;
249+ let not_resizing = !matches ! ( state, ArtboardToolFsmState :: ResizingBounds ) ;
250+
251+ if quick_measurement_enabled && not_resizing && alt_pressed {
252+ // Get the selected artboard bounds
253+ let selected_artboard_bounds = tool_data. selected_artboard . and_then ( |layer| document. metadata ( ) . bounding_box_document ( layer) ) . map ( Rect :: from_box) ;
254+
255+ // Find hovered artboard or regular layer
256+ let hovered_artboard = ArtboardToolData :: hovered_artboard ( document, input) ;
257+ let hovered_layer = document. click_xray ( input) . find ( |& layer| !document. network_interface . is_artboard ( & layer. to_node ( ) , & [ ] ) ) ;
258+
259+ // Get bounds for the hovered object (prioritize artboards)
260+ let hovered_bounds = if let Some ( artboard) = hovered_artboard {
261+ document. metadata ( ) . bounding_box_document ( artboard) . map ( Rect :: from_box)
262+ } else if let Some ( layer) = hovered_layer {
263+ document. metadata ( ) . bounding_box_document ( layer) . map ( Rect :: from_box)
264+ } else {
265+ None
266+ } ;
267+
268+ // If both selected artboard and hovered object bounds exist, overlay measurement lines
269+ if let ( Some ( selected_bounds) , Some ( hovered_bounds) ) = ( selected_artboard_bounds, hovered_bounds) {
270+ // Don't measure if it's the same artboard
271+ if selected_artboard_bounds != Some ( hovered_bounds) {
272+ let document_to_viewport = document. metadata ( ) . document_to_viewport ;
273+ measure:: overlay ( selected_bounds, hovered_bounds, document_to_viewport, document_to_viewport, & mut overlay_context) ;
274+ }
275+ }
276+ }
277+
244278 tool_data. snap_manager . draw_overlays ( SnapData :: new ( document, input) , & mut overlay_context) ;
245279
246280 self
0 commit comments