mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-26 04:22:38 +01:00
red round 2 (fw-lists): fixes for fw-run-3 (runs/fw-run-3/fw-lists.md); L-198 applied in fw-lists; committed by the lead
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6187b8cea3
commit
3ca5e9ef77
6 files changed
+26
-9
No files matched your search
@@ -891,6 +891,15 @@ impl<C: Collection> ItemsHooks<'_, '_, C> {
|
||||
let item = sub(id, ("key", key_hash(&self.source.key(at))));
|
||||
placed.note((named, (false, true)), item, Vec2::new(0.0, row.min.y), row.size());
|
||||
}
|
||||
// A zoom reflows the rows, so the anchor's row may lie outside the rows this pass built: the layout still
|
||||
// knows where it is.
|
||||
if let (Some(child), None) = (named, placed.anchor) {
|
||||
let away = (0..source.len()).filter(|&at| scrolling(at)).find(|&at| sub(id, ("key", key_hash(&source.key(at)))) == child);
|
||||
if let Some(at) = away {
|
||||
let row = layout.rect(at, offset);
|
||||
placed.note((named, (false, true)), child, Vec2::new(0.0, row.min.y), row.size());
|
||||
}
|
||||
}
|
||||
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 let Some(shift) = lazy::follow(&mut self.anchor, &placed, moved, view, room, (false, true)) {
|
||||
|
||||
@@ -277,14 +277,14 @@ impl<C: Collection> ItemsHooks<'_, '_, C> {
|
||||
_ => {}
|
||||
}
|
||||
// A secondary release on a row asks for its menu (9.2 rule 3); the row joins the selection unless it is in it.
|
||||
// Something over the collection, or a part of a row or of the collection that takes presses and is under the
|
||||
// pointer, keeps the request away; a part that picks its item (a thumbnail) is the row's, and the request names
|
||||
// Something over the collection, or a part of a row or of the collection that takes the secondary click itself
|
||||
// (its own menu, L-198) and is under the pointer, keeps the request away; a part that picks its item (a thumbnail) is the row's, and the request names
|
||||
// it.
|
||||
let released = crate::runtime::pointer::frame(&ctx);
|
||||
let hover = crate::primitives::sensing::read_outcome(&ctx, ArenaId::new(cx.core.id)).hover;
|
||||
let menu_at = if released.release == Some(craft_behavior::PointerButton::Secondary)
|
||||
&& cx.core.response.hovered()
|
||||
&& hover.find(|hit| hit.part.is_some() && hit.sense.takes_press() && !hit.sense.contains(Sense::PICKS_ITEM)).is_none()
|
||||
&& hover.find(|hit| hit.part.is_some() && hit.sense.contains(Sense::CONTEXT_CLICK) && !hit.sense.contains(Sense::PICKS_ITEM)).is_none()
|
||||
{
|
||||
released.pos.filter(|pos| rect.contains(xf.map_or(*pos, |map| map.to_layer(*pos))))
|
||||
} else {
|
||||
|
||||
@@ -141,6 +141,10 @@ fn text_size_from(story: &Story, base: Shot) -> Result<(), String> {
|
||||
// A run the component painted elided is shortened by design and keeps its full text in the access name
|
||||
// (the elision rule checks that), so it is not cut; it must still stay inside its part.
|
||||
if !grown.keeps(same.rect, same.clip) {
|
||||
eprintln!(
|
||||
"DIAG suite ListRow reads text-size {}: {name}: base run {:?} clip {:?} grown run {:?} clip {:?} elided {} shown {:?}",
|
||||
story.name, run.rect, run.clip, same.rect, same.clip, same.elided, grown.shown
|
||||
);
|
||||
return Err(format!("{}: under {name} the text `{}` leaves its part", story.name, run.text));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,6 +103,11 @@ 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");
|
||||
|
||||
@@ -1396,7 +1396,7 @@ fn a_rename_editor_selects_the_name_once_keeps_the_caret_and_escape_cancels() {
|
||||
let held = seen.clone();
|
||||
let mut fixture = Fixture::new(move |ui| {
|
||||
let keys = [0_usize, 1];
|
||||
let source = keyed(&keys, |key: &usize| *key);
|
||||
let source = keyed(&keys, |key: &usize| *key).with_text(|key| std::borrow::Cow::Borrowed(SHEETS[*key]));
|
||||
let out = List::new("Sheets").id(list_id()).rename(true).show_items(ui, &source, &mut |key, _| ListRow::new(SHEETS[*key]));
|
||||
held.borrow_mut().extend(out.events);
|
||||
});
|
||||
|
||||
@@ -49,16 +49,15 @@ fn an_icon_row_is_one_stop_in_the_menu_left_and_right_move_between_its_icons_and
|
||||
}
|
||||
});
|
||||
fixture.settle();
|
||||
let target = fixture.by_label("Canvas").expect("the menu's target");
|
||||
fixture.click(&target);
|
||||
let open = |fixture: &mut Fixture| {
|
||||
// A click does not focus a button, and Shift+F10 asks the focused component for its menu.
|
||||
request(fixture.ctx(), FocusTarget::Id(rows.get().target.expect("the menu's target is shown")));
|
||||
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: target {:?} focused {:?} context request {:?} group shown {}",
|
||||
rows.get().target,
|
||||
"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(),
|
||||
rows.get().target.and_then(|id| craft_ui::testing::focus::context_request(fixture.ctx(), id)),
|
||||
fixture.by_label("Group").is_some()
|
||||
);
|
||||
assert!(fixture.by_label("Ungroup").is_some(), "Shift+F10 opens the context menu");
|
||||
|
||||
Reference in new issue
Block a user