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

@@ -15,10 +15,10 @@ pub struct TextEdit {
impl TextEdit {
pub fn region(&self) -> UiRegion {
UiRegion::from_size_align(
self.tex().map(|t| t.size()).unwrap_or(Vec2::ZERO),
self.align,
)
self.tex()
.map(|t| t.size())
.unwrap_or(Vec2::ZERO)
.align(self.align)
}
pub fn content(&self) -> String {
@@ -44,7 +44,7 @@ impl Widget for TextEdit {
let size = vec2(1, self.attrs.line_height);
painter.primitive_within(
RectPrimitive::color(Color::WHITE),
UiRegion::from_size_align(size, Align::TopLeft)
size.align(Align::TOP_LEFT)
.offset(offset)
.within(&region),
);
@@ -205,7 +205,7 @@ impl<'a> TextEditCtx<'a> {
}
pub fn select(&mut self, pos: Vec2, size: Vec2) {
let pos = pos - self.text.region().top_left.to_abs(size);
let pos = pos - self.text.region().top_left().to_abs(size);
self.text.cursor = self.text.buf.hit(pos.x, pos.y);
}