[−][src]Trait cursive::view::ViewWrapper
Generic wrapper around a view.
This trait is a shortcut to implement View
on a type by forwarding
calls to a wrapped view.
You only need to define with_view
and with_view_mut
(the wrap_impl!
macro can help you with that), and you will get
the View
implementation for free.
You can also override any of the wrap_*
methods for more specific
behaviors (the default implementations simply forwards the calls to the
child view).
Associated Types
Loading content...Required methods
pub fn with_view<F, R>(&self, f: F) -> Option<R> where
F: FnOnce(&Self::V) -> R,
[src]
F: FnOnce(&Self::V) -> R,
Runs a function on the inner view, returning the result.
Returns None
if the inner view is unavailable. This should only
happen with some views if they are already borrowed by another call.
pub fn with_view_mut<F, R>(&mut self, f: F) -> Option<R> where
F: FnOnce(&mut Self::V) -> R,
[src]
F: FnOnce(&mut Self::V) -> R,
Runs a function on the inner view, returning the result.
Returns None
if the inner view is unavailable. This should only
happen with some views if they are already borrowed by another call.
Provided methods
pub fn into_inner(self) -> Result<Self::V, Self> where
Self::V: Sized,
[src]
Self::V: Sized,
Attempts to retrieve the inner view.
pub fn wrap_draw(&self, printer: &Printer<'_, '_>)
[src]
Wraps the draw
method.
pub fn wrap_required_size(&mut self, req: XY<usize>) -> XY<usize>
[src]
Wraps the required_size
method.
pub fn wrap_on_event(&mut self, ch: Event) -> EventResult
[src]
Wraps the on_event
method.
pub fn wrap_layout(&mut self, size: XY<usize>)
[src]
Wraps the layout
method.
pub fn wrap_take_focus(&mut self, source: Direction) -> bool
[src]
Wraps the take_focus
method.
pub fn wrap_call_on_any(
&mut self,
selector: &Selector<'_>,
callback: &'a mut (dyn FnMut(&mut (dyn View + 'static)) + 'a)
)
[src]
&mut self,
selector: &Selector<'_>,
callback: &'a mut (dyn FnMut(&mut (dyn View + 'static)) + 'a)
)
Wraps the find
method.
pub fn wrap_focus_view(
&mut self,
selector: &Selector<'_>
) -> Result<(), ViewNotFound>
[src]
&mut self,
selector: &Selector<'_>
) -> Result<(), ViewNotFound>
Wraps the focus_view
method.
pub fn wrap_needs_relayout(&self) -> bool
[src]
Wraps the needs_relayout
method.
pub fn wrap_important_area(&self, size: XY<usize>) -> Rect
[src]
Wraps the important_area
method.
Implementors
impl ViewWrapper for BoxedView
[src]
type V = dyn View + 'static
pub fn with_view<F, R>(&self, f: F) -> Option<R> where
F: FnOnce(&<BoxedView as ViewWrapper>::V) -> R,
[src]
F: FnOnce(&<BoxedView as ViewWrapper>::V) -> R,
pub fn with_view_mut<F, R>(&mut self, f: F) -> Option<R> where
F: FnOnce(&mut <BoxedView as ViewWrapper>::V) -> R,
[src]
F: FnOnce(&mut <BoxedView as ViewWrapper>::V) -> R,
impl<T> ViewWrapper for CircularFocus<T> where
T: View,
[src]
T: View,
type V = T
pub fn with_view<F, R>(&self, f: F) -> Option<R> where
F: FnOnce(&<CircularFocus<T> as ViewWrapper>::V) -> R,
[src]
F: FnOnce(&<CircularFocus<T> as ViewWrapper>::V) -> R,
pub fn with_view_mut<F, R>(&mut self, f: F) -> Option<R> where
F: FnOnce(&mut <CircularFocus<T> as ViewWrapper>::V) -> R,
[src]
F: FnOnce(&mut <CircularFocus<T> as ViewWrapper>::V) -> R,
pub fn into_inner(
self
) -> Result<<CircularFocus<T> as ViewWrapper>::V, CircularFocus<T>> where
<CircularFocus<T> as ViewWrapper>::V: Sized,
[src]
self
) -> Result<<CircularFocus<T> as ViewWrapper>::V, CircularFocus<T>> where
<CircularFocus<T> as ViewWrapper>::V: Sized,
pub fn wrap_on_event(&mut self, event: Event) -> EventResult
[src]
impl<T> ViewWrapper for LastSizeView<T> where
T: View,
[src]
T: View,
type V = T
pub fn with_view<F, R>(&self, f: F) -> Option<R> where
F: FnOnce(&<LastSizeView<T> as ViewWrapper>::V) -> R,
[src]
F: FnOnce(&<LastSizeView<T> as ViewWrapper>::V) -> R,
pub fn with_view_mut<F, R>(&mut self, f: F) -> Option<R> where
F: FnOnce(&mut <LastSizeView<T> as ViewWrapper>::V) -> R,
[src]
F: FnOnce(&mut <LastSizeView<T> as ViewWrapper>::V) -> R,
pub fn into_inner(
self
) -> Result<<LastSizeView<T> as ViewWrapper>::V, LastSizeView<T>> where
<LastSizeView<T> as ViewWrapper>::V: Sized,
[src]
self
) -> Result<<LastSizeView<T> as ViewWrapper>::V, LastSizeView<T>> where
<LastSizeView<T> as ViewWrapper>::V: Sized,
pub fn wrap_layout(&mut self, size: XY<usize>)
[src]
impl<T> ViewWrapper for Layer<T> where
T: View,
[src]
T: View,
type V = T
pub fn with_view<F, R>(&self, f: F) -> Option<R> where
F: FnOnce(&<Layer<T> as ViewWrapper>::V) -> R,
[src]
F: FnOnce(&<Layer<T> as ViewWrapper>::V) -> R,
pub fn with_view_mut<F, R>(&mut self, f: F) -> Option<R> where
F: FnOnce(&mut <Layer<T> as ViewWrapper>::V) -> R,
[src]
F: FnOnce(&mut <Layer<T> as ViewWrapper>::V) -> R,
pub fn into_inner(self) -> Result<<Layer<T> as ViewWrapper>::V, Layer<T>> where
<Layer<T> as ViewWrapper>::V: Sized,
[src]
<Layer<T> as ViewWrapper>::V: Sized,
pub fn wrap_draw(&self, printer: &Printer<'_, '_>)
[src]
impl<T> ViewWrapper for NamedView<T> where
T: 'static + View,
[src]
T: 'static + View,
type V = T
pub fn with_view<F, R>(&self, f: F) -> Option<R> where
F: FnOnce(&<NamedView<T> as ViewWrapper>::V) -> R,
[src]
F: FnOnce(&<NamedView<T> as ViewWrapper>::V) -> R,
pub fn with_view_mut<F, R>(&mut self, f: F) -> Option<R> where
F: FnOnce(&mut <NamedView<T> as ViewWrapper>::V) -> R,
[src]
F: FnOnce(&mut <NamedView<T> as ViewWrapper>::V) -> R,
pub fn into_inner(
self
) -> Result<<NamedView<T> as ViewWrapper>::V, NamedView<T>> where
<NamedView<T> as ViewWrapper>::V: Sized,
[src]
self
) -> Result<<NamedView<T> as ViewWrapper>::V, NamedView<T>> where
<NamedView<T> as ViewWrapper>::V: Sized,
pub fn wrap_call_on_any(
&mut self,
selector: &Selector<'_>,
callback: &'a mut (dyn FnMut(&mut (dyn View + 'static)) + 'a)
)
[src]
&mut self,
selector: &Selector<'_>,
callback: &'a mut (dyn FnMut(&mut (dyn View + 'static)) + 'a)
)
pub fn wrap_focus_view(
&mut self,
selector: &Selector<'_>
) -> Result<(), ViewNotFound>
[src]
&mut self,
selector: &Selector<'_>
) -> Result<(), ViewNotFound>
impl<T> ViewWrapper for OnEventView<T> where
T: View,
[src]
T: View,
type V = T
pub fn with_view<F, R>(&self, f: F) -> Option<R> where
F: FnOnce(&<OnEventView<T> as ViewWrapper>::V) -> R,
[src]
F: FnOnce(&<OnEventView<T> as ViewWrapper>::V) -> R,
pub fn with_view_mut<F, R>(&mut self, f: F) -> Option<R> where
F: FnOnce(&mut <OnEventView<T> as ViewWrapper>::V) -> R,
[src]
F: FnOnce(&mut <OnEventView<T> as ViewWrapper>::V) -> R,
pub fn into_inner(
self
) -> Result<<OnEventView<T> as ViewWrapper>::V, OnEventView<T>> where
<OnEventView<T> as ViewWrapper>::V: Sized,
[src]
self
) -> Result<<OnEventView<T> as ViewWrapper>::V, OnEventView<T>> where
<OnEventView<T> as ViewWrapper>::V: Sized,
pub fn wrap_on_event(&mut self, event: Event) -> EventResult
[src]
impl<T> ViewWrapper for ResizedView<T> where
T: View,
[src]
T: View,
type V = T
pub fn with_view<F, R>(&self, f: F) -> Option<R> where
F: FnOnce(&<ResizedView<T> as ViewWrapper>::V) -> R,
[src]
F: FnOnce(&<ResizedView<T> as ViewWrapper>::V) -> R,
pub fn with_view_mut<F, R>(&mut self, f: F) -> Option<R> where
F: FnOnce(&mut <ResizedView<T> as ViewWrapper>::V) -> R,
[src]
F: FnOnce(&mut <ResizedView<T> as ViewWrapper>::V) -> R,
pub fn into_inner(
self
) -> Result<<ResizedView<T> as ViewWrapper>::V, ResizedView<T>> where
<ResizedView<T> as ViewWrapper>::V: Sized,
[src]
self
) -> Result<<ResizedView<T> as ViewWrapper>::V, ResizedView<T>> where
<ResizedView<T> as ViewWrapper>::V: Sized,
pub fn wrap_draw(&self, printer: &Printer<'_, '_>)
[src]
pub fn wrap_required_size(&mut self, req: XY<usize>) -> XY<usize>
[src]
pub fn wrap_layout(&mut self, size: XY<usize>)
[src]
pub fn wrap_needs_relayout(&self) -> bool
[src]
impl<T> ViewWrapper for ShadowView<T> where
T: View,
[src]
T: View,
type V = T
pub fn with_view<F, R>(&self, f: F) -> Option<R> where
F: FnOnce(&<ShadowView<T> as ViewWrapper>::V) -> R,
[src]
F: FnOnce(&<ShadowView<T> as ViewWrapper>::V) -> R,
pub fn with_view_mut<F, R>(&mut self, f: F) -> Option<R> where
F: FnOnce(&mut <ShadowView<T> as ViewWrapper>::V) -> R,
[src]
F: FnOnce(&mut <ShadowView<T> as ViewWrapper>::V) -> R,
pub fn into_inner(
self
) -> Result<<ShadowView<T> as ViewWrapper>::V, ShadowView<T>> where
<ShadowView<T> as ViewWrapper>::V: Sized,
[src]
self
) -> Result<<ShadowView<T> as ViewWrapper>::V, ShadowView<T>> where
<ShadowView<T> as ViewWrapper>::V: Sized,
pub fn wrap_required_size(&mut self, req: XY<usize>) -> XY<usize>
[src]
pub fn wrap_layout(&mut self, size: XY<usize>)
[src]
pub fn wrap_on_event(&mut self, event: Event) -> EventResult
[src]
pub fn wrap_draw(&self, printer: &Printer<'_, '_>)
[src]
pub fn wrap_important_area(&self, view_size: XY<usize>) -> Rect
[src]
impl<T> ViewWrapper for TrackedView<T> where
T: View,
[src]
T: View,
type V = T
pub fn with_view<F, R>(&self, f: F) -> Option<R> where
F: FnOnce(&<TrackedView<T> as ViewWrapper>::V) -> R,
[src]
F: FnOnce(&<TrackedView<T> as ViewWrapper>::V) -> R,
pub fn with_view_mut<F, R>(&mut self, f: F) -> Option<R> where
F: FnOnce(&mut <TrackedView<T> as ViewWrapper>::V) -> R,
[src]
F: FnOnce(&mut <TrackedView<T> as ViewWrapper>::V) -> R,
pub fn into_inner(
self
) -> Result<<TrackedView<T> as ViewWrapper>::V, TrackedView<T>> where
<TrackedView<T> as ViewWrapper>::V: Sized,
[src]
self
) -> Result<<TrackedView<T> as ViewWrapper>::V, TrackedView<T>> where
<TrackedView<T> as ViewWrapper>::V: Sized,
pub fn wrap_draw(&self, printer: &Printer<'_, '_>)
[src]
impl<V> ViewWrapper for EnableableView<V> where
V: View,
[src]
V: View,
type V = V
pub fn with_view<F, R>(&self, f: F) -> Option<R> where
F: FnOnce(&<EnableableView<V> as ViewWrapper>::V) -> R,
[src]
F: FnOnce(&<EnableableView<V> as ViewWrapper>::V) -> R,
pub fn with_view_mut<F, R>(&mut self, f: F) -> Option<R> where
F: FnOnce(&mut <EnableableView<V> as ViewWrapper>::V) -> R,
[src]
F: FnOnce(&mut <EnableableView<V> as ViewWrapper>::V) -> R,
pub fn into_inner(
self
) -> Result<<EnableableView<V> as ViewWrapper>::V, EnableableView<V>> where
<EnableableView<V> as ViewWrapper>::V: Sized,
[src]
self
) -> Result<<EnableableView<V> as ViewWrapper>::V, EnableableView<V>> where
<EnableableView<V> as ViewWrapper>::V: Sized,
pub fn wrap_on_event(&mut self, event: Event) -> EventResult
[src]
pub fn wrap_draw(&self, printer: &Printer<'_, '_>)
[src]
impl<V> ViewWrapper for HideableView<V> where
V: View,
[src]
V: View,
type V = V
pub fn with_view<F, R>(&self, f: F) -> Option<R> where
F: FnOnce(&<HideableView<V> as ViewWrapper>::V) -> R,
[src]
F: FnOnce(&<HideableView<V> as ViewWrapper>::V) -> R,
pub fn with_view_mut<F, R>(&mut self, f: F) -> Option<R> where
F: FnOnce(&mut <HideableView<V> as ViewWrapper>::V) -> R,
[src]
F: FnOnce(&mut <HideableView<V> as ViewWrapper>::V) -> R,
pub fn wrap_call_on_any(
&mut self,
selector: &Selector<'_>,
callback: &'a mut (dyn FnMut(&mut (dyn View + 'static)) + 'a)
)
[src]
&mut self,
selector: &Selector<'_>,
callback: &'a mut (dyn FnMut(&mut (dyn View + 'static)) + 'a)
)
pub fn into_inner(
self
) -> Result<<HideableView<V> as ViewWrapper>::V, HideableView<V>> where
HideableView<V>: Sized,
<HideableView<V> as ViewWrapper>::V: Sized,
[src]
self
) -> Result<<HideableView<V> as ViewWrapper>::V, HideableView<V>> where
HideableView<V>: Sized,
<HideableView<V> as ViewWrapper>::V: Sized,
pub fn wrap_layout(&mut self, size: XY<usize>)
[src]
pub fn wrap_needs_relayout(&self) -> bool
[src]
impl<V> ViewWrapper for OnLayoutView<V> where
V: View,
[src]
V: View,
type V = V
pub fn with_view<F, R>(&self, f: F) -> Option<R> where
F: FnOnce(&<OnLayoutView<V> as ViewWrapper>::V) -> R,
[src]
F: FnOnce(&<OnLayoutView<V> as ViewWrapper>::V) -> R,
pub fn with_view_mut<F, R>(&mut self, f: F) -> Option<R> where
F: FnOnce(&mut <OnLayoutView<V> as ViewWrapper>::V) -> R,
[src]
F: FnOnce(&mut <OnLayoutView<V> as ViewWrapper>::V) -> R,
pub fn into_inner(
self
) -> Result<<OnLayoutView<V> as ViewWrapper>::V, OnLayoutView<V>> where
<OnLayoutView<V> as ViewWrapper>::V: Sized,
[src]
self
) -> Result<<OnLayoutView<V> as ViewWrapper>::V, OnLayoutView<V>> where
<OnLayoutView<V> as ViewWrapper>::V: Sized,
pub fn wrap_layout(&mut self, size: XY<usize>)
[src]
impl<V> ViewWrapper for PaddedView<V> where
V: View,
[src]
V: View,
type V = V
pub fn with_view<F, R>(&self, f: F) -> Option<R> where
F: FnOnce(&<PaddedView<V> as ViewWrapper>::V) -> R,
[src]
F: FnOnce(&<PaddedView<V> as ViewWrapper>::V) -> R,
pub fn with_view_mut<F, R>(&mut self, f: F) -> Option<R> where
F: FnOnce(&mut <PaddedView<V> as ViewWrapper>::V) -> R,
[src]
F: FnOnce(&mut <PaddedView<V> as ViewWrapper>::V) -> R,
pub fn into_inner(
self
) -> Result<<PaddedView<V> as ViewWrapper>::V, PaddedView<V>> where
<PaddedView<V> as ViewWrapper>::V: Sized,
[src]
self
) -> Result<<PaddedView<V> as ViewWrapper>::V, PaddedView<V>> where
<PaddedView<V> as ViewWrapper>::V: Sized,
pub fn wrap_required_size(&mut self, req: XY<usize>) -> XY<usize>
[src]
pub fn wrap_layout(&mut self, size: XY<usize>)
[src]
pub fn wrap_on_event(&mut self, event: Event) -> EventResult
[src]
pub fn wrap_draw(&self, printer: &Printer<'_, '_>)
[src]
pub fn wrap_important_area(&self, view_size: XY<usize>) -> Rect
[src]
impl<V> ViewWrapper for Panel<V> where
V: View,
[src]
V: View,
type V = V
pub fn with_view<F, R>(&self, f: F) -> Option<R> where
F: FnOnce(&<Panel<V> as ViewWrapper>::V) -> R,
[src]
F: FnOnce(&<Panel<V> as ViewWrapper>::V) -> R,
pub fn with_view_mut<F, R>(&mut self, f: F) -> Option<R> where
F: FnOnce(&mut <Panel<V> as ViewWrapper>::V) -> R,
[src]
F: FnOnce(&mut <Panel<V> as ViewWrapper>::V) -> R,
pub fn into_inner(self) -> Result<<Panel<V> as ViewWrapper>::V, Panel<V>> where
<Panel<V> as ViewWrapper>::V: Sized,
[src]
<Panel<V> as ViewWrapper>::V: Sized,
pub fn wrap_on_event(&mut self, event: Event) -> EventResult
[src]
pub fn wrap_required_size(&mut self, req: XY<usize>) -> XY<usize>
[src]
pub fn wrap_draw(&self, printer: &Printer<'_, '_>)
[src]
pub fn wrap_layout(&mut self, size: XY<usize>)
[src]
pub fn wrap_important_area(&self, size: XY<usize>) -> Rect
[src]
pub fn wrap_needs_relayout(&self) -> bool
[src]
impl<V> ViewWrapper for ScreensView<V> where
V: View,
[src]
V: View,
type V = V
pub fn with_view<F, R>(&self, f: F) -> Option<R> where
F: FnOnce(&<ScreensView<V> as ViewWrapper>::V) -> R,
[src]
F: FnOnce(&<ScreensView<V> as ViewWrapper>::V) -> R,
pub fn with_view_mut<F, R>(&mut self, f: F) -> Option<R> where
F: FnOnce(&mut <ScreensView<V> as ViewWrapper>::V) -> R,
[src]
F: FnOnce(&mut <ScreensView<V> as ViewWrapper>::V) -> R,
pub fn wrap_call_on_any(
&mut self,
selector: &Selector<'_>,
callback: &'a mut (dyn FnMut(&mut (dyn View + 'static)) + 'a)
)
[src]
&mut self,
selector: &Selector<'_>,
callback: &'a mut (dyn FnMut(&mut (dyn View + 'static)) + 'a)
)
pub fn wrap_focus_view(
&mut self,
selector: &Selector<'_>
) -> Result<(), ViewNotFound>
[src]
&mut self,
selector: &Selector<'_>
) -> Result<(), ViewNotFound>