FIX SIZE CACHE
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user