FIX SIZE CACHE
This commit is contained in:
1 parent
ecbb9e56e2
commit
1363f31fcd
9 files changed
+144
-178
No files matched your search
+14
-1
@@ -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