PhotoCraft: An open-source, photo editor written by scratch in pure Rust
fix(ui): no Type tool path target while the target path is hidden
PanPDX250c15c503ce
diff --git a/crates/ui-egui/src/type_tool.rs b/crates/ui-egui/src/type_tool.rsindex 30d03d6aa..a2ebf1a91 100644--- a/crates/ui-egui/src/type_tool.rs+++ b/crates/ui-egui/src/type_tool.rs@@ -326,8 +326,12 @@ fn arc_length_to(sub: &photocraft_doc::Subpath, seg: usize, t: f64) -> f64 {/// The path a Type tool click at document `(x, y)` would use: the active shape layer's path,/// else the work path (the path Photoshop shows), within 4 screen px of its outline or inside it.+/// None while View › Show › Target Path (or Extras) hides the path, as the canvas then draws none.pub(crate) fn path_target(app: &PhotocraftApp, x: f64, y: f64) -> Option<PathClick> {use photocraft_vector::edit::{Hit, hit};+ if !app.ui.view.shows(app.ui.view.show.target_path) {+ return None;+ }let (shape, path) = match crate::vector_ui::active_shape_path(app) {Some((id, p)) => (Some(id), p),None => (None, app.session.active()?.doc.work_path.clone()?),diff --git a/crates/ui-egui/src/type_tool_tests.rs b/crates/ui-egui/src/type_tool_tests.rsindex 99c3a4864..278f71152 100644--- a/crates/ui-egui/src/type_tool_tests.rs+++ b/crates/ui-egui/src/type_tool_tests.rs@@ -2192,3 +2192,17 @@ fn paths_with_too_many_anchors_are_not_hover_targets() {Some(photocraft_doc::Path::new(vec![photocraft_doc::Subpath::polygon(&ring(5000))]));assert!(path_target(&app, 500.0, 400.0).is_none());}++#[test]+fn hidden_target_path_is_not_a_click_target() {+ // View › Show › Target Path off hides the path, so a click there makes plain point text.+ let mut app = new_app();+ std::sync::Arc::make_mut(&mut app.session.active_mut().unwrap().doc).work_path =+ Some(photocraft_doc::Path::new(vec![photocraft_doc::Subpath::polygon(&[(300.0, 300.0), (700.0, 300.0), (700.0, 500.0), (300.0, 500.0)])]));+ assert!(matches!(path_target(&app, 500.0, 400.0), Some(PathClick::Area { shape: None })));+ app.ui.view.show.target_path = false;+ assert!(path_target(&app, 500.0, 400.0).is_none(), "Target Path off");+ app.ui.view.show.target_path = true;+ app.ui.view.extras = false;+ assert!(path_target(&app, 500.0, 400.0).is_none(), "Extras off");+}