@@ -4,6 +4,7 @@ use crate::messages::portfolio::document::overlays::utility_types::OverlayContex
4
4
use crate :: messages:: portfolio:: document:: utility_types:: document_metadata:: LayerNodeIdentifier ;
5
5
use crate :: messages:: tool:: common_functionality:: auto_panning:: AutoPanning ;
6
6
use crate :: messages:: tool:: common_functionality:: compass_rose:: Axis ;
7
+ use crate :: messages:: tool:: common_functionality:: measure;
7
8
use crate :: messages:: tool:: common_functionality:: resize:: Resize ;
8
9
use crate :: messages:: tool:: common_functionality:: snapping;
9
10
use crate :: messages:: tool:: common_functionality:: snapping:: SnapCandidatePoint ;
@@ -12,7 +13,7 @@ use crate::messages::tool::common_functionality::snapping::SnapManager;
12
13
use crate :: messages:: tool:: common_functionality:: transformation_cage:: * ;
13
14
use graph_craft:: document:: NodeId ;
14
15
use graphene_std:: Artboard ;
15
- use graphene_std:: renderer:: Quad ;
16
+ use graphene_std:: renderer:: { Quad , Rect } ;
16
17
use graphene_std:: table:: Table ;
17
18
18
19
#[ derive( Default , ExtractField ) ]
@@ -241,6 +242,39 @@ impl Fsm for ArtboardToolFsmState {
241
242
tool_data. bounding_box_manager . take ( ) ;
242
243
}
243
244
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
+
244
278
tool_data. snap_manager . draw_overlays ( SnapData :: new ( document, input) , & mut overlay_context) ;
245
279
246
280
self
0 commit comments