diff --git a/src/random.rs b/src/random.rs index b792266..b761532 100644 --- a/src/random.rs +++ b/src/random.rs @@ -122,11 +122,21 @@ impl Widget for Branch { let measured = painter .widget_at(&self.probe, [None; 2], [Place::Within(Part::All), top]) .len(Axis::X); - let px = painter.to_px(measured.apply_leftover(), Axis::X); + let len = measured.apply_leftover(); + let px = painter.to_px(len, Axis::X); + // The range it actually branched on, said the way a container says + // one: pinning the window instead would redraw this widget on every + // resize, which is a fixture that never exercises reuse. + let threshold = Px::from_f32(self.threshold); + let holds = match px > threshold { + true => Holds::from(threshold + Px::STEP..=Px::MAX), + false => Holds::from(Px::MIN..=threshold), + }; + painter.window_holds(Axis::X, holds.through(len)); let below = Place::Within(Part::From(UiSpan::new(cut, painter.extent_len(Axis::Y)))); let place = [Place::Within(Part::All), below]; - match px > Px::from_f32(self.threshold) { + match px > threshold { true => painter.widget_at(&self.wide, [None; 2], place), false => painter.widget_at(&self.narrow, [None; 2], place), };