remove context generic
This commit is contained in:
@@ -1,25 +1,21 @@
|
||||
use crate::prelude::*;
|
||||
|
||||
pub trait Sensable<W, Ctx, Tag> {
|
||||
fn on(self, sense: Sense, f: impl SenseFn<Ctx>) -> WidgetIdFnRet!(W, Ctx);
|
||||
pub trait Sensable<W, Tag> {
|
||||
fn on(self, sense: Sense, f: impl SenseFn) -> WidgetIdFnRet!(W);
|
||||
fn id_on(
|
||||
self,
|
||||
sense: Sense,
|
||||
f: impl FnMut(&WidgetId<W>, SenseCtx<Ctx>) + 'static + Clone,
|
||||
) -> WidgetIdFnRet!(W, Ctx)
|
||||
f: impl FnMut(&WidgetId<W>, &mut Ui) + 'static + Clone,
|
||||
) -> WidgetIdFnRet!(W)
|
||||
where
|
||||
W: Widget<Ctx>;
|
||||
fn edit_on(
|
||||
self,
|
||||
sense: Sense,
|
||||
f: impl FnMut(&mut W, &mut Ctx) + 'static + Clone,
|
||||
) -> WidgetIdFnRet!(W, Ctx)
|
||||
W: Widget;
|
||||
fn edit_on(self, sense: Sense, f: impl FnMut(&mut W) + 'static + Clone) -> WidgetIdFnRet!(W)
|
||||
where
|
||||
W: Widget<Ctx>;
|
||||
W: Widget;
|
||||
}
|
||||
|
||||
impl<W: WidgetLike<Ctx, Tag>, Ctx, Tag> Sensable<W::Widget, Ctx, Tag> for W {
|
||||
fn on(self, sense: Sense, f: impl SenseFn<Ctx>) -> WidgetIdFnRet!(W::Widget, Ctx) {
|
||||
impl<W: WidgetLike<Tag>, Tag> Sensable<W::Widget, Tag> for W {
|
||||
fn on(self, sense: Sense, f: impl SenseFn) -> WidgetIdFnRet!(W::Widget) {
|
||||
move |ui| {
|
||||
let id = self.add(ui);
|
||||
ui.add_sensor(
|
||||
@@ -35,10 +31,10 @@ impl<W: WidgetLike<Ctx, Tag>, Ctx, Tag> Sensable<W::Widget, Ctx, Tag> for W {
|
||||
fn id_on(
|
||||
self,
|
||||
sense: Sense,
|
||||
mut f: impl FnMut(&WidgetId<W::Widget>, SenseCtx<Ctx>) + 'static + Clone,
|
||||
) -> WidgetIdFnRet!(W::Widget, Ctx)
|
||||
mut f: impl FnMut(&WidgetId<W::Widget>, &mut Ui) + 'static + Clone,
|
||||
) -> WidgetIdFnRet!(W::Widget)
|
||||
where
|
||||
W::Widget: Widget<Ctx>,
|
||||
W::Widget: Widget,
|
||||
{
|
||||
self.with_id(move |ui, id| {
|
||||
let id2 = id.clone();
|
||||
@@ -48,11 +44,11 @@ impl<W: WidgetLike<Ctx, Tag>, Ctx, Tag> Sensable<W::Widget, Ctx, Tag> for W {
|
||||
fn edit_on(
|
||||
self,
|
||||
sense: Sense,
|
||||
mut f: impl FnMut(&mut W::Widget, &mut Ctx) + 'static + Clone,
|
||||
) -> WidgetIdFnRet!(W::Widget, Ctx)
|
||||
mut f: impl FnMut(&mut W::Widget) + 'static + Clone,
|
||||
) -> WidgetIdFnRet!(W::Widget)
|
||||
where
|
||||
W::Widget: Widget<Ctx>,
|
||||
W::Widget: Widget,
|
||||
{
|
||||
self.id_on(sense, move |id, ctx| f(&mut ctx.ui[id], ctx.app))
|
||||
self.id_on(sense, move |id, ui| f(&mut ui[id]))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user