[−][src]Struct druid::widget::LensWrap
A wrapper for its widget subtree to have access to a part of its parent's data.
Every widget in druid is instantiated with access to data of some
type; the root widget has access to the entire application data.
Often, a part of the widget hierarchy is only concerned with a part
of that data. The LensWrap
widget is a way to "focus" the data
reference down, for the subtree. One advantage is performance;
data changes that don't intersect the scope of the lens aren't
propagated.
Another advantage is generality and reuse. If a widget (or tree of widgets) is designed to work with some chunk of data, then with a lens that same code can easily be reused across all occurrences of that chunk within the application state.
This wrapper takes a Lens
as an argument, which is a specification
of a struct field, or some other way of narrowing the scope.
Implementations
impl<T, U, L, W> LensWrap<T, U, L, W>
[src]
pub fn new(inner: W, lens: L) -> LensWrap<T, U, L, W>
[src]
Wrap a widget with a lens.
When the lens has type Lens<T, U>
, the inner widget has data
of type U
, and the wrapped widget has data of type T
.
Trait Implementations
impl<T, U, L, W> Widget<T> for LensWrap<T, U, L, W> where
T: Data,
U: Data,
L: Lens<T, U>,
W: Widget<U>,
[src]
T: Data,
U: Data,
L: Lens<T, U>,
W: Widget<U>,
pub fn event(
&mut self,
ctx: &mut EventCtx<'_, '_>,
event: &Event,
data: &mut T,
env: &Env
)
[src]
&mut self,
ctx: &mut EventCtx<'_, '_>,
event: &Event,
data: &mut T,
env: &Env
)
pub fn lifecycle(
&mut self,
ctx: &mut LifeCycleCtx<'_, '_>,
event: &LifeCycle,
data: &T,
env: &Env
)
[src]
&mut self,
ctx: &mut LifeCycleCtx<'_, '_>,
event: &LifeCycle,
data: &T,
env: &Env
)
pub fn update(
&mut self,
ctx: &mut UpdateCtx<'_, '_>,
old_data: &T,
data: &T,
env: &Env
)
[src]
&mut self,
ctx: &mut UpdateCtx<'_, '_>,
old_data: &T,
data: &T,
env: &Env
)
pub fn layout(
&mut self,
ctx: &mut LayoutCtx<'_, '_>,
bc: &BoxConstraints,
data: &T,
env: &Env
) -> Size
[src]
&mut self,
ctx: &mut LayoutCtx<'_, '_>,
bc: &BoxConstraints,
data: &T,
env: &Env
) -> Size
pub fn paint(&mut self, ctx: &mut PaintCtx<'_, '_, '_>, data: &T, env: &Env)
[src]
pub fn id(&self) -> Option<WidgetId>
[src]
Auto Trait Implementations
impl<T, U, L, W> RefUnwindSafe for LensWrap<T, U, L, W> where
L: RefUnwindSafe,
T: RefUnwindSafe,
U: RefUnwindSafe,
W: RefUnwindSafe,
[src]
L: RefUnwindSafe,
T: RefUnwindSafe,
U: RefUnwindSafe,
W: RefUnwindSafe,
impl<T, U, L, W> Send for LensWrap<T, U, L, W> where
L: Send,
T: Send,
U: Send,
W: Send,
[src]
L: Send,
T: Send,
U: Send,
W: Send,
impl<T, U, L, W> Sync for LensWrap<T, U, L, W> where
L: Sync,
T: Sync,
U: Sync,
W: Sync,
[src]
L: Sync,
T: Sync,
U: Sync,
W: Sync,
impl<T, U, L, W> Unpin for LensWrap<T, U, L, W> where
L: Unpin,
T: Unpin,
U: Unpin,
W: Unpin,
[src]
L: Unpin,
T: Unpin,
U: Unpin,
W: Unpin,
impl<T, U, L, W> UnwindSafe for LensWrap<T, U, L, W> where
L: UnwindSafe,
T: UnwindSafe,
U: UnwindSafe,
W: UnwindSafe,
[src]
L: UnwindSafe,
T: UnwindSafe,
U: UnwindSafe,
W: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> RoundFrom<T> for T
pub fn round_from(x: T) -> T
impl<T, U> RoundInto<U> for T where
U: RoundFrom<T>,
U: RoundFrom<T>,
pub fn round_into(self) -> U
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,