crop text images that are too big

This commit is contained in:
2025-11-21 18:18:28 -05:00
parent 97b284e81e
commit 23c5abe5a9
7 changed files with 97 additions and 79 deletions

View File

@@ -33,9 +33,7 @@ impl TextEdit {
impl Widget for TextEdit {
fn draw(&mut self, painter: &mut Painter) {
let tex = self.view.draw(&mut painter.size_ctx());
let region = text_region(&tex, self.align);
painter.texture_within(&tex.handle, region);
let region = self.view.draw(painter);
if let Some(cursor) = &self.cursor
&& let Some(offset) = cursor_pos(cursor, &self.buf)
@@ -49,11 +47,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.render(ctx).size.x)
}
fn desired_height(&mut self, ctx: &mut SizeCtx) -> Len {
Len::abs(self.view.draw(ctx).size.y)
Len::abs(self.view.render(ctx).size.y)
}
}