diff --git a/src/widgets/predrawn.rs b/src/widgets/predrawn.rs index e4f594a..f38166d 100644 --- a/src/widgets/predrawn.rs +++ b/src/widgets/predrawn.rs @@ -11,27 +11,32 @@ pub struct Predrawn { } impl Predrawn { - pub fn new>(inner: W, frame: &mut Frame) -> Result { + pub fn new>(inner: W, widthdb: &mut WidthDb) -> Result { let mut tmp_frame = Frame::default(); - tmp_frame.buffer.resize(frame.size()); - mem::swap(&mut frame.widthdb, &mut tmp_frame.widthdb); + let size = inner.size(widthdb, None, None)?; + tmp_frame.buffer.resize(size); + + mem::swap(widthdb, &mut tmp_frame.widthdb); inner.draw(&mut tmp_frame)?; - - mem::swap(&mut frame.widthdb, &mut tmp_frame.widthdb); + mem::swap(widthdb, &mut tmp_frame.widthdb); let buffer = tmp_frame.buffer; Ok(Self { buffer }) } - pub async fn new_async>(inner: W, frame: &mut Frame) -> Result { + pub async fn new_async>( + inner: W, + widthdb: &mut WidthDb, + ) -> Result { let mut tmp_frame = Frame::default(); - tmp_frame.buffer.resize(frame.size()); - mem::swap(&mut frame.widthdb, &mut tmp_frame.widthdb); + let size = inner.size(widthdb, None, None).await?; + tmp_frame.buffer.resize(size); + + mem::swap(widthdb, &mut tmp_frame.widthdb); inner.draw(&mut tmp_frame).await?; - - mem::swap(&mut frame.widthdb, &mut tmp_frame.widthdb); + mem::swap(widthdb, &mut tmp_frame.widthdb); let buffer = tmp_frame.buffer; Ok(Self { buffer })