Trait cursive::view::ViewWrapper
[−]
[src]
pub trait ViewWrapper {
type V: View + ?Sized;
fn with_view<F, R>(&self, f: F) -> Option<R>
where
F: FnOnce(&Self::V) -> R;
fn with_view_mut<F, R>(&mut self, f: F) -> Option<R>
where
F: FnOnce(&mut Self::V) -> R;
fn wrap_draw(&self, printer: &Printer) { ... }
fn wrap_required_size(&mut self, req: Vec2) -> Vec2 { ... }
fn wrap_on_event(&mut self, ch: Event) -> EventResult { ... }
fn wrap_layout(&mut self, size: Vec2) { ... }
fn wrap_take_focus(&mut self, source: Direction) -> bool { ... }
fn wrap_call_on_any<'a>(
&mut self,
selector: &Selector,
callback: Box<FnMut(&mut Any) + 'a>
) { ... }
fn wrap_focus_view(&mut self, selector: &Selector) -> Result<(), ()> { ... }
fn wrap_needs_relayout(&self) -> bool { ... }
}Generic wrapper around a view.
Default implementation forwards all calls to the child view. Overrides some methods as desired.
You can use the wrap_impl! macro to define with_view and
with_view_mut for you.
Associated Types
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 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: Box<FnMut(&mut Any) + 'a>
)
&mut self,
selector: &Selector,
callback: Box<FnMut(&mut Any) + '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.
Implementors
impl<U: View + ?Sized, T: Deref<Target = U> + DerefMut> ViewWrapper for T type V = U;impl<T: View> ViewWrapper for BoxView<T> type V = T;impl<T: View + 'static> ViewWrapper for IdView<T> type V = T;impl<T: View> ViewWrapper for OnEventView<T> type V = T;impl<T: View> ViewWrapper for Layer<T> type V = T;impl<V: View> ViewWrapper for Panel<V> type V = V;impl<T: View> ViewWrapper for ShadowView<T> type V = T;impl<T: View> ViewWrapper for SizedView<T> type V = T;impl<T: View> ViewWrapper for TrackedView<T> type V = T;