Skip to content

Commit 61accc5

Browse files
committed
add links_in_selection_box_world for world-coordinate box selection
The Slint side now converts selection box coordinates to world space before calling the callback. Add a world-coordinate variant so callers that receive pre-converted coordinates don't double-convert.
1 parent 538f8b9 commit 61accc5

1 file changed

Lines changed: 27 additions & 13 deletions

File tree

src/controller.rs

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -405,22 +405,15 @@ impl NodeEditorController {
405405
.nodes_in_selection_box(world_x, world_y, world_w, world_h)
406406
}
407407

408-
/// Find all links that have at least one endpoint inside the given screen-space selection box.
409-
///
410-
/// Converts the box and link endpoints to world space for comparison.
411-
pub fn links_in_selection_box_screen(
408+
/// Find all links that have at least one endpoint inside the given world-space selection box.
409+
pub fn links_in_selection_box_world(
412410
&self,
413-
sx: f32,
414-
sy: f32,
415-
sw: f32,
416-
sh: f32,
411+
world_x: f32,
412+
world_y: f32,
413+
world_w: f32,
414+
world_h: f32,
417415
) -> Vec<i32> {
418416
let s = self.state.borrow();
419-
let z = s.safe_zoom();
420-
let world_x = (sx - s.pan_x) / z;
421-
let world_y = (sy - s.pan_y) / z;
422-
let world_w = sw / z;
423-
let world_h = sh / z;
424417
let cache = self.cache.borrow();
425418

426419
// Compute world-space link endpoints: node_world + pin_rel
@@ -447,6 +440,27 @@ impl NodeEditorController {
447440
link_geometries,
448441
)
449442
}
443+
444+
/// Find all links that have at least one endpoint inside the given screen-space selection box.
445+
///
446+
/// Converts the box from screen→world and delegates to [`links_in_selection_box_world`](Self::links_in_selection_box_world).
447+
pub fn links_in_selection_box_screen(
448+
&self,
449+
sx: f32,
450+
sy: f32,
451+
sw: f32,
452+
sh: f32,
453+
) -> Vec<i32> {
454+
let s = self.state.borrow();
455+
let z = s.safe_zoom();
456+
let world_x = (sx - s.pan_x) / z;
457+
let world_y = (sy - s.pan_y) / z;
458+
let world_w = sw / z;
459+
let world_h = sh / z;
460+
drop(s);
461+
462+
self.links_in_selection_box_world(world_x, world_y, world_w, world_h)
463+
}
450464
}
451465

452466
#[cfg(test)]

0 commit comments

Comments
 (0)