[−][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
fn with_view<F, R>(&self, f: F) -> Option<R> where
F: FnOnce(&Self::V) -> R,
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.
fn with_view_mut<F, R>(&mut self, f: F) -> Option<R> where
F: FnOnce(&mut Self::V) -> R,
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
fn into_inner(self) -> Result<Self::V, Self> where
Self: Sized,
Self::V: Sized,
Self: Sized,
Self::V: Sized,
Attempts to retrieve the inner view.
fn wrap_draw(&self, printer: &Printer)
Wraps the draw
method.
fn wrap_required_size(&mut self, req: Vec2) -> Vec2
Wraps the required_size
method.
fn wrap_on_event(&mut self, ch: Event) -> EventResult
Wraps the on_event
method.
fn wrap_layout(&mut self, size: Vec2)
Wraps the layout
method.
fn wrap_take_focus(&mut self, source: Direction) -> bool
Wraps the take_focus
method.
fn wrap_call_on_any<'a>(&mut self, selector: &Selector, callback: AnyCb<'a>)
Wraps the find
method.
fn wrap_focus_view(&mut self, selector: &Selector) -> Result<(), ()>
Wraps the focus_view
method.
fn wrap_needs_relayout(&self) -> bool
Wraps the needs_relayout
method.
fn wrap_important_area(&self, size: Vec2) -> Rect
Wraps the important_area
method.
Implementors
impl ViewWrapper for ViewBox
[src]
type V = dyn View
fn with_view<F, R>(&self, f: F) -> Option<R> where
F: FnOnce(&Self::V) -> R,
[src]
F: FnOnce(&Self::V) -> R,
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,
impl<T: View + 'static> ViewWrapper for IdView<T>
[src]
type V = T
fn with_view<F, R>(&self, f: F) -> Option<R> where
F: FnOnce(&Self::V) -> R,
[src]
F: FnOnce(&Self::V) -> R,
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,
fn into_inner(self) -> Result<Self::V, Self> where
Self::V: Sized,
[src]
Self::V: Sized,
fn wrap_call_on_any<'a>(
&mut self,
selector: &Selector,
callback: Box<dyn FnMut(&'b mut dyn Any) + 'a>
)
[src]
&mut self,
selector: &Selector,
callback: Box<dyn FnMut(&'b mut dyn Any) + 'a>
)
fn wrap_focus_view(&mut self, selector: &Selector) -> Result<(), ()>
[src]
impl<T: View> ViewWrapper for BoxView<T>
[src]
type V = T
fn with_view<F, R>(&self, f: F) -> Option<R> where
F: FnOnce(&Self::V) -> R,
[src]
F: FnOnce(&Self::V) -> R,
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,
fn into_inner(self) -> Result<Self::V, Self> where
Self::V: Sized,
[src]
Self::V: Sized,
fn wrap_required_size(&mut self, req: Vec2) -> Vec2
[src]
fn wrap_layout(&mut self, size: Vec2)
[src]
fn wrap_needs_relayout(&self) -> bool
[src]
impl<T: View> ViewWrapper for CircularFocus<T>
[src]
type V = T
fn with_view<F, R>(&self, f: F) -> Option<R> where
F: FnOnce(&Self::V) -> R,
[src]
F: FnOnce(&Self::V) -> R,
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,
fn into_inner(self) -> Result<Self::V, Self> where
Self::V: Sized,
[src]
Self::V: Sized,
fn wrap_on_event(&mut self, event: Event) -> EventResult
[src]
impl<T: View> ViewWrapper for Layer<T>
[src]
type V = T
fn with_view<F, R>(&self, f: F) -> Option<R> where
F: FnOnce(&Self::V) -> R,
[src]
F: FnOnce(&Self::V) -> R,
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,
fn into_inner(self) -> Result<Self::V, Self> where
Self::V: Sized,
[src]
Self::V: Sized,
fn wrap_draw(&self, printer: &Printer)
[src]
impl<T: View> ViewWrapper for OnEventView<T>
[src]
type V = T
fn with_view<F, R>(&self, f: F) -> Option<R> where
F: FnOnce(&Self::V) -> R,
[src]
F: FnOnce(&Self::V) -> R,
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,
fn into_inner(self) -> Result<Self::V, Self> where
Self::V: Sized,
[src]
Self::V: Sized,
fn wrap_on_event(&mut self, event: Event) -> EventResult
[src]
impl<T: View> ViewWrapper for ShadowView<T>
[src]
type V = T
fn with_view<F, R>(&self, f: F) -> Option<R> where
F: FnOnce(&Self::V) -> R,
[src]
F: FnOnce(&Self::V) -> R,
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,
fn into_inner(self) -> Result<Self::V, Self> where
Self::V: Sized,
[src]
Self::V: Sized,
fn wrap_required_size(&mut self, req: Vec2) -> Vec2
[src]
fn wrap_layout(&mut self, size: Vec2)
[src]
fn wrap_on_event(&mut self, event: Event) -> EventResult
[src]
fn wrap_draw(&self, printer: &Printer)
[src]
impl<T: View> ViewWrapper for SizedView<T>
[src]
type V = T
fn with_view<F, R>(&self, f: F) -> Option<R> where
F: FnOnce(&Self::V) -> R,
[src]
F: FnOnce(&Self::V) -> R,
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,
fn into_inner(self) -> Result<Self::V, Self> where
Self::V: Sized,
[src]
Self::V: Sized,
fn wrap_layout(&mut self, size: Vec2)
[src]
impl<T: View> ViewWrapper for TrackedView<T>
[src]
type V = T
fn with_view<F, R>(&self, f: F) -> Option<R> where
F: FnOnce(&Self::V) -> R,
[src]
F: FnOnce(&Self::V) -> R,
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,
fn into_inner(self) -> Result<Self::V, Self> where
Self::V: Sized,
[src]
Self::V: Sized,
fn wrap_draw(&self, printer: &Printer)
[src]
impl<V: View> ViewWrapper for EnableableView<V>
[src]
type V = V
fn with_view<F, R>(&self, f: F) -> Option<R> where
F: FnOnce(&Self::V) -> R,
[src]
F: FnOnce(&Self::V) -> R,
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,
fn into_inner(self) -> Result<Self::V, Self> where
Self::V: Sized,
[src]
Self::V: Sized,
fn wrap_on_event(&mut self, event: Event) -> EventResult
[src]
fn wrap_draw(&self, printer: &Printer)
[src]
impl<V: View> ViewWrapper for HideableView<V>
[src]
type V = V
fn with_view<F, R>(&self, f: F) -> Option<R> where
F: FnOnce(&Self::V) -> R,
[src]
F: FnOnce(&Self::V) -> R,
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,
fn wrap_call_on_any<'a>(
&mut self,
selector: &Selector,
callback: Box<dyn FnMut(&mut dyn Any) + 'a>
)
[src]
&mut self,
selector: &Selector,
callback: Box<dyn FnMut(&mut dyn Any) + 'a>
)
fn into_inner(self) -> Result<Self::V, Self> where
Self: Sized,
Self::V: Sized,
[src]
Self: Sized,
Self::V: Sized,
fn wrap_layout(&mut self, size: Vec2)
[src]
fn wrap_needs_relayout(&self) -> bool
[src]
impl<V: View> ViewWrapper for PaddedView<V>
[src]
type V = V
fn with_view<F, R>(&self, f: F) -> Option<R> where
F: FnOnce(&Self::V) -> R,
[src]
F: FnOnce(&Self::V) -> R,
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,
fn into_inner(self) -> Result<Self::V, Self> where
Self::V: Sized,
[src]
Self::V: Sized,
fn wrap_required_size(&mut self, req: Vec2) -> Vec2
[src]
fn wrap_layout(&mut self, size: Vec2)
[src]
fn wrap_on_event(&mut self, event: Event) -> EventResult
[src]
fn wrap_draw(&self, printer: &Printer)
[src]
impl<V: View> ViewWrapper for Panel<V>
[src]
type V = V
fn with_view<F, R>(&self, f: F) -> Option<R> where
F: FnOnce(&Self::V) -> R,
[src]
F: FnOnce(&Self::V) -> R,
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,
fn into_inner(self) -> Result<Self::V, Self> where
Self::V: Sized,
[src]
Self::V: Sized,