diff --git a/crates/ui-widgets/src/list/row/show.rs b/crates/ui-widgets/src/list/row/show.rs index c061be4696..1afa86a789 100644 --- a/crates/ui-widgets/src/list/row/show.rs +++ b/crates/ui-widgets/src/list/row/show.rs @@ -112,7 +112,8 @@ impl Component for ListRow<'_> { tone => row_ink_of(cx, cx.tone(tone), form), }, ), - toggle: IconLook::new(sizes.icon, quiet_row_ink(cx, form, text.muted)), + // A dimmed row's toggles dim with its name: the children of a hidden group read hidden all along the row. + toggle: IconLook::new(sizes.icon, quiet_row_ink(cx, form, muted)), toggle_off: IconLook::new(sizes.icon, quiet_row_ink(cx, form, text.faint)), detail: TextLook::new(TypeRole::Caption, ink(text.faint)), cell: TextLook::new(role, ink(base)), diff --git a/crates/ui-widgets/tests/it/list.rs b/crates/ui-widgets/tests/it/list.rs index d2c9d86711..7f828fcde4 100644 --- a/crates/ui-widgets/tests/it/list.rs +++ b/crates/ui-widgets/tests/it/list.rs @@ -1356,6 +1356,48 @@ fn a_toggle_glyph_rests_muted_and_reads_normal_under_the_pointer() { ); } +/// A dimmed row (a shape inside a hidden group) rests its on toggle in `text.faint` with its name, not in the +/// `text.muted` of an ordinary row's toggle. +#[trial] +fn a_dimmed_rows_toggle_glyph_rests_faint() { + use craft_behavior::{ColumnKey, ColumnWidth}; + use craft_ui::contract::{ColumnSpec, ToggleColumn}; + use craft_ui::list::{RowInk, ToggleCell}; + use craft_ui::runtime::env::Env; + use egui::Color32; + use std::cell::Cell; + const EYE: ColumnKey = ColumnKey::new("eye"); + const NAME: ColumnKey = ColumnKey::new("name"); + let seen = Rc::new(Cell::new((egui::Rect::NOTHING, Color32::TRANSPARENT))); + let held = seen.clone(); + let mut fixture = Fixture::new(move |ui| { + let text = Env::of(ui).tokens.tokens().color.text; + let [r, g, b, a] = text.faint.0; + let columns = vec![ColumnSpec::toggle(EYE, "", ToggleColumn::sweepable()), ColumnSpec::new(NAME, "", ColumnWidth::fill(1.0))]; + let keys = [0_usize]; + let source = keyed(&keys, |key: &usize| *key); + let _ = List::new("Layers").columns(columns).show_items(ui, &source, &mut |key, icx| { + held.set((icx.cell(&EYE).unwrap_or(egui::Rect::NOTHING), Color32::from_rgba_unmultiplied(r, g, b, a))); + ListRow::new(NAMES[*key]).cells(icx.cells()).toggle(ToggleCell::eye(EYE, true)).ink(RowInk::Dimmed) + }); + }); + fixture.room(Vec2::new(300.0, 200.0)); + fixture.settle(); + let (cell, faint) = seen.get(); + let mut tints: Vec = fixture + .frame_shapes() + .iter() + .filter_map(|shape| match shape { + egui::Shape::Mesh(mesh) if cell.contains(mesh.calc_bounds().center()) => Some(mesh.vertices.iter().map(|vertex| vertex.color)), + _ => None, + }) + .flatten() + .filter(|color| color.a() > 0) + .collect(); + tints.dedup(); + assert!(!tints.is_empty() && tints.iter().all(|tint| *tint == faint), "the dimmed row's eye rests in text.faint {faint:?}: {tints:?}"); +} + /// Two rows whose eye cell is on and whose lock cell is off; the source does not flip the first row's cells. struct LockedFirst;