handles (tuple)
This commit is contained in:
@@ -26,6 +26,8 @@ pub struct WidgetView<W: ?Sized = dyn Widget> {
|
||||
ty: *const W,
|
||||
}
|
||||
|
||||
pub type WidgetHandles<W> = (WidgetHandle<W>, WidgetView<W>);
|
||||
|
||||
impl<W: Widget + ?Sized + Unsize<dyn Widget>> WidgetHandle<W> {
|
||||
pub fn any(self) -> WidgetHandle<dyn Widget> {
|
||||
self
|
||||
@@ -60,7 +62,7 @@ impl<W: ?Sized> WidgetHandle<W> {
|
||||
WidgetView { ty, id }
|
||||
}
|
||||
|
||||
pub fn handles(self) -> (Self, WidgetView<W>) {
|
||||
pub fn handles(self) -> WidgetHandles<W> {
|
||||
let weak = self.weak();
|
||||
(self, weak)
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use super::*;
|
||||
use std::marker::Unsize;
|
||||
|
||||
pub trait WidgetLike<Tag> {
|
||||
pub trait WidgetLike<Tag>: Sized {
|
||||
type Widget: Widget + ?Sized + Unsize<dyn Widget> + 'static;
|
||||
|
||||
fn add(self, ui: &mut Ui) -> WidgetHandle<Self::Widget>;
|
||||
@@ -9,22 +9,20 @@ pub trait WidgetLike<Tag> {
|
||||
fn with_id<W2>(
|
||||
self,
|
||||
f: impl FnOnce(&mut Ui, WidgetHandle<Self::Widget>) -> WidgetHandle<W2>,
|
||||
) -> impl WidgetIdFn<W2>
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
) -> impl WidgetIdFn<W2> {
|
||||
move |ui| {
|
||||
let id = self.add(ui);
|
||||
f(ui, id)
|
||||
}
|
||||
}
|
||||
|
||||
fn set_root(self, ui: &mut Ui)
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
fn set_root(self, ui: &mut Ui) {
|
||||
ui.set_root(self);
|
||||
}
|
||||
|
||||
fn handles(self, ui: &mut Ui) -> WidgetHandles<Self::Widget> {
|
||||
self.add(ui).handles()
|
||||
}
|
||||
}
|
||||
|
||||
pub trait WidgetArrLike<const LEN: usize, Tag> {
|
||||
|
||||
Reference in New Issue
Block a user