Ask each child once and place its answer by re-expression
A widget draws in the box it is asked in and its answer is placed inside that box by re-expressing the drawing; nothing is drawn again in a box an answer chose. The offer machinery, whose job was to tell a measuring draw from a placing one, goes with the placing draw. A span measures each child from its cursor and moves fixed children to their slots with place_at; a share child is asked once more in its decided slot with its frame narrowed to it. A stack asks non-sizing children in the box its sizing child decided. A scroll asks its content once and moves it to the scrolled offset. A local redraw asks the retained question again and puts the answer back where the parent placed it. A symbolic length a child pinned composes through Part::Of exactly where the part is the whole box less pixels, and pins the parent's own length otherwise; dropping it let a pad reuse a drawing across a narrowed frame of the same pixel length (shrinker seeds 60, 248 and 384 at depth 5). Suite 114/114 including the two decided-box pins, fast oracle 11/11, shrinker 400 seeds at depth 5 over all fifteen cases. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
4328eac756
commit
3091fb86df
12 files changed
+353
-354
No files matched your search
@@ -12,10 +12,9 @@ pub struct Scroll {
|
||||
impl Widget for Scroll {
|
||||
fn draw(&mut self, painter: &mut Painter) -> Size {
|
||||
let container_len = painter.px_len(self.axis);
|
||||
// Measured in the whole viewport, then drawn at the scrolled offset.
|
||||
let whole = UiRegion::FULL;
|
||||
// Asked in the whole viewport, then put at the scrolled offset.
|
||||
let answer_len = painter
|
||||
.widget_at(&self.inner, whole, [Place::Fill(Part::All); 2])
|
||||
.widget_at(&self.inner, [None; 2], [Place::Fill(Part::All); 2])
|
||||
.len(self.axis);
|
||||
let fixed = Len::from_parts(answer_len.rel, answer_len.px).to_px(container_len);
|
||||
self.container_len = container_len;
|
||||
@@ -59,11 +58,10 @@ impl Widget for Scroll {
|
||||
}
|
||||
// The viewport is the inner's frame, so a fraction it declares or
|
||||
// reports is a fraction of what is on screen rather than of the
|
||||
// content box its own answer decided. Where it is drawn is the
|
||||
// content box, scrolled.
|
||||
painter.widget_at(
|
||||
// content box its own answer decided. Where it goes is the content
|
||||
// box, scrolled: its drawing moved there, not made again there.
|
||||
painter.place_at(
|
||||
&self.inner,
|
||||
whole,
|
||||
self.axis
|
||||
.pair(Place::Fill(Part::From(content)), Place::Fill(Part::All)),
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user