the great orientation refactor (move to x & y UiScalars/Spans) + don't call full size in align

This commit is contained in:
2025-11-20 15:44:39 -05:00
parent 96ef0c529b
commit 6251c23d37
20 changed files with 832 additions and 578 deletions

View File

@@ -7,8 +7,32 @@ pub struct Aligned {
impl Widget for Aligned {
fn draw(&mut self, painter: &mut Painter) {
let region =
UiRegion::from_ui_size_align(painter.size(&self.inner).to_uivec2(), self.align);
let region = match self.align {
Align {
x: Some(x),
y: Some(y),
} => {
painter
.size(&self.inner)
.to_uivec2()
.align(RegionAlign { x, y })
}
Align {
x: Some(x),
y: None,
} => {
let x = painter.size_ctx().width(&self.inner).apply_rest().align(x);
UiRegion::new(x, UiSpan::FULL)
}
Align {
x: None,
y: Some(y),
} => {
let y = painter.size_ctx().height(&self.inner).apply_rest().align(y);
UiRegion::new(UiSpan::FULL, y)
}
Align { x: None, y: None } => UiRegion::FULL,
};
painter.widget_within(&self.inner, region);
}