[][src]Trait cursive::view::ViewWrapper

pub trait ViewWrapper: 'static {
    type V: View + ?Sized;
    pub fn with_view<F, R>(&self, f: F) -> Option<R>
    where
        F: FnOnce(&Self::V) -> R
;
pub fn with_view_mut<F, R>(&mut self, f: F) -> Option<R>
    where
        F: FnOnce(&mut Self::V) -> R
; pub fn into_inner(self) -> Result<Self::V, Self>
    where
        Self::V: Sized
, { ... }
pub fn wrap_draw(&self, printer: &Printer<'_, '_>) { ... }
pub fn wrap_required_size(&mut self, req: XY<usize>) -> XY<usize> { ... }
pub fn wrap_on_event(&mut self, ch: Event) -> EventResult { ... }
pub fn wrap_layout(&mut self, size: XY<usize>) { ... }
pub fn wrap_take_focus(&mut self, source: Direction) -> bool { ... }
pub fn wrap_call_on_any(
        &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> { ... }
pub fn wrap_needs_relayout(&self) -> bool { ... }
pub fn wrap_important_area(&self, size: XY<usize>) -> Rect { ... } }

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

type V: View + ?Sized[src]

Type that this view wraps.

Loading content...

Required methods

pub fn with_view<F, R>(&self, f: F) -> Option<R> where
    F: FnOnce(&Self::V) -> R, 
[src]

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]

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.

Loading content...

Provided methods

pub fn into_inner(self) -> Result<Self::V, Self> where
    Self::V: Sized
[src]

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]

Wraps the find method.

pub fn wrap_focus_view(
    &mut self,
    selector: &Selector<'_>
) -> Result<(), ViewNotFound>
[src]

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.

Loading content...

Implementors

impl ViewWrapper for BoxedView[src]

type V = dyn View + 'static

impl<T> ViewWrapper for CircularFocus<T> where
    T: View
[src]

type V = T

impl<T> ViewWrapper for LastSizeView<T> where
    T: View
[src]

type V = T

impl<T> ViewWrapper for Layer<T> where
    T: View
[src]

type V = T

impl<T> ViewWrapper for NamedView<T> where
    T: 'static + View
[src]

type V = T

impl<T> ViewWrapper for OnEventView<T> where
    T: View
[src]

type V = T

impl<T> ViewWrapper for ResizedView<T> where
    T: View
[src]

type V = T

impl<T> ViewWrapper for ShadowView<T> where
    T: View
[src]

type V = T

impl<T> ViewWrapper for TrackedView<T> where
    T: View
[src]

type V = T

impl<V> ViewWrapper for EnableableView<V> where
    V: View
[src]

type V = V

impl<V> ViewWrapper for HideableView<V> where
    V: View
[src]

type V = V

impl<V> ViewWrapper for OnLayoutView<V> where
    V: View
[src]

type V = V

impl<V> ViewWrapper for PaddedView<V> where
    V: View
[src]

type V = V

impl<V> ViewWrapper for Panel<V> where
    V: View
[src]

type V = V

impl<V> ViewWrapper for ScreensView<V> where
    V: View
[src]

type V = V

Loading content...