preparation
This commit is contained in:
1 parent
15cc91d92a
commit
709a2d0e17
14 files changed
+292
-220
No files matched your search
+15
-11
@@ -1,21 +1,25 @@
|
||||
use crate::prelude::*;
|
||||
|
||||
pub trait Sensable<W, Tag> {
|
||||
fn on(self, sense: Senses, f: impl SenseFn) -> WidgetIdFn!(W);
|
||||
fn on(self, sense: Senses, f: impl SenseFn) -> impl WidgetIdFn<W>;
|
||||
fn id_on(
|
||||
self,
|
||||
senses: Senses,
|
||||
f: impl FnMut(&WidgetId<W>, &mut Ui) + 'static + Clone,
|
||||
) -> WidgetIdFn!(W)
|
||||
f: impl FnMut(&WidgetId<W>, &mut Ui, SenseCtx) + 'static,
|
||||
) -> impl WidgetIdFn<W>
|
||||
where
|
||||
W: Widget;
|
||||
fn edit_on(self, senses: Senses, f: impl FnMut(&mut W) + 'static + Clone) -> WidgetIdFn!(W)
|
||||
fn edit_on(
|
||||
self,
|
||||
senses: Senses,
|
||||
f: impl FnMut(&mut W, SenseCtx) + 'static,
|
||||
) -> impl WidgetIdFn<W>
|
||||
where
|
||||
W: Widget;
|
||||
}
|
||||
|
||||
impl<W: WidgetLike<Tag>, Tag> Sensable<W::Widget, Tag> for W {
|
||||
fn on(self, senses: Senses, f: impl SenseFn) -> WidgetIdFn!(W::Widget) {
|
||||
fn on(self, senses: Senses, f: impl SenseFn) -> impl WidgetIdFn<W::Widget> {
|
||||
move |ui| {
|
||||
let id = self.add(ui);
|
||||
ui.add_sensor(
|
||||
@@ -31,24 +35,24 @@ impl<W: WidgetLike<Tag>, Tag> Sensable<W::Widget, Tag> for W {
|
||||
fn id_on(
|
||||
self,
|
||||
senses: Senses,
|
||||
mut f: impl FnMut(&WidgetId<W::Widget>, &mut Ui) + 'static + Clone,
|
||||
) -> WidgetIdFn!(W::Widget)
|
||||
mut f: impl FnMut(&WidgetId<W::Widget>, &mut Ui, SenseCtx) + 'static,
|
||||
) -> impl WidgetIdFn<W::Widget>
|
||||
where
|
||||
W::Widget: Widget,
|
||||
{
|
||||
self.with_id(move |ui, id| {
|
||||
let id2 = id.clone();
|
||||
ui.add(id.on(senses, move |ui| f(&id2, ui)))
|
||||
ui.add(id.on(senses, move |ui, pos| f(&id2, ui, pos)))
|
||||
})
|
||||
}
|
||||
fn edit_on(
|
||||
self,
|
||||
senses: Senses,
|
||||
mut f: impl FnMut(&mut W::Widget) + 'static + Clone,
|
||||
) -> WidgetIdFn!(W::Widget)
|
||||
mut f: impl FnMut(&mut W::Widget, SenseCtx) + 'static,
|
||||
) -> impl WidgetIdFn<W::Widget>
|
||||
where
|
||||
W::Widget: Widget,
|
||||
{
|
||||
self.id_on(senses, move |id, ui| f(&mut ui[id]))
|
||||
self.id_on(senses, move |id, ui, pos| f(&mut ui[id], pos))
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user