mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-26 04:22:38 +01:00
Colour picker round 3: trials compare the whole warning chip and drop the dialog-width check; no DIAG prints
This commit is contained in:
1 parent
a629ce8ec4
commit
8376d6467a
4 files changed
+10
-8
No files matched your search
@@ -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(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -819,7 +819,6 @@ impl<C: Container> ShapeHooks<C> 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<C: Container> ShapeHooks<C> 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());
|
||||
|
||||
@@ -1201,7 +1201,6 @@ fn run_grid<R>(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));
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
Reference in new issue
Block a user