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

+1 -1
View File
@@ -19,7 +19,7 @@ impl Widget for MaxSize {
fn capped(len: Len, max: Option<Len>, output: f32) -> Len {
match max {
Some(max) if len.apply_rest().to_abs(output) > max.apply_rest().to_abs(output) => max,
Some(max) if len.apply_rest().to_px(output) > max.apply_rest().to_px(output) => max,
_ => len,
}
}
+6 -6
View File
@@ -12,11 +12,11 @@ impl Widget for Pad {
.size();
Size {
x: Len {
abs: inner.x.abs + self.padding.left + self.padding.right,
px: inner.x.px + self.padding.left + self.padding.right,
..inner.x
},
y: Len {
abs: inner.y.abs + self.padding.top + self.padding.bottom,
px: inner.y.px + self.padding.top + self.padding.bottom,
..inner.y
},
}
@@ -55,10 +55,10 @@ impl Padding {
}
pub fn region(&self) -> UiRegion {
let mut region = UiRegion::FULL;
region.x.start.abs += self.left;
region.y.start.abs += self.top;
region.x.end.abs -= self.right;
region.y.end.abs -= self.bottom;
region.x.start.px += self.left;
region.y.start.px += self.top;
region.x.end.px -= self.right;
region.y.end.px -= self.bottom;
region
}
pub fn x(amt: impl UiNum) -> Self {
+3 -3
View File
@@ -12,7 +12,7 @@ pub struct Scroll {
impl Widget for Scroll {
fn draw(&mut self, painter: &mut Painter) -> Size {
let output_len = painter.output_len(self.axis);
let container_len = UiScalar::abs(painter.px_len(self.axis));
let container_len = UiScalar::px(painter.px_len(self.axis));
// Draw in the whole container only when its scrolling-axis length is
// not already known, then place it at the scrolled offset.
let known_len = painter.known_len(&self.inner, self.axis, UiRegion::FULL);
@@ -22,8 +22,8 @@ impl Widget for Scroll {
.unwrap_or_else(|| child.unwrap().axis(self.axis))
.apply_rest()
.within_len(container_len)
.to_abs(output_len);
self.container_len = container_len.to_abs(output_len);
.to_px(output_len);
self.container_len = container_len.to_px(output_len);
self.content_len = content_len;
if self.snap_end {
+6 -6
View File
@@ -24,13 +24,13 @@ impl Widget for Span {
Some(len) => len,
None => painter.place(child, region).len(axis),
};
cursor.abs += len.abs + self.gap;
cursor.px += len.px + self.gap;
cursor.rel += len.rel;
lens.push(len);
}
let gap = self.gap * self.children.len().saturating_sub(1) as f32;
let total = lens.iter().fold(Len::abs(gap), |sum, len| sum + *len);
let total = lens.iter().fold(Len::px(gap), |sum, len| sum + *len);
let mut start = UiScalar::rel_min();
let mut ortho = Len::ZERO;
@@ -38,12 +38,12 @@ impl Widget for Span {
let mut span = UiSpan::FULL;
span.start = start;
if len.rest > 0.0 {
let offset = UiScalar::new(total.rel, total.abs);
let offset = UiScalar::new(total.rel, total.px);
let rel_end = UiScalar::rel(len.rest / total.rest);
let end = (UiScalar::rel_max() + start) - offset;
start = rel_end.within(&start.to(end));
}
start.abs += len.abs;
start.px += len.px;
start.rel += len.rel;
span.end = start;
let mut region = UiRegion::from_axis(axis, span, UiSpan::FULL);
@@ -55,9 +55,9 @@ impl Widget for Span {
if used.rel > 0.0 || used.rest > 0.0 {
ortho = Len::REST;
} else if ortho.rest == 0.0 {
ortho.abs = ortho.abs.max(used.abs);
ortho.px = ortho.px.max(used.px);
}
start.abs += self.gap;
start.px += self.gap;
}
let along = match total.rest == 0.0 && total.rel == 0.0 {