Write a shared constant once, and stop a scroll placing its own content
Two findings from a sweep over the WGSL prelude and the position widgets, scoped against upstream/main atca2b4b2. `module_source` already builds each shader's preamble from iris_core's own constants, so the move-chain work's second copy of `MOVE_NONE` and `CHAIN_LIMIT` -- under "keep in step with iris_core::CHAIN_LIMIT" -- asked a reader by hand for what the mechanism beside it exists to do. Both are injected now, with `MASK_NONE` beside them replacing a bare literal, and the shader declares none of them. `Scroll`'s `content_len` is never less than its box, so `slack` and the `anchor` computed from it were always zero whatever the alignment: the framework centres short content by placing the answer in the whole box, and the comment credited arithmetic that could not have done it. The same belief guarded the fits-in-the-box contract with `align == NEG`, so at the default alignment -- the middle -- every box change redrew the scroll, measured as 1 widget against 0 at TOP_LEFT. `align` now has no reader at all. `UiSpan::translated` and `UiRegion::translated` are reachable only from each other and from nothing else. Format, clippy with and without layout-diagnostics, and the 131-test suite are clean. The cold dump over 400 depth-5 trees is byte-identical to1096c31, and all three seed scans pass: 400 at depth 5 in 69.07s, 1,000 at depth 6 in 169.29s, 2,000 at depth 4 in 300.75s. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1096c3167a
commit
b7b8d09e40
8 files changed
+63
-64
No files matched your search
@@ -22,6 +22,30 @@ use std::time::Instant;
|
||||
|
||||
const OUTPUT: (f32, f32) = (1920.0, 1200.0);
|
||||
|
||||
/// A scroll whose content fits is the same drawing in every box it still
|
||||
/// fits in, so a longer or shorter one relays out nothing. Where the content
|
||||
/// sits in that box is decided by placing its answer in the whole of it,
|
||||
/// which is a fraction of the box and holds at every length -- so the
|
||||
/// contract must not turn on the alignment. It did, and at the default
|
||||
/// alignment, which is the middle, every box change redrew the scroll.
|
||||
#[cfg(feature = "layout-diagnostics")]
|
||||
#[test]
|
||||
fn a_fitting_scroll_holds_for_every_box_its_content_fits_in() {
|
||||
use iris::core::layout_diagnostics as diag;
|
||||
|
||||
for align in [Align::TOP_LEFT, Align::CENTER, Align::BOT_RIGHT] {
|
||||
let mut harness = Harness::new((400, 200));
|
||||
let inner = rect(Color::RED).height(50).add(&mut harness.rsc);
|
||||
harness.set_root(inner.scrollable().align(align));
|
||||
harness.frame();
|
||||
let _ = diag::take();
|
||||
// Still far longer than the 50 the content needs.
|
||||
harness.resize((400, 180));
|
||||
harness.frame();
|
||||
assert_eq!(diag::take().distinct_widgets(), 0, "{align:?}");
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "layout-diagnostics")]
|
||||
#[test]
|
||||
fn a_selected_widget_retains_its_layout_events() {
|
||||
|
||||
Reference in new issue
Block a user