rustfmt batch 6

This commit is contained in:
Dylan M. Taylor committed 2026-11-20 00:22:08 -05:00
1 parent 4bd4aced5f
commit bdd1288eb4
6 files changed
+227 -141

No files matched your search

+6 -2
View File
@@ -181,8 +181,12 @@ impl PartialEq for NumberCodec {
(Some(a), Some(b)) => Arc::ptr_eq(a, b),
_ => false,
};
self.reader == other.reader && self.decimals == other.decimals && self.fixed == other.fixed && self.zoom == other.zoom
&& self.signed_zoom == other.signed_zoom && same_custom
self.reader == other.reader
&& self.decimals == other.decimals
&& self.fixed == other.fixed
&& self.zoom == other.zoom
&& self.signed_zoom == other.signed_zoom
&& same_custom
}
}
+143 -105
View File
@@ -425,17 +425,38 @@ impl<'a> PageView<'a> {
/// Shows the view at `rect`, registering controls and running tools in `before` before drawing.
/// Return the view reported by the tool host; `body` receives the resulting placement for overlays.
/// Both callbacks borrow `session` in sequence and run on measuring and real passes.
pub fn show_at_with<T>(self, ui: &mut Ui, rect: Rect, session: &mut T, before: impl FnMut(&mut Ui, &PageBody<'_>, &mut T) -> Option<CanvasView>, body: impl FnMut(&mut Ui, &PageBody<'_>, &mut T)) -> PageViewOutput {
pub fn show_at_with<T>(
self,
ui: &mut Ui,
rect: Rect,
session: &mut T,
before: impl FnMut(&mut Ui, &PageBody<'_>, &mut T) -> Option<CanvasView>,
body: impl FnMut(&mut Ui, &PageBody<'_>, &mut T),
) -> PageViewOutput {
self.run(ui, rect, false, session, before, body)
}
/// Shows the view in the available room with a pre-draw tool callback and an overlay callback.
pub fn show_with<T>(self, ui: &mut Ui, session: &mut T, before: impl FnMut(&mut Ui, &PageBody<'_>, &mut T) -> Option<CanvasView>, body: impl FnMut(&mut Ui, &PageBody<'_>, &mut T)) -> PageViewOutput {
pub fn show_with<T>(
self,
ui: &mut Ui,
session: &mut T,
before: impl FnMut(&mut Ui, &PageBody<'_>, &mut T) -> Option<CanvasView>,
body: impl FnMut(&mut Ui, &PageBody<'_>, &mut T),
) -> PageViewOutput {
let rect = ui.available_rect_before_wrap();
self.run(ui, rect, true, session, before, body)
}
fn run<T>(self, ui: &mut Ui, rect: Rect, take_room: bool, session: &mut T, mut before: impl FnMut(&mut Ui, &PageBody<'_>, &mut T) -> Option<CanvasView>, mut body: impl FnMut(&mut Ui, &PageBody<'_>, &mut T)) -> PageViewOutput {
fn run<T>(
self,
ui: &mut Ui,
rect: Rect,
take_room: bool,
session: &mut T,
mut before: impl FnMut(&mut Ui, &PageBody<'_>, &mut T) -> Option<CanvasView>,
mut body: impl FnMut(&mut Ui, &PageBody<'_>, &mut T),
) -> PageViewOutput {
let PageView { label, source, state, options, navigation, bodies, describer, paper, border, keep } = self;
let spacing = PageMetrics::new().show_at(ui, Rect::from_min_size(rect.min, Vec2::ZERO)).spacing;
let count = source.page_count();
@@ -464,7 +485,9 @@ impl<'a> PageView<'a> {
let inputs = Inputs { source, describer, build: &build, rect, given, paper, navigation, border, keep };
let (mut next, pending) = run_pass(ui, cx, &mut held, &inputs, |ui, page| before(ui, page, session))?;
let pass = tool_pass(&cx.env);
with_canvas_space(ui, pending.space, |ui| body(ui, &PageBody { rect: cx.rect, pages: &next.pages, view: next.view, pass: pass.as_ref() }, session));
with_canvas_space(ui, pending.space, |ui| {
body(ui, &PageBody { rect: cx.rect, pages: &next.pages, view: next.view, pass: pass.as_ref() }, session)
});
// The body's tool host took the arrows a tool claims; the view moves with the keys it left.
pending.finish(ui.ctx(), &mut next, &inputs);
let decided = next.next.clone();
@@ -624,7 +647,13 @@ impl Frame {
/// One pass of the canvas body up to the app's body: layout, the wheel, a pinch and a pan folded into the state; the
/// pasteboard, the pictures and the scroll bars drawn. The keys, the turns and the go-to wait for [`Pending::finish`],
/// after the app's body.
fn run_pass(ui: &mut Ui, cx: &mut BodyCx<'_>, held: &mut Held<'_, PageViewState>, inputs: &Inputs<'_>, mut before: impl FnMut(&mut Ui, &PageBody<'_>) -> Option<CanvasView>) -> Option<(Seen, Pending)> {
fn run_pass(
ui: &mut Ui,
cx: &mut BodyCx<'_>,
held: &mut Held<'_, PageViewState>,
inputs: &Inputs<'_>,
mut before: impl FnMut(&mut Ui, &PageBody<'_>) -> Option<CanvasView>,
) -> Option<(Seen, Pending)> {
let Inputs { source, describer, build, rect, given, paper, navigation, border, keep } = *inputs;
let mut state = held.read(cx)?;
let started = state.clone();
@@ -700,17 +729,25 @@ fn run_pass(ui: &mut Ui, cx: &mut BodyCx<'_>, held: &mut Held<'_, PageViewState>
let preliminary_view = shown.visible();
let preliminary_view = DocRect::new(
preliminary_view.x0 * drawn_frame.zoom + drawn_frame.origin.x, preliminary_view.y0 * drawn_frame.zoom + drawn_frame.origin.y,
preliminary_view.x1 * drawn_frame.zoom + drawn_frame.origin.x, preliminary_view.y1 * drawn_frame.zoom + drawn_frame.origin.y,
preliminary_view.x0 * drawn_frame.zoom + drawn_frame.origin.x,
preliminary_view.y0 * drawn_frame.zoom + drawn_frame.origin.y,
preliminary_view.x1 * drawn_frame.zoom + drawn_frame.origin.x,
preliminary_view.y1 * drawn_frame.zoom + drawn_frame.origin.y,
);
let preliminary: Vec<PlacedPage> = drawn.row.clone().filter_map(|page| {
if !overlaps(band_rect(&drawn.layout, page), preliminary_view) { return None; }
let r = drawn_frame.document_rect(&drawn.layout.rects[page]);
let rect = Rect::from_min_max(shown.to_screen(Point::new(r.x0, r.y0)), shown.to_screen(Point::new(r.x1, r.y1)));
let ratio = shown.zoom / drawn_frame.zoom;
let band = (drawn.layout.bands[page].0 as f32 * ratio as f32, drawn.layout.bands[page].1 as f32 * ratio as f32);
Some(PlacedPage::new(page, rect, drawn.scale * ratio, band, TextureState::Missing))
}).collect();
let preliminary: Vec<PlacedPage> = drawn
.row
.clone()
.filter_map(|page| {
if !overlaps(band_rect(&drawn.layout, page), preliminary_view) {
return None;
}
let r = drawn_frame.document_rect(&drawn.layout.rects[page]);
let rect = Rect::from_min_max(shown.to_screen(Point::new(r.x0, r.y0)), shown.to_screen(Point::new(r.x1, r.y1)));
let ratio = shown.zoom / drawn_frame.zoom;
let band = (drawn.layout.bands[page].0 as f32 * ratio as f32, drawn.layout.bands[page].1 as f32 * ratio as f32);
Some(PlacedPage::new(page, rect, drawn.scale * ratio, band, TextureState::Missing))
})
.collect();
let slot = PaintSlot::reserve(&ui.painter_at(cx.rect));
let pass = tool_pass(&cx.env);
let tool_view = before(ui, &PageBody { rect: cx.rect, pages: &preliminary, view: shown, pass: pass.as_ref() });
@@ -727,100 +764,101 @@ fn run_pass(ui: &mut Ui, cx: &mut BodyCx<'_>, held: &mut Held<'_, PageViewState>
}
with_canvas_space(ui, space, |ui| {
// The pasteboard and the pictures are drawn through the view the canvas shows; a zoom still
// under way draws the layout the view was made for, scaled. A pointer zoom runs while the canvas zooms this pass
// or its eased zoom is still arriving on screen.
let ratio = shown.zoom / drawn_frame.zoom;
let pointer_zoom = zooming || ratio != 1.0;
let travel = travel_of(mem.offset, want, wheel.as_ref());
// The pasteboard and the pictures are drawn through the view the canvas shows; a zoom still
// under way draws the layout the view was made for, scaled. A pointer zoom runs while the canvas zooms this pass
// or its eased zoom is still arriving on screen.
let ratio = shown.zoom / drawn_frame.zoom;
let pointer_zoom = zooming || ratio != 1.0;
let travel = travel_of(mem.offset, want, wheel.as_ref());
let seen = shown.visible();
let in_view = DocRect::new(
seen.x0 * drawn_frame.zoom + drawn_frame.origin.x,
seen.y0 * drawn_frame.zoom + drawn_frame.origin.y,
seen.x1 * drawn_frame.zoom + drawn_frame.origin.x,
seen.y1 * drawn_frame.zoom + drawn_frame.origin.y,
);
let rows: Vec<usize> = drawn.row.clone().filter(|&p| overlaps(band_rect(&drawn.layout, p), in_view)).collect();
let visible = match (rows.first(), rows.last()) {
(Some(&first), Some(&last)) => first..last + 1,
_ => 0..0,
};
let to_screen = |r: &DocRect| {
let r = drawn_frame.document_rect(r);
Rect::from_min_max(shown.to_screen(Point::new(r.x0, r.y0)), shown.to_screen(Point::new(r.x1, r.y1)))
};
// Each page's picture state is asked of the page store before the pages are listed, once per page per pass,
// then the pages near what shows (ahead of the travel) and the pages the app keeps, at their side in this
// layout. Sharp renders of the page store wait while a pointer zoom runs.
let ctx = ui.ctx().clone();
let (thumbs, details) = page_stores(&ctx, cx.id, picture_options(&ctx));
thumbs.hold(pointer_zoom);
let ppp = ctx.pixels_per_point();
let ask = |page: usize, side: f32, priority: Priority| thumbs.state(&ctx, source, &page, &ThumbRequest::for_cell(side, ppp), priority);
let pages: Vec<PlacedPage> = rows
.iter()
.map(|&page| {
let rect = to_screen(&drawn.layout.rects[page]);
let band = (drawn.layout.bands[page].0 as f32 * ratio as f32, drawn.layout.bands[page].1 as f32 * ratio as f32);
let picture = ask(page, rect.width().max(rect.height()), Priority::VISIBLE);
let picture_revision = matches!(picture, TextureState::Ready(_)).then(|| source.page_revision(page)).flatten();
let mut placed = PlacedPage::new(page, rect, drawn.scale * ratio, band, picture);
placed.picture_revision = picture_revision;
placed
})
.collect();
let near = near_pages(&drawn, state.continuous, &visible, count, &build.layout_options(&state), travel);
let kept = keep.iter().copied().filter(|page| *page < count && !rows.contains(page) && !near.contains(page));
for page in near.iter().copied().chain(kept) {
let size = drawn.layout.rects[page].size();
ask(page, size.width.max(size.height) as f32, Priority::NEAR);
}
let seen = shown.visible();
let in_view = DocRect::new(
seen.x0 * drawn_frame.zoom + drawn_frame.origin.x,
seen.y0 * drawn_frame.zoom + drawn_frame.origin.y,
seen.x1 * drawn_frame.zoom + drawn_frame.origin.x,
seen.y1 * drawn_frame.zoom + drawn_frame.origin.y,
);
let rows: Vec<usize> = drawn.row.clone().filter(|&p| overlaps(band_rect(&drawn.layout, p), in_view)).collect();
let visible = match (rows.first(), rows.last()) {
(Some(&first), Some(&last)) => first..last + 1,
_ => 0..0,
};
let to_screen = |r: &DocRect| {
let r = drawn_frame.document_rect(r);
Rect::from_min_max(shown.to_screen(Point::new(r.x0, r.y0)), shown.to_screen(Point::new(r.x1, r.y1)))
};
// Each page's picture state is asked of the page store before the pages are listed, once per page per pass,
// then the pages near what shows (ahead of the travel) and the pages the app keeps, at their side in this
// layout. Sharp renders of the page store wait while a pointer zoom runs.
let ctx = ui.ctx().clone();
let (thumbs, details) = page_stores(&ctx, cx.id, picture_options(&ctx));
thumbs.hold(pointer_zoom);
let ppp = ctx.pixels_per_point();
let ask = |page: usize, side: f32, priority: Priority| thumbs.state(&ctx, source, &page, &ThumbRequest::for_cell(side, ppp), priority);
let pages: Vec<PlacedPage> = rows
.iter()
.map(|&page| {
let rect = to_screen(&drawn.layout.rects[page]);
let band = (drawn.layout.bands[page].0 as f32 * ratio as f32, drawn.layout.bands[page].1 as f32 * ratio as f32);
let picture = ask(page, rect.width().max(rect.height()), Priority::VISIBLE);
let picture_revision = matches!(picture, TextureState::Ready(_)).then(|| source.page_revision(page)).flatten();
let mut placed = PlacedPage::new(page, rect, drawn.scale * ratio, band, picture);
placed.picture_revision = picture_revision;
placed
})
.collect();
let near = near_pages(&drawn, state.continuous, &visible, count, &build.layout_options(&state), travel);
let kept = keep.iter().copied().filter(|page| *page < count && !rows.contains(page) && !near.contains(page));
for page in near.iter().copied().chain(kept) {
let size = drawn.layout.rects[page].size();
ask(page, size.width.max(size.height) as f32, Priority::NEAR);
}
let frames: Vec<PageFrame> =
rows.iter().map(|&p| PageFrame::new(drawn_frame.document_rect(&band_rect(&drawn.layout, p))).fill(paper)).collect();
let border = if state.page_gaps { border } else { PageBorder::None };
let pasteboard = Pasteboard::new(words.pasteboard.clone(), &frames).border(border).show_at(ui, cx.rect);
// The scroll bars read their drag before the pictures show, so a drag holds the part in view in its own pass; they
// paint where they always did, over the pictures: their shapes are lifted out of the paint list here and put back
// in a slot reserved after the pictures.
let slot = PaintSlot::reserve(&ui.painter_at(cx.rect));
// The bars edit the view the state keeps, the canvas's settled one: the view on screen is pixel aligned, and a
// drag handed it back would differ from the drag's own value and cancel it.
let document = drawn_frame.document(&drawn);
let bars = CanvasScrollbars::new(words.scroll_bars.clone(), Bind::given(target), DocRect::from_origin_size(Point::ZERO, document))
.show_at(ui, cx.rect);
let bar_drag = bars.view.value().is_some();
scrolled |= bar_drag;
let bar_want = bars.view.value().map(|moved| drawn_frame.offset_of(moved.center, vw, vh));
let bar_shapes = slot.take_after(&ctx);
let frames: Vec<PageFrame> = rows.iter().map(|&p| PageFrame::new(drawn_frame.document_rect(&band_rect(&drawn.layout, p))).fill(paper)).collect();
let border = if state.page_gaps { border } else { PageBorder::None };
let pasteboard = Pasteboard::new(words.pasteboard.clone(), &frames).border(border).show_at(ui, cx.rect);
// The scroll bars read their drag before the pictures show, so a drag holds the part in view in its own pass; they
// paint where they always did, over the pictures: their shapes are lifted out of the paint list here and put back
// in a slot reserved after the pictures.
let slot = PaintSlot::reserve(&ui.painter_at(cx.rect));
// The bars edit the view the state keeps, the canvas's settled one: the view on screen is pixel aligned, and a
// drag handed it back would differ from the drag's own value and cancel it.
let document = drawn_frame.document(&drawn);
let bars =
CanvasScrollbars::new(words.scroll_bars.clone(), Bind::given(target), DocRect::from_origin_size(Point::ZERO, document)).show_at(ui, cx.rect);
let bar_drag = bars.view.value().is_some();
scrolled |= bar_drag;
let bar_want = bars.view.value().map(|moved| drawn_frame.offset_of(moved.center, vw, vh));
let bar_shapes = slot.take_after(&ctx);
// The part in view waits while the view zooms or moves.
let pictures =
PagePictures::new(source, &pages, cx.id, paper).label(words.text.clone()).hold_detail(pointer_zoom || travel != 0.0 || bar_drag);
match describer {
Some(describer) => pictures.describer(describer).show_at(ui, cx.rect),
None => pictures.show_at(ui, cx.rect),
};
// PLAN: assumed impl Add for TextureStatistics (pdf-canvas-w7)
let textures = thumbs.cache().statistics(&ctx) + details.cache().statistics(&ctx);
PaintSlot::reserve(&ui.painter_at(cx.rect)).extend(&ctx, bar_shapes);
// The part in view waits while the view zooms or moves.
let pictures = PagePictures::new(source, &pages, cx.id, paper).label(words.text.clone()).hold_detail(pointer_zoom || travel != 0.0 || bar_drag);
match describer {
Some(describer) => pictures.describer(describer).show_at(ui, cx.rect),
None => pictures.show_at(ui, cx.rect),
};
// PLAN: assumed impl Add for TextureStatistics (pdf-canvas-w7)
let textures = thumbs.cache().statistics(&ctx) + details.cache().statistics(&ctx);
PaintSlot::reserve(&ui.painter_at(cx.rect)).extend(&ctx, bar_shapes);
let seen = Seen {
geo: drawn,
frame: drawn_frame,
view: shown,
pages,
visible,
current_changed: false,
scrolled,
pasteboard: Some(pasteboard),
textures,
next: None,
};
let pending =
Pending { started, state, mem, geo, want, bar_want, wheel_turned, pointer_zoom, started_on, space, edit: words.edit.as_str().to_owned() };
PaintSlot::reserve(&ui.painter_at(cx.rect)).extend(&ctx, pre_shapes);
Some((seen, pending))
let seen = Seen {
geo: drawn,
frame: drawn_frame,
view: shown,
pages,
visible,
current_changed: false,
scrolled,
pasteboard: Some(pasteboard),
textures,
next: None,
};
let pending =
Pending { started, state, mem, geo, want, bar_want, wheel_turned, pointer_zoom, started_on, space, edit: words.edit.as_str().to_owned() };
PaintSlot::reserve(&ui.painter_at(cx.rect)).extend(&ctx, pre_shapes);
Some((seen, pending))
})
}
+26 -14
View File
@@ -147,8 +147,15 @@ fn rig_with(
let mut now = kept.borrow().clone();
let offset = now.offset;
let keep = held.borrow().clone();
let shown =
PageView::new("Pages", &source, &mut now, PAPER).options(LayoutOptions::ACROBAT).navigation(navigation).keep(&keep).show_with(ui, &mut body, |ui, page, body| { body(ui, page); None }, |_, _, _| ());
let shown = PageView::new("Pages", &source, &mut now, PAPER).options(LayoutOptions::ACROBAT).navigation(navigation).keep(&keep).show_with(
ui,
&mut body,
|ui, page, body| {
body(ui, page);
None
},
|_, _, _| (),
);
let scrolled = seen.borrow().scrolled || shown.scrolled;
*seen.borrow_mut() =
Out { offset, rects: shown.layout.rects.clone(), pages: shown.pages, visible: shown.visible, view: shown.canvas.response.rect, scrolled };
@@ -1015,18 +1022,23 @@ fn hand_drag_places_pages_at_the_tools_view_in_the_same_pass() {
let (before_count, after_count) = (Rc::clone(&before_runs), Rc::clone(&after_runs));
let mut fixture = Fixture::new(move |ui| {
let mut target = None;
PageView::new("Pages", &source, &mut state, PAPER).show_with(ui, &mut target, |ui, body, target| {
before_count.set(before_count.get() + 1);
let reply = body.pass.map(|pass| ToolHost::new().run(ui, pass, &mut hand));
let view = reply.and_then(|reply| reply.view);
*target = view.and_then(|view| body.pages.first().map(|page| (view, body.view.to_doc(page.rect.min))));
view
}, |_, body, target| {
after_count.set(after_count.get() + 1);
if let (Some((view, point)), Some(page)) = (*target, body.pages.first()) {
*seen.borrow_mut() = Some((body.view, view, page.rect.min, point));
}
});
PageView::new("Pages", &source, &mut state, PAPER).show_with(
ui,
&mut target,
|ui, body, target| {
before_count.set(before_count.get() + 1);
let reply = body.pass.map(|pass| ToolHost::new().run(ui, pass, &mut hand));
let view = reply.and_then(|reply| reply.view);
*target = view.and_then(|view| body.pages.first().map(|page| (view, body.view.to_doc(page.rect.min))));
view
},
|_, body, target| {
after_count.set(after_count.get() + 1);
if let (Some((view, point)), Some(page)) = (*target, body.pages.first()) {
*seen.borrow_mut() = Some((body.view, view, page.rect.min, point));
}
},
);
});
fixture.room(vec2(900.0, 600.0));
fixture.settle();
+7 -1
View File
@@ -408,7 +408,13 @@ pub fn canvas_space(env: &EnvView<'_>) -> Option<CanvasSpace> {
/// Runs `body` with `space` as the canvas space inherited by its controls.
pub fn with_canvas_space<R>(ui: &mut egui::Ui, space: CanvasSpace, body: impl FnOnce(&mut egui::Ui) -> R) -> R {
crate::runtime::env::with_env(ui, |overrides| { overrides.values.set(InCanvas(Some(space))); }, body)
crate::runtime::env::with_env(
ui,
|overrides| {
overrides.values.set(InCanvas(Some(space)));
},
body,
)
}
/// The text of one axis' ruler units: its tick maths with the unit kind it is written in, over `Units` (the one
+44 -17
View File
@@ -211,7 +211,10 @@ fn end_skips_the_items_of_a_closed_group() {
#[trial]
fn unused_moves_reach_the_regions_collection_in_either_declaration_order() {
use craft_ui::contract::{Show as _, ShowContainer as _};
use craft_ui_test_kit::{body::Slab, contract::{Probe as Button, Seen as ButtonSeen}};
use craft_ui_test_kit::{
body::Slab,
contract::{Probe as Button, Seen as ButtonSeen},
};
for collection_first in [false, true] {
let (seen, layout) = (Seen::default(), Ragged { rows: vec![3, 2], hidden_from: 5 });
let source = Count(5);
@@ -223,12 +226,21 @@ fn unused_moves_reach_the_regions_collection_in_either_declaration_order() {
in_region(ui, Rect::from_min_size(ORIGIN, VIEW), |ui| {
Slab::new(ContainerProps::new().fallback_collection(list_id)).show(ui, |ui, _| {
let list = |ui: &mut Ui| {
seen.take(Probe::new(CollectionProps::new().select(SelectMode::Single), layout.clone(), &seen.digits)
.id(list_id).show_items(ui, &source, &mut |_, _| Row::new()));
seen.take(
Probe::new(CollectionProps::new().select(SelectMode::Single), layout.clone(), &seen.digits).id(list_id).show_items(
ui,
&source,
&mut |_, _| Row::new(),
),
);
};
if collection_first { list(ui); }
if collection_first {
list(ui);
}
Button::new(&button_seen).id(button_id).show(ui);
if !collection_first { list(ui); }
if !collection_first {
list(ui);
}
});
});
};
@@ -253,16 +265,26 @@ impl Component for MoveControl<'_> {
type Style = PlainStyle;
type Output = egui::Response;
fn style(_: &StyleCx<'_>, _: MoveControlStyleKey) -> PlainStyle { PlainStyle::default() }
fn style(_: &StyleCx<'_>, _: MoveControlStyleKey) -> PlainStyle {
PlainStyle::default()
}
fn keys(&self) -> craft_ui::runtime::focus::KeyUse {
craft_ui::runtime::focus::KeyUse::of(craft_behavior::Input::Pointer).with_moves()
}
fn measure(&mut self, _: &craft_ui::contract::MeasureCx<'_, Self>) -> Vec2 { TILE }
fn sense(&self) -> craft_behavior::Sense { craft_behavior::Sense::CLICK | craft_behavior::Sense::FOCUS }
fn measure(&mut self, _: &craft_ui::contract::MeasureCx<'_, Self>) -> Vec2 {
TILE
}
fn sense(&self) -> craft_behavior::Sense {
craft_behavior::Sense::CLICK | craft_behavior::Sense::FOCUS
}
fn update(&mut self, cx: &mut Cx<'_, Self>) {
while cx.intents().take_move().is_some() { self.taken.set(self.taken.get() + 1); }
while cx.intents().take_move().is_some() {
self.taken.set(self.taken.get() + 1);
}
}
fn finish(self, cx: Cx<'_, Self>) -> Self::Output {
cx.response.clone()
}
fn finish(self, cx: Cx<'_, Self>) -> Self::Output { cx.response.clone() }
}
#[trial]
@@ -275,13 +297,18 @@ fn a_focused_control_keeps_the_moves_it_uses_before_the_fallback() {
let list_id = Id::unique("fallback first refusal list");
let control_id = Id::unique("fallback first refusal control");
let mut frames = Frames::new();
let mut show = |ui: &mut Ui| in_region(ui, Rect::from_min_size(ORIGIN, VIEW), |ui| {
Slab::new(ContainerProps::new().fallback_collection(list_id)).show(ui, |ui, _| {
MoveControl { common: Common::new(), taken: &taken }.id(control_id).show(ui);
seen.take(Probe::new(CollectionProps::new().select(SelectMode::Single), layout.clone(), &seen.digits)
.id(list_id).show_items(ui, &source, &mut |_, _| Row::new()));
});
});
let mut show = |ui: &mut Ui| {
in_region(ui, Rect::from_min_size(ORIGIN, VIEW), |ui| {
Slab::new(ContainerProps::new().fallback_collection(list_id)).show(ui, |ui, _| {
MoveControl { common: Common::new(), taken: &taken }.id(control_id).show(ui);
seen.take(Probe::new(CollectionProps::new().select(SelectMode::Single), layout.clone(), &seen.digits).id(list_id).show_items(
ui,
&source,
&mut |_, _| Row::new(),
));
});
})
};
frames.idle(3, &mut show);
request(&frames.ctx, FocusTarget::Id(control_id));
frames.idle(2, &mut show);
@@ -14,8 +14,7 @@ const BACKGROUND: PartKey = PartKey::new("background");
#[trial]
fn active_part_survives_a_drag_outside_its_shape() {
let area = rect(100.0, 100.0, 80.0, 80.0);
let root = ProbeRoot::new("active-part", area, Sense::empty())
.part(ProbePart::new(BACKGROUND, area, Sense::DRAG));
let root = ProbeRoot::new("active-part", area, Sense::empty()).part(ProbePart::new(BACKGROUND, area, Sense::DRAG));
let (mut show_frame, _) = scene(vec![root]);
let mut frames = Frames::new();
frames.idle(2, &mut show_frame);