`Place` was a product written as a sum -- a `Part` and a fill flag -- and `Part` named three operations the geometry already had, under words that did not match them. `Of` was `UiSpan::within`, `From` was `UiSpan::shift`, and `Sized` was `placement`'s own body with the length given rather than reported. Both enums are gone. `PlaceDescAxis` says one axis, named after the operation it performs: `within`, `shifted`, `sized`, and `WHOLE`. What is optional is a builder -- `fills` and `rel_base` -- so a caller writes only what it decided, and the rel base it does not write follows the constructor: a span composed into the caller's box narrows it, a span along a cursor does not, a decided length is it. That was the one rule a caller could get wrong with nothing failing. `PlaceDesc` says both axes with named fields, so `axis`, `axis_mut` and `from_axis` work the way they do on every other pair here, and the joint work -- resolving a region, reading the fill flags -- is written once rather than per axis. `widget_at` and `place_at` take `impl Into<PlaceDesc>`, so a wrapper passes a `UiRegion` and says nothing else. `widget_within` and `ActiveData::narrow_rel_base` are deleted; `asked` and `placed` carry the rel base their ask stated. Cold layout is byte-identical to `84dad21`.
15 lines
291 B
Rust
15 lines
291 B
Rust
use crate::prelude::*;
|
|
|
|
pub struct Offset {
|
|
pub inner: StrongWidget,
|
|
pub amt: UiVec2,
|
|
}
|
|
|
|
impl Widget for Offset {
|
|
fn draw(&mut self, painter: &mut Painter) -> Size {
|
|
painter
|
|
.widget_at(&self.inner, UiRegion::FULL.offset(self.amt))
|
|
.size()
|
|
}
|
|
}
|