Toggle cells that are off or mixed and unlinked link glyphs rest in text.faint; on toggles and linked glyphs rest in text.muted; both read in text.normal under the pointer

This commit is contained in:
aiongg
2026-11-12 15:42:15 +00:00
parent 683e9b25da
commit 1ee300bbb3
3 changed files with 26 additions and 12 deletions
+11 -5
View File
@@ -86,7 +86,11 @@ impl ListRow<'_> {
};
if let Some(id) = shown {
let spec = IconSpec::svg(id.clone());
let spec = if toggle.fill.is_some() { spec.ink(Ink::OnDark) } else { spec.color(glyph_ink(cx, part)) };
let spec = if toggle.fill.is_some() {
spec.ink(Ink::OnDark)
} else {
spec.color(glyph_ink(cx, part, toggle.state == ToggleState::On))
};
ui.draw().icon(Rect::from_center_size(cell.center(), Vec2::splat(icon)), &spec);
}
}
@@ -134,7 +138,7 @@ impl ListRow<'_> {
let (Some(slot), Some((linked, _))) = (link, &self.extras[at].link) else { continue };
let id = IconId::new(if *linked { "link" } else { "unlink" });
let side = Rect::from_center_size(slot.center(), Vec2::splat(style.sizes.icon));
let color = glyph_ink(cx, LINK.at(at as u64));
let color = glyph_ink(cx, LINK.at(at as u64), *linked);
ui.draw().icon(side, &IconSpec::svg(id).color(color));
}
}
@@ -262,10 +266,12 @@ impl ListRow<'_> {
}
}
/// The ink of a toggle or link glyph: its own part's hover and press, over the row's selection and lead.
fn glyph_ink(cx: &Cx<'_, ListRow<'_>>, part: PartRef) -> StyleColor {
/// The ink of a toggle or link glyph that is `on` or not: its own part's hover and press, over the row's selection and
/// lead.
fn glyph_ink(cx: &Cx<'_, ListRow<'_>>, part: PartRef, on: bool) -> StyleColor {
let (row, cell) = (cx.state(), cx.part_state(part));
StateSet::new(cell.state, row.flags, StateMix::new(cell.t.hover, cell.t.press, row.t.on)).resolve(&cx.style.toggle.color)
let look = if on { &cx.style.toggle } else { &cx.style.toggle_off };
StateSet::new(cell.state, row.flags, StateMix::new(cell.t.hover, cell.t.press, row.t.on)).resolve(&look.color)
}
/// The down-right clipping mark: a stem down from the top, then a leg toward the reading end with an arrowhead.
+2 -1
View File
@@ -104,7 +104,8 @@ impl Component for ListRow<'_> {
tone => row_ink_of(cx, cx.tone(tone), form),
},
),
toggle: IconLook::new(sizes.icon, quiet_row_ink(cx, form)),
toggle: IconLook::new(sizes.icon, quiet_row_ink(cx, form, text.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)),
cell_muted: TextLook::new(role, ink(muted)),
+13 -6
View File
@@ -25,9 +25,14 @@ pub struct ListRowStyle {
/// The row's trailing icons.
#[style(icon)]
pub(super) trailing_icon: IconLook,
/// The glyph of a toggle cell and of the link between thumbnails: quiet at rest, the normal ink under the pointer.
/// The glyph of a toggle cell that is on and of a link between thumbnails that links: `text.muted` at rest, the
/// normal ink under the pointer.
#[style(icon)]
pub(super) toggle: IconLook,
/// The glyph of a toggle cell that is off or mixed and of a link that does not link: `text.faint` at rest, the
/// normal ink under the pointer.
#[style(icon)]
pub(super) toggle_off: IconLook,
/// The detail line.
#[style(text)]
pub(super) detail: TextLook,
@@ -208,11 +213,13 @@ impl RowStyleCx for StyleCx<'_> {
}
}
/// The ink of a row's toggle and link glyphs: `row_ink_of` on `text.muted`, whose off states are the quiet ink's, so
/// the glyph reads in `text.normal` under the pointer and while pressed. The flag rules keep every fill's paired ink.
pub(super) fn quiet_row_ink(cx: &StyleCx<'_>, form: RowForm) -> Stateful<StyleColor> {
let mut ink = row_ink_of(cx, cx.color(cx.tokens.color.text.muted), form);
ink.off = cx.quiet_ink().off;
/// The ink of a row's toggle and link glyphs: `row_ink_of` on `rest`, whose off states are the quiet ink's with `rest`
/// at rest, so the glyph reads in `text.normal` under the pointer and while pressed. The flag rules keep every fill's
/// paired ink.
pub(super) fn quiet_row_ink(cx: &StyleCx<'_>, form: RowForm, rest: Rgba) -> Stateful<StyleColor> {
let rest = cx.color(rest);
let mut ink = row_ink_of(cx, rest, form);
ink.off = States { rest, ..cx.quiet_ink().off };
ink
}