FIX SIZE CACHE

This commit is contained in:
2025-12-17 00:09:20 -05:00
parent ecbb9e56e2
commit 1363f31fcd
9 changed files with 144 additions and 178 deletions

View File

@@ -1,4 +1,4 @@
use crate::{Len, Painter, SizeCtx, Ui};
use crate::{Axis, AxisT, Len, Painter, SizeCtx, Ui};
use std::any::Any;
mod data;
@@ -19,6 +19,19 @@ pub trait Widget<State>: Any {
fn desired_height(&mut self, ctx: &mut SizeCtx<State>) -> Len;
}
pub trait WidgetAxisFns<State> {
fn desired_len<A: AxisT>(&mut self, ctx: &mut SizeCtx<State>) -> Len;
}
impl<State, W: Widget<State> + ?Sized> WidgetAxisFns<State> for W {
fn desired_len<A: AxisT>(&mut self, ctx: &mut SizeCtx<State>) -> Len {
match A::get() {
Axis::X => self.desired_width(ctx),
Axis::Y => self.desired_height(ctx),
}
}
}
impl<State> Widget<State> for () {
fn draw(&mut self, _: &mut Painter<State>) {}
fn desired_width(&mut self, _: &mut SizeCtx<State>) -> Len {