Resolve size using limits

This commit is contained in:
tarkah 2022-11-01 11:23:21 -07:00 committed by Jeremy Soller
parent 8efebfcd07
commit 9e389b629b
2 changed files with 7 additions and 2 deletions

View file

@ -105,6 +105,8 @@ where
) -> layout::Node {
let instant = Instant::now();
let limits = limits.width(Length::Shrink).height(Length::Shrink);
let shape = self.line.shape_opt().as_ref().unwrap();
//TODO: can we cache this?
@ -128,7 +130,7 @@ where
log::debug!("layout {:?} in {:?}", size, instant.elapsed());
layout::Node::new(size)
layout::Node::new(limits.resolve(size))
}
fn draw(

View file

@ -88,6 +88,8 @@ where
_renderer: &Renderer,
limits: &layout::Limits,
) -> layout::Node {
let limits = limits.width(Length::Fill).height(Length::Fill);
//TODO: allow lazy shape
let mut editor = self.editor.lock().unwrap();
editor.buffer.shape_until(i32::max_value());
@ -103,7 +105,8 @@ where
let height = layout_lines as f32 * editor.buffer.metrics().line_height as f32;
let size = Size::new(limits.max().width, height);
log::info!("size {:?}", size);
layout::Node::new(size)
layout::Node::new(limits.resolve(size))
}
fn mouse_interaction(