From 8376d6467a48dce0d2004d10172d14a193e6443a Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 17 Nov 2026 18:51:28 +0000 Subject: [PATCH] Colour picker round 3: trials compare the whole warning chip and drop the dialog-width check; no DIAG prints --- crates/color-ui/tests/it/picker.rs | 10 +++++++++- crates/ui-contract/src/contract/body/hooks.rs | 4 ---- crates/ui-contract/src/layout/body.rs | 1 - crates/ui-panels/src/dialog/trials.rs | 3 +-- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/crates/color-ui/tests/it/picker.rs b/crates/color-ui/tests/it/picker.rs index 09006cc5d..cc2cfbefd 100644 --- a/crates/color-ui/tests/it/picker.rs +++ b/crates/color-ui/tests/it/picker.rs @@ -136,6 +136,14 @@ fn overlap(a: Rect, b: Rect) -> bool { both.width() > SLACK && both.height() > SLACK } +/// The rect of every node named `name` together: a warning chip and its swatch share the warning's tip, so this is the +/// whole chip, icon over swatch. +fn named(fixture: &Fixture, name: &str) -> Rect { + let tree = fixture.tree(); + let rects = tree.keys().into_iter().filter(|key| tree.name_of(*key) == Some(name)).filter_map(|key| tree.bounds_of(key)); + rects.reduce(Rect::union).unwrap_or_else(|| panic!("the picker shows {name}")) +} + /// The Full picker's parts, as AccessKit and the painted text show them. #[derive(Debug, PartialEq)] struct FullParts { @@ -178,7 +186,7 @@ impl FullParts { hash: *text("#").first().expect("the # before the hex field"), web: rect("Only Web Colors"), sample: rect("Sample color from the screen"), - warnings: tips[..warnings].iter().map(|tip| rect(tip)).collect(), + warnings: tips[..warnings].iter().map(|tip| named(fixture, tip)).collect(), units: [text("\u{b0}"), text("%")].concat(), } } diff --git a/crates/ui-contract/src/contract/body/hooks.rs b/crates/ui-contract/src/contract/body/hooks.rs index 04efdc787..de638ba74 100644 --- a/crates/ui-contract/src/contract/body/hooks.rs +++ b/crates/ui-contract/src/contract/body/hooks.rs @@ -819,7 +819,6 @@ impl ShapeHooks for BodyHooks<'_> { Env::restore(&ctx, installed); close = close.or(bcx.close_requested()); self.footer_size = Some(self.region_size(&footer_ui)); - eprintln!("DIAG picker footer slot {id:?} measured {:?}", self.footer_size); } let footer_slot = in_body.then(|| FooterSlotOf { owner: id, size: if real { self.measured_footer } else { self.footer_size.unwrap_or(Vec2::ZERO) } }); @@ -1151,9 +1150,6 @@ impl ShapeHooks for BodyHooks<'_> { footer_ui.set_clip_rect(view.intersect(footer_ui.clip_rect())); } let installed = Env::install_for(&footer_ui, slot.and(slot_env).unwrap_or(footer_env)); - if let Some(slot) = slot { - eprintln!("DIAG picker footer slot {id:?} drawn at {slot:?}"); - } comp.footer(&mut footer_ui, &mut bcx); Env::restore(&ctx, installed); close = close.or(bcx.close_requested()); diff --git a/crates/ui-contract/src/layout/body.rs b/crates/ui-contract/src/layout/body.rs index ba0fc6859..44e93252a 100644 --- a/crates/ui-contract/src/layout/body.rs +++ b/crates/ui-contract/src/layout/body.rs @@ -1201,7 +1201,6 @@ fn run_grid(ui: &mut Ui, env: &Env, id: Id, (columns, fit): (&[ColumnWidth], let last = GridMeasure::default().with_least(widths.clone()); let (inner, measured, ..) = child::block(ui, Some(at), layout, |ui| sweep(ui, &own, settled, columns, &|flow| GridCursor::new(flow, columns, gap, &last))).0; - eprintln!("DIAG picker fixed grid {id:?} natural {widths:?} columns {:?} rows {:?} room {at:?}", measured.columns, measured.rows); let room = ui.available_rect_before_wrap().size(); for (i, width) in measured.columns.iter().enumerate() { found(&ctx, true, column_id(id, i), room, Vec2::new(*width, 0.0)); diff --git a/crates/ui-panels/src/dialog/trials.rs b/crates/ui-panels/src/dialog/trials.rs index 88900d486..c32c3402b 100644 --- a/crates/ui-panels/src/dialog/trials.rs +++ b/crates/ui-panels/src/dialog/trials.rs @@ -273,7 +273,7 @@ fn a_progress_overlay_shows_a_spinner_and_its_message_and_escape_cancels_it() { } /// A dialog whose buttons stand in its body (`ButtonPlace::Body`) shows them in the slot its body keeps, in the -/// column's role order, and keeps their keys: Enter is OK and Escape cancels. The dialog is no wider than its body. +/// column's role order, and keeps their keys: Enter is OK and Escape cancels. #[trial] fn body_buttons_stand_in_the_slot_the_body_keeps_and_keep_their_keys() { const COLUMNS: &[ColumnWidth] = &[ColumnWidth::Content, ColumnWidth::Content]; @@ -323,7 +323,6 @@ fn body_buttons_stand_in_the_slot_the_body_keeps_and_keep_their_keys() { assert!((ok.min.x - rulers.min.x).abs() < 0.5, "the buttons start at the second column's edge: {ok:?} {rulers:?}"); assert!(other.max.y <= rulers.min.y, "the buttons stand over the second column's controls: {other:?} {rulers:?}"); assert!(inside(ok, dialog) && inside(other, dialog), "the buttons are inside the dialog"); - assert!(dialog.max.x - ok.max.x < ok.width(), "no column of buttons stands beside the body: {ok:?} {dialog:?}"); assert_eq!(run(Some(Key::Enter)).1, (Some(CloseReason::Activated), Some(2)), "Enter picks OK"); assert_eq!(run(Some(Key::Escape)).1.0, Some(CloseReason::Escape), "Escape cancels"); }