store size in tex instead of bot_right

This commit is contained in:
2025-11-21 14:38:16 -05:00
parent c428de8fd5
commit 97b284e81e
5 changed files with 34 additions and 17 deletions

View File

@@ -16,7 +16,7 @@ pub struct TextEdit {
impl TextEdit {
pub fn region(&self) -> UiRegion {
self.tex()
.map(|t| t.size())
.map(|t| t.size)
.unwrap_or(Vec2::ZERO)
.align(self.align)
}
@@ -49,11 +49,11 @@ impl Widget for TextEdit {
}
fn desired_width(&mut self, ctx: &mut SizeCtx) -> Len {
Len::abs(self.view.draw(ctx).size().x)
Len::abs(self.view.draw(ctx).size.x)
}
fn desired_height(&mut self, ctx: &mut SizeCtx) -> Len {
Len::abs(self.view.draw(ctx).size().y)
Len::abs(self.view.draw(ctx).size.y)
}
}

View File

@@ -92,19 +92,19 @@ impl Widget for Text {
}
fn desired_width(&mut self, ctx: &mut SizeCtx) -> Len {
Len::abs(self.update_buf(ctx).size().x)
Len::abs(self.update_buf(ctx).size.x)
}
fn desired_height(&mut self, ctx: &mut SizeCtx) -> Len {
Len::abs(self.update_buf(ctx).size().y)
Len::abs(self.update_buf(ctx).size.y)
}
}
pub fn text_region(tex: &TextTexture, align: RegionAlign) -> UiRegion {
let tex_dims = tex.handle.size();
let mut region = tex.size().align(align);
region.x.start.abs += tex.top_left.x;
region.y.start.abs += tex.top_left.y;
let mut region = tex.size.align(align);
region.x.start.abs += tex.top_left_offset.x;
region.y.start.abs += tex.top_left_offset.y;
region.x.end.abs = region.x.start.abs + tex_dims.x;
region.y.end.abs = region.y.start.abs + tex_dims.y;
region