From 242d00d30f05984cc2bfa0f43d3e54e17598f2ef Mon Sep 17 00:00:00 2001 From: aiongg Date: Mon, 16 Nov 2026 21:41:44 +0000 Subject: [PATCH 1/2] Pen trial: the close badge shows only over the first anchor --- crates/draw/tests/it/pen.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/crates/draw/tests/it/pen.rs b/crates/draw/tests/it/pen.rs index 46f2bfde1..f1a9654a6 100644 --- a/crates/draw/tests/it/pen.rs +++ b/crates/draw/tests/it/pen.rs @@ -160,6 +160,27 @@ fn a_press_on_the_first_anchor_closes_the_path_on_release_with_or_without_a_drag assert_eq!(done.knots.len(), 3, "no anchor added"); } +// Over the first anchor of an open draft the Pen's cursor carries the close badge (#4596); over the last anchor and +// over empty canvas it does not. +#[trial] +fn the_cursor_has_the_close_badge_only_over_the_first_anchor() { + use craft_behavior::{Cursor, CursorBadge, PaintedCursor}; + let mut pen = Pen::three(); + let mut badge_at = |x: f64, y: f64| { + let at = pen.at(x, y); + pen.move_to(at, Modifiers::NONE); + pen.fixture.fixture().frame(Vec::new()); + match craft_ui::runtime::cursor::current(pen.fixture.fixture().ctx()) { + Some(Cursor::Painted(PaintedCursor::Tool { badge, .. })) => badge, + other => panic!("the Pen shows its own cursor: {other:?}"), + } + }; + assert_eq!(badge_at(60.0, 60.0), Some(CursorBadge::Close), "over the first anchor"); + assert_eq!(badge_at(300.0, 250.0), None, "over empty canvas"); + assert_eq!(badge_at(160.0, 160.0), None, "the last anchor does not close"); + assert_eq!(badge_at(60.0, 60.0), Some(CursorBadge::Close), "back on the first anchor"); +} + #[trial] fn remove_last_waits_for_a_press_that_is_still_down() { let mut pen = Pen::three(); From fc5e6c1bc8929126196c9b9b6bbaf263721326e7 Mon Sep 17 00:00:00 2001 From: aiongg Date: Mon, 16 Nov 2026 21:43:42 +0000 Subject: [PATCH 2/2] New Guide trial: Position text that does not parse keeps OK from making a guide --- .../patterns/form_dialogs/guides/trials.rs | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/crates/ui-patterns/src/patterns/form_dialogs/guides/trials.rs b/crates/ui-patterns/src/patterns/form_dialogs/guides/trials.rs index 85f51c284..5a11d1e6d 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/guides/trials.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/guides/trials.rs @@ -129,3 +129,45 @@ fn a_new_guide_remembers_its_confirmed_values_for_the_next_open() { reopen(&mut fixture); assert_eq!(*values.borrow(), NewGuideValues::new(Axis::Y, typed, GuideColor::Magenta), "Cancel stored nothing: the OK'd values come back"); } + +/// Position text that does not parse keeps OK from making a guide at the last good position: nothing is made and the +/// dialog stays open until the text is a number. +#[trial] +fn position_text_that_does_not_parse_keeps_ok_from_making_a_guide() { + let open = Rc::new(Cell::new(true)); + let made: Rc>> = Rc::default(); + let enabled = Rc::new(Cell::new(true)); + let (opened, seen, ok_seen) = (Rc::clone(&open), Rc::clone(&made), Rc::clone(&enabled)); + let mut values = NewGuideValues::new(Axis::X, 30.0, GuideColor::Magenta); + let mut fixture = Fixture::new(move |ui| { + let units = GuideUnits::new(UnitKind::Pixels, 3000.0, 2000.0, 300.0); + let mut is_open = opened.get(); + let shown = NewGuideDialog::new(units, Bind::bound(&mut values)).opened(Bind::bound(&mut is_open)).show(ui); + opened.set(is_open); + ok_seen.set(shown.ok_enabled); + seen.borrow_mut().extend(shown.result); + }); + fixture.settle(); + let position = fixture.by_label("Position").expect("the Position field"); + fixture.click(&position).settle(); + fixture.key(egui::Key::A, egui::Modifiers::COMMAND); + fixture.type_text("far"); + fixture.key(egui::Key::Tab, egui::Modifiers::NONE).settle(); + assert!(!enabled.get(), "OK is disabled while the text does not parse"); + let ok = fixture.by_label("OK").expect("the footer has OK"); + fixture.click(&ok).settle(); + assert!(open.get(), "the dialog stays open"); + assert!(made.borrow().is_empty(), "no guide is made at the last good position"); + + let position = fixture.by_label("Position").expect("the Position field"); + fixture.click(&position).settle(); + fixture.key(egui::Key::A, egui::Modifiers::COMMAND); + fixture.type_text("40"); + fixture.key(egui::Key::Tab, egui::Modifiers::NONE).settle(); + assert!(enabled.get(), "a number enables OK again"); + let ok = fixture.by_label("OK").expect("the footer has OK"); + fixture.click(&ok).settle(); + assert!(!open.get(), "OK closes the dialog"); + let confirmed: Vec<_> = made.borrow().iter().map(|guide| guide.position).collect(); + assert_eq!(confirmed, [40.0]); +}