app work
This commit is contained in:
@@ -141,6 +141,9 @@ pub struct IdFnTag;
|
||||
pub trait WidgetIdFn<W>: FnOnce(&mut Ui) -> WidgetId<W> {}
|
||||
impl<W, F: FnOnce(&mut Ui) -> WidgetId<W>> WidgetIdFn<W> for F {}
|
||||
|
||||
pub trait WidgetRet: FnOnce(&mut Ui) -> WidgetId<AnyWidget> {}
|
||||
impl<F: FnOnce(&mut Ui) -> WidgetId<AnyWidget>> WidgetRet for F {}
|
||||
|
||||
impl<W: 'static> WidgetLike<IdTag> for WidgetId<W> {
|
||||
type Widget = W;
|
||||
fn add(self, _: &mut Ui) -> WidgetId<W> {
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
use crate::layout::{Len, Painter, SizeCtx, StaticWidgetId, Ui, WidgetId, WidgetIdFn};
|
||||
use crate::{
|
||||
core::WidgetPtr,
|
||||
layout::{Len, Painter, SizeCtx, StaticWidgetId, Ui, WidgetId, WidgetIdFn},
|
||||
};
|
||||
|
||||
use std::{any::Any, marker::PhantomData};
|
||||
|
||||
@@ -48,6 +51,12 @@ pub trait WidgetLike<Tag> {
|
||||
{
|
||||
ui.set_root(self);
|
||||
}
|
||||
fn set_ptr(self, ptr: &WidgetId<WidgetPtr>, ui: &mut Ui)
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
ui[ptr].inner = Some(self.add(ui).any());
|
||||
}
|
||||
}
|
||||
|
||||
/// A function that returns a widget given a UI.
|
||||
|
||||
Reference in New Issue
Block a user