Make Widget::size like toss::AsyncWidget::size

This commit is contained in:
Joscha 2023-04-05 23:08:53 +02:00
parent 059ff94aef
commit ff9a16d8a3
21 changed files with 244 additions and 110 deletions

View file

@ -1,5 +1,5 @@
use async_trait::async_trait;
use toss::{Frame, Size};
use toss::{Frame, Size, WidthDb};
use super::{BoxedWidget, Widget};
@ -15,10 +15,15 @@ impl Layer {
#[async_trait]
impl Widget for Layer {
fn size(&self, frame: &mut Frame, max_width: Option<u16>, max_height: Option<u16>) -> Size {
async fn size(
&self,
widthdb: &mut WidthDb,
max_width: Option<u16>,
max_height: Option<u16>,
) -> Size {
let mut max_size = Size::ZERO;
for layer in &self.layers {
let size = layer.size(frame, max_width, max_height);
let size = layer.size(widthdb, max_width, max_height).await;
max_size.width = max_size.width.max(size.width);
max_size.height = max_size.height.max(size.height);
}