Rename a length's abs component to px

`dp` is coming, and then `abs` says which of the two it is not. The
component has always been a pixel count, so the name that admits it is
the one that leaves room for a second unit beside it.

Mechanical: the field on `Len` and `UiScalar`, their constructors,
`to_abs`/`get_abs`, the matching WGSL struct member and the locals
composing it. Field order and types are unchanged, so the `Pod` layout
the shader reads is the same bytes. `f32::abs` is untouched.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
iris-aiandClaude Opus 5 committed 2026-09-14 22:29:20 -04:00
1 parent 3f7cd8251b
commit 7c50a3e51b
22 files changed
+120 -124

No files matched your search

+11 -11
View File
@@ -156,7 +156,7 @@ impl Widget for FromHint {
fn draw(&mut self, painter: &mut Painter) -> Size {
let len = painter.size_hint(&self.inner, Axis::Y).unwrap();
let mut region = UiRegion::FULL;
region.y.end = region.y.start.offset(len.abs);
region.y.end = region.y.start.offset(len.px);
painter.widget_within(&self.inner, region);
Size::REST
}
@@ -173,7 +173,7 @@ fn a_parent_that_only_read_a_hint_relays_out_when_the_hint_changes() {
h.set_root(parent);
assert_corners!(h, inner, (0, 0), (400, 80));
h.rsc[inner].y = Some(Len::abs(120));
h.rsc[inner].y = Some(Len::px(120));
h.frame();
assert_corners!(h, inner, (0, 0), (400, 120));
@@ -187,7 +187,7 @@ struct ReadsOutput {
impl Widget for ReadsOutput {
fn draw(&mut self, painter: &mut Painter) -> Size {
self.draws.set(self.draws.get() + 1);
Size::abs(painter.output_size() / 4.0)
Size::px(painter.output_size() / 4.0)
}
}
@@ -198,7 +198,7 @@ struct ReadsWidth {
impl Widget for ReadsWidth {
fn draw(&mut self, painter: &mut Painter) -> Size {
self.draws.set(self.draws.get() + 1);
Size::abs((painter.output_len(Axis::X) / 4.0, 20.0).into())
Size::px((painter.output_len(Axis::X) / 4.0, 20.0).into())
}
}
@@ -287,12 +287,12 @@ fn subpixel_box_changes_accumulate_from_the_last_draw() {
let settled = draws.get();
for width in [100.02, 100.04, 100.05] {
h.rsc[first].size.x = Len::abs(width);
h.rsc[first].size.x = Len::px(width);
h.frame();
assert_eq!(draws.get(), settled);
}
h.rsc[first].size.x = Len::abs(100.06);
h.rsc[first].size.x = Len::px(100.06);
h.frame();
assert_eq!(draws.get(), settled + 1);
}
@@ -342,13 +342,13 @@ fn a_change_two_levels_under_its_reader_still_reaches_it() {
// Every wrapper up to the outer pad read the size below it, so the outer
// pad is what draws again -- and the span it hands the box to is the same
// size as before, which is what lets a draw reuse its way past the leaf.
let (leaf, _) = counted(&mut h, Size::abs((100, 100).into()), OnResize::Redraw);
let (leaf, _) = counted(&mut h, Size::px((100, 100).into()), OnResize::Redraw);
let padded = leaf.pad(10).add(&mut h.rsc);
let below = rect(Color::RED).add(&mut h.rsc);
h.set_root((padded, below).span(Dir::DOWN).pad(12));
assert_corners!(h, below, (12, 132), (388, 388));
h.rsc[leaf].size = Size::abs((100, 200).into());
h.rsc[leaf].size = Size::px((100, 200).into());
h.frame();
assert_corners!(h, below, (12, 232), (388, 388));
@@ -387,7 +387,7 @@ fn stretching_a_subtree_carries_the_children_in_it() {
let settled = draws.get();
assert_corners!(h, inner, (0, 40), (400, 400));
h.rsc[first].y = Some(Len::abs(80));
h.rsc[first].y = Some(Len::px(80));
h.frame();
assert_eq!(
@@ -411,7 +411,7 @@ fn a_widened_row_redraws_what_reads_its_length_and_nothing_else() {
h.set_root((bar, row).span(Dir::RIGHT));
let (settled_wrap, settled_back) = (wrap_draws.get(), back_draws.get());
h.rsc[bar].x = Some(Len::abs(200));
h.rsc[bar].x = Some(Len::px(200));
h.frame();
// The span reads every child's size, so redrawing one takes the span
@@ -437,7 +437,7 @@ fn a_declared_length_child_is_not_redrawn_when_the_box_around_it_grows() {
h.set_root((bar, row).span(Dir::RIGHT));
let settled = draws.get();
h.rsc[bar].x = Some(Len::abs(200));
h.rsc[bar].x = Some(Len::px(200));
h.frame();
assert_eq!(draws.get(), settled, "its own length did not change");