mirror of
https://github.com/storytold/craft-libs.git
synced 2026-12-01 10:48:15 +01:00
List: a dimmed row's toggles dim with its name
The children of a hidden group drew their eye and padlock in the ordinary toggle ink, so only their names showed the hidden state. A dimmed row's on toggles now take the row's dimmed ink. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
37c3959c5b
commit
b802c4dbd4
2 files changed
+44
-1
No files matched your search
@@ -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)),
|
||||
|
||||
@@ -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<Color32> = 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;
|
||||
|
||||
|
||||
Reference in new issue
Block a user