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
@@ -142,7 +142,7 @@ impl<Rsc: UiRsc + 'static> Grow<'_, Rsc> {
fn len(&mut self) -> Option<Len> {
match self.rng.below(4) {
0 => Some(Len::abs(20.0 + self.rng.below(180) as f32)),
0 => Some(Len::px(20.0 + self.rng.below(180) as f32)),
1 => Some(Len::REST),
_ => None,
}
+2 -2
View File
@@ -8,11 +8,11 @@ pub struct Image {
impl Widget for Image {
fn draw(&mut self, painter: &mut Painter) -> Size {
painter.primitive(&self.handle);
Size::abs(self.handle.size())
Size::px(self.handle.size())
}
fn size_hint(&self, axis: Axis) -> Option<Len> {
Some(Len::abs(self.handle.size().axis(axis)))
Some(Len::px(self.handle.size().axis(axis)))
}
fn on_resize(&self, _: Axis) -> OnResize {
+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 {
+1 -1
View File
@@ -280,7 +280,7 @@ impl<'a> TextEditCtx<'a> {
}
pub fn select(&mut self, pos: Vec2, size: Vec2, drag: bool, recent: bool) {
let pos = pos - self.text.region().top_left().to_abs(size);
let pos = pos - self.text.region().top_left().to_px(size);
let prev_sel = self.text.selection;
let prev_hit = self.text.double_hit;
+1 -1
View File
@@ -72,7 +72,7 @@ impl TextView {
let tex = self.render(painter);
let region = tex.size.align(align);
let size = Size::abs(tex.size);
let size = Size::px(tex.size);
let within = region.within(&painter.region());
painter.glyphs(tex, within);
(region, size)