mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-26 05:37:04 +00:00
red round 3 (fw-lists): fixes for fw-run-4 (runs/fw-run-4/fw-lists.md); committed by the lead
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
ca26f06558
commit
aa06616683
@@ -902,7 +902,21 @@ impl<C: Collection> ItemsHooks<'_, '_, C> {
|
||||
}
|
||||
let moved = Vec2::new(0.0, (self.offset - self.offset_at_read) as f32);
|
||||
let room = (Vec2::new(0.0, self.offset as f32), Vec2::new(0.0, (self.max_offset(view.y) - self.offset) as f32));
|
||||
if named.is_some() {
|
||||
eprintln!(
|
||||
"DIAG zoom-follow: anchor at {:?} placed.anchor {:?} first {:?} offset {} at_read {} room {room:?} content {:?} visible {:?} source {}",
|
||||
self.anchor.map(|anchor| anchor.at),
|
||||
placed.anchor,
|
||||
placed.first.map(|(_, at)| at),
|
||||
self.offset,
|
||||
self.offset_at_read,
|
||||
self.content,
|
||||
self.visible,
|
||||
source.len()
|
||||
);
|
||||
}
|
||||
if let Some(shift) = lazy::follow(&mut self.anchor, &placed, moved, view, room, (false, true)) {
|
||||
eprintln!("DIAG zoom-follow: shift {shift:?}");
|
||||
self.offset += f64::from(shift.y);
|
||||
log::debug!(target: crate::runtime::egui::sizing::RERUN_LOG, "collection {id:?} keeps its anchor row in place by {shift:?}");
|
||||
crate::runtime::egui::sizing::request_discard(ctx, crate::runtime::egui::sizing::Rerun::Layout);
|
||||
|
||||
@@ -467,6 +467,7 @@ pub(crate) fn run<C: Component>(
|
||||
let back_from_menu = menu_held && state.held_selection.is_none();
|
||||
if out.focused && !left_for_part && !was_focused && !back_from_menu {
|
||||
let len = decl.shown.chars().count();
|
||||
eprintln!("DIAG text focus select: widget {widget:?} caret {:?} len {len} was_focused {was_focused}", decl.caret);
|
||||
match decl.caret {
|
||||
Caret::All => adapter::select(&ctx, widget, 0, len),
|
||||
_ => adapter::select(&ctx, widget, len, len),
|
||||
|
||||
@@ -174,6 +174,14 @@ fn rtl_from(story: &Story, ltr: &Fixture) -> Result<(), String> {
|
||||
for key in tree.keys().into_iter().filter(|key| is_interactive(tree, *key) && !in_document_space(tree, *key) && !tree.in_ltr_axis(*key)) {
|
||||
let (Some(a), Some(b)) = (tree.bounds_of(key), rtl.tree().bounds_of(key)) else { continue };
|
||||
if !mirrored(a, b, within) {
|
||||
eprintln!(
|
||||
"DIAG rtl_from {}: own ltr {:?} own rtl {:?} within {within:?} key {key:?} ltr shown {:?} rtl shown {:?}",
|
||||
story.name,
|
||||
own.0,
|
||||
own.1,
|
||||
ltr.shown(),
|
||||
rtl.shown()
|
||||
);
|
||||
return Err(format!("{}: a node at {a:?} is at {b:?} under right-to-left, not its reflection", story.name));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,6 +166,13 @@ impl ListRow<'_> {
|
||||
draw.layout(&run, self.text_block(label, sizes, 0.0).0.width())
|
||||
});
|
||||
let lines = wrapped.as_ref().map_or(0.0, |layout| sizes.gap + layout.size().y);
|
||||
if let Some(layout) = &wrapped {
|
||||
eprintln!(
|
||||
"DIAG row paint: label {label:?} text_block width {} wrapped size {:?}",
|
||||
self.text_block(label, sizes, 0.0).0.width(),
|
||||
layout.size()
|
||||
);
|
||||
}
|
||||
let (label, mut top) = self.text_block(label, sizes, lines + self.below_height(sizes));
|
||||
// A heading's detail sits at the end of the label's line and the title is cut to what it leaves.
|
||||
let beside = match (&self.detail, self.heading) {
|
||||
@@ -270,15 +277,8 @@ impl ListRow<'_> {
|
||||
let action = {
|
||||
let draw = ui.draw();
|
||||
// The action's slot is its part's rect, which `parts` declared from the link's measured width.
|
||||
let slots = self.status_slots(
|
||||
*at,
|
||||
cell,
|
||||
sizes,
|
||||
rtl,
|
||||
role,
|
||||
&|run| draw.layout(run, f32::INFINITY).size().x,
|
||||
&|_| cx.part(part).rect.width(),
|
||||
);
|
||||
let slots =
|
||||
self.status_slots(*at, cell, sizes, rtl, role, &|run| draw.layout(run, f32::INFINITY).size().x, &|_| cx.part(part).rect.width());
|
||||
if let (Some(slot), Some(icon)) = (slots.icon, tone_icon(status.tone)) {
|
||||
draw.icon(Rect::from_center_size(slot.center(), Vec2::splat(sizes.mark)), &IconSpec::svg(IconId::new(icon)).color(ink));
|
||||
}
|
||||
|
||||
@@ -147,6 +147,12 @@ impl Component for ListRow<'_> {
|
||||
let runs = [run];
|
||||
DocText::new(&runs).layout(cx.ui.ctx(), cx.tokens, cx.env.text_direction()).size()
|
||||
});
|
||||
if self.lines.is_some() {
|
||||
eprintln!(
|
||||
"DIAG row measure: proposal {:?} room {:?} probe.label {:?} toggles {toggles} band {band} wrapped {wrapped} height {height}",
|
||||
cx.proposal, cx.room, probe.label
|
||||
);
|
||||
}
|
||||
let detail = if self.detail_line() { sizes.detail_line } else { 0.0 };
|
||||
let text = sizes.label_line + detail + self.progress_line(sizes) + wrapped + self.below_height(sizes);
|
||||
let height = if self.lines.is_some() || self.progress.is_some() || !self.below.is_empty() {
|
||||
@@ -268,15 +274,10 @@ impl Component for ListRow<'_> {
|
||||
let role = cx.style.cell.role;
|
||||
for (at, position, cell) in &placed.statuses {
|
||||
let cell = Rect::from_x_y_ranges(cell.x_range(), rect.y_range());
|
||||
let slots = self.status_slots(
|
||||
*at,
|
||||
cell,
|
||||
&cx.style.sizes,
|
||||
cx.flow.is_rtl(),
|
||||
role,
|
||||
&|run| cx.layout_at(run, f32::INFINITY).size().x,
|
||||
&|action| cx.face(action_link(action, role)).x,
|
||||
);
|
||||
let slots =
|
||||
self.status_slots(*at, cell, &cx.style.sizes, cx.flow.is_rtl(), role, &|run| cx.layout_at(run, f32::INFINITY).size().x, &|action| {
|
||||
cx.face(action_link(action, role)).x
|
||||
});
|
||||
let status = &self.statuses[*at].status;
|
||||
if let Some(tip) = &status.tip {
|
||||
// The tip covers the icon and the text; the action keeps its own pointer target beside them.
|
||||
|
||||
@@ -103,11 +103,6 @@ fn list_row_status_cell(ui: &mut Ui, _: &mut StoryData) -> StoryOutput {
|
||||
Rect::from_min_max(Pos2::new(2.0 * left + width - cell.max.x, cell.min.y), Pos2::new(2.0 * left + width - cell.min.x, cell.max.y));
|
||||
}
|
||||
}
|
||||
eprintln!(
|
||||
"DIAG suite ListRow variants rtl list_row_status_cell: rtl {} left {left} width {width} cursor {:?} cells {cells:?}",
|
||||
Env::of(ui).view().direction().is_rtl(),
|
||||
ui.cursor()
|
||||
);
|
||||
let status = CellStatus::new(Tone::Warn, "2 warnings")
|
||||
.tip("The file has form fields that will be flattened.\nIts bookmarks point to pages that are not kept.")
|
||||
.action("Details");
|
||||
|
||||
@@ -1418,7 +1418,12 @@ fn a_rename_editor_selects_the_name_once_keeps_the_caret_and_escape_cancels() {
|
||||
fixture.settle();
|
||||
let field = egui_focused(fixture.ctx()).expect("the rename field takes the focus");
|
||||
assert_eq!(caret(fixture.ctx(), field), Some(name.chars().count()), "the field opens with the whole name selected");
|
||||
fixture.key(Key::Home, Modifiers::NONE).idle(3);
|
||||
fixture.key(Key::Home, Modifiers::NONE);
|
||||
eprintln!("DIAG rename caret: right after Home {:?} focused {:?}", caret(fixture.ctx(), field), egui_focused(fixture.ctx()) == Some(field));
|
||||
for frame in 0..3 {
|
||||
fixture.idle(1);
|
||||
eprintln!("DIAG rename caret: idle {frame} {:?} focused {:?}", caret(fixture.ctx(), field), egui_focused(fixture.ctx()) == Some(field));
|
||||
}
|
||||
assert_eq!(caret(fixture.ctx(), field), Some(0), "later frames keep the caret the user put");
|
||||
fixture.key(Key::Escape, Modifiers::NONE).settle();
|
||||
assert!(edits(&seen).is_empty(), "Escape ends the rename with no edit: {:?}", seen.borrow());
|
||||
|
||||
@@ -55,11 +55,6 @@ fn an_icon_row_is_one_stop_in_the_menu_left_and_right_move_between_its_icons_and
|
||||
fixture.settle();
|
||||
fixture.key(Key::F10, Modifiers::SHIFT);
|
||||
fixture.settle();
|
||||
eprintln!(
|
||||
"DIAG an_icon_row_is_one_stop_in_the_menu_left_and_right_move_between_its_icons_and_a_pick_closes_the_chain: focused {:?} group shown {}",
|
||||
fixture.focused_stop(),
|
||||
fixture.by_label("Group").is_some()
|
||||
);
|
||||
assert!(fixture.by_label("Ungroup").is_some(), "Shift+F10 opens the context menu");
|
||||
// Every walk below starts on the first row.
|
||||
request(fixture.ctx(), FocusTarget::Id(rows.get().group.expect("the first row is shown")));
|
||||
|
||||
Reference in New Issue
Block a user