Decide reuse on the box a widget drew against, in pixels
Two holes the random trees found, both of which kept a wrapping text shaped for a width it no longer had. **A region is a fraction of a slot's box, so an unchanged region is not an unchanged box.** `try_reuse` compared regions, and a child drawn at `UiRegion::FULL` of a slot whose box had just halved compared equal to itself and was reused without being descended into. `ActiveData` now keeps the pixel size of the box it drew against and the comparison is against that, which is the question that was being asked all along and is right through a slot change and an output resize alike. **A size the parent learnt by drawing the child is an answer for that box only.** The walk looking for what cannot survive a length change skipped a child whose own box was a fixed width -- correctly, its box does not change -- but that width was what the child reported when the span drew it in the span's box, and the span's box did change. So a child whose size the widget read is redrawn unless it declares an exact `size_hint` for the changed axis, which is the one case the parent did not have to draw it to know. The cost is that a size-reading container gives up its reuse when its box changes length, which is every span, so `OnResize::Scale` now earns its keep on moves and on subtrees whose sizes nobody read rather than on every stretch. Correct first; `replace_cost` still measures the case the chain was built for. `tests/generated.rs` is what found both and what says they are fixed: 90 of 90 warm trees now land where a cold build does, against 83 before this commit and 83 on `db1751f`. The ignored sweep agrees over 300 checks on 100 seeds. `a_fixed_length_child_is_not_redrawn_when_the_box_around_it_grows` became `a_declared_length_...`: the child now says its width, since a width the span measured is not one it may keep. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
86a7e8dfc3
commit
b0f9f046da
4 files changed
+65
-32
No files matched your search
@@ -1,4 +1,6 @@
|
||||
use crate::{LayerId, MaskIdx, MoveIdx, PrimitiveHandle, Size, TextureHandle, UiRegion, WidgetId};
|
||||
use crate::{
|
||||
LayerId, MaskIdx, MoveIdx, PrimitiveHandle, Size, TextureHandle, UiRegion, WidgetId, util::Vec2,
|
||||
};
|
||||
|
||||
/// important non rendering data for retained drawing
|
||||
#[derive(Debug)]
|
||||
@@ -7,6 +9,10 @@ pub struct ActiveData {
|
||||
pub region: UiRegion,
|
||||
/// What the widget said it used of `region`, the last time it drew.
|
||||
pub size: Size,
|
||||
/// The pixel size of the box it drew against. `region` alone cannot say:
|
||||
/// it is a fraction of a slot's box, and the same fraction of a box that
|
||||
/// has since changed is a different number of pixels.
|
||||
pub px: Vec2,
|
||||
pub parent: Option<WidgetId>,
|
||||
pub textures: Vec<TextureHandle>,
|
||||
pub primitives: Vec<PrimitiveHandle>,
|
||||
|
||||
Reference in new issue
Block a user