Skip to content

DesignCraft: An open-source page and layout design editor written by scratch in pure Rust

Place cursor: the crosshair throughout when no graphic is loaded

paaspaas00d0e90e71cabc
diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs
index 3eb129c83..b43ef439e 100644
--- a/crates/engine/src/tests.rs
+++ b/crates/engine/src/tests.rs
@@ -527,6 +527,10 @@ Y: 100.00%")),
s.pointer(&PointerEvent::new(PointerKind::Up, 102.5, 501.25), v).unwrap();
let it = s.doc().unwrap().doc.spreads[0].items.last().unwrap().clone();
assert_eq!(it.bounds(), designcraft_geom::Rect::new(100.0, 500.0, 140.0, 520.0), "actual size at the press");
+ // With no graphic loaded there's no thumbnail to show: the crosshair, before any press too.
+ s.loaded = None;
+ s.set_tool("placeGun");
+ assert_eq!(s.cursor(p(300.0, 300.0), Mods::default(), v), Cursor::Crosshair);
}
#[test]
diff --git a/crates/tools/src/nav.rs b/crates/tools/src/nav.rs
index 95b471e4e..74a8c5074 100644
--- a/crates/tools/src/nav.rs
+++ b/crates/tools/src/nav.rs
@@ -191,8 +191,9 @@ Y: {pct}"
fn cursor(&self, cx: &ToolContext, _p: Point, _m: Mods) -> Cursor {
// Drawing the frame: the crosshair (the loaded graphic's thumbnail would hide the frame).
// Under the drag threshold no frame is drawn yet (the release is a click), so the
- // thumbnail stays, as the overlay does.
- let drawing = self.start.is_some_and(|a| cx.loaded.is_none() || (self.cur - a).hypot() >= cx.tol(3.0));
+ // thumbnail stays, as the overlay does. With no graphic loaded there's no thumbnail to
+ // show: the crosshair throughout.
+ let drawing = cx.loaded.is_none() || self.start.is_some_and(|a| (self.cur - a).hypot() >= cx.tol(3.0));
if drawing { Cursor::Crosshair } else { Cursor::LoadedGraphic }
}
}