tfix-harness: Frames over a caller's context keep its clock; an unmeasured end region spans the line's own edges

This commit is contained in:
aiongg
2026-11-15 14:30:06 +00:00
parent 2bc5fd1782
commit b01de193b9
2 changed files with 15 additions and 7 deletions
@@ -426,13 +426,15 @@ impl<'b> BodyHooks<'b> {
});
let taken = measured.unwrap_or(0.0);
let cut = if taken > 0.0 { taken + self.end_gap + self.rules.end } else { 0.0 };
let end_w = measured.unwrap_or(width);
let end_bottom = if full { footer_top + across_h } else { footer_top };
let mut end = if rtl {
Rect::from_min_max(Pos2::new(left, top), Pos2::new(left + end_w, end_bottom.max(top)))
} else {
Rect::from_min_max(Pos2::new(right - end_w, top), Pos2::new(right, end_bottom.max(top)))
// The line's own edges before the first measure: a line of unbounded room (a content-sized container measured
// in an unbounded flow) has no finite width to take from its other edge.
let (end_left, end_right) = match measured {
None => (left, right),
Some(end_w) if rtl => (left, left + end_w),
Some(end_w) => (right - end_w, right),
};
let mut end = Rect::from_min_max(Pos2::new(end_left, top), Pos2::new(end_right, end_bottom.max(top)));
if rtl {
body.min.x = (body.min.x + cut).min(body.max.x);
} else {
+8 -2
View File
@@ -187,7 +187,7 @@ impl Frames {
/// One frame with no events; returns the shapes it painted, nested shapes flattened.
pub fn frame_shapes(&mut self, mut ui: impl FnMut(&mut Ui)) -> Vec<egui::Shape> {
set_input(&self.ctx, self.input());
self.time += DT;
self.tick();
fixture::run_frame_shapes(&self.ctx, self.time, self.screen, &mut ui)
}
@@ -235,8 +235,14 @@ impl Frames {
}
}
/// Moves the clock on one frame from the later of its own time and the context's, so frames over a context the
/// caller also drives (an app's own, which another harness ran between these frames) never take its time back.
fn tick(&mut self) {
self.time = self.time.max(self.ctx.input(|i| i.time)) + DT;
}
fn run(&mut self, viewport: egui::ViewportId, mut events: Vec<Event>, ui: impl FnMut(&mut Ui)) -> bool {
self.time += DT;
self.tick();
if self.told != self.modifiers {
self.told = self.modifiers;
events.insert(0, fixture::modifiers_changed(self.modifiers));