Struct cursive_core::views::OnLayoutView
source · pub struct OnLayoutView<V> { /* private fields */ }
Expand description
View wrapper overriding the View::layout
method.
Implementations§
source§impl<V> OnLayoutView<V>
impl<V> OnLayoutView<V>
sourcepub fn new<F>(view: V, on_layout: F) -> Selfwhere
F: FnMut(&mut V, Vec2) + 'static,
pub fn new<F>(view: V, on_layout: F) -> Selfwhere
F: FnMut(&mut V, Vec2) + 'static,
Wraps a view in an OnLayoutView
.
Will run the given closure for layout instead of the one from view
.
use cursive_core::{
views::{OnLayoutView, TextView},
View,
};
let view = TextView::new("foo");
// Here we just run the innver view's layout.
OnLayoutView::new(view, |v, s| v.layout(s));
sourcepub fn wrap(view: V) -> Selfwhere
V: View,
pub fn wrap(view: V) -> Selfwhere
V: View,
Wraps a view in an OnLayoutView
.
This is a shortcut for Self::new(view, V::layout)
You can change it later with set_on_layout
.
sourcepub fn set_on_layout<F>(&mut self, on_layout: F)where
F: FnMut(&mut V, Vec2) + 'static,
pub fn set_on_layout<F>(&mut self, on_layout: F)where
F: FnMut(&mut V, Vec2) + 'static,
Replaces the callback to run.
sourcepub fn get_inner_mut(&mut self) -> &mut V
pub fn get_inner_mut(&mut self) -> &mut V
Gets mutable access to the inner view.
Trait Implementations§
source§impl<V: View> ViewWrapper for OnLayoutView<V>
impl<V: View> ViewWrapper for OnLayoutView<V>
source§fn with_view<F, R>(&self, f: F) -> Option<R>where
F: FnOnce(&Self::V) -> R,
fn with_view<F, R>(&self, f: F) -> Option<R>where
F: FnOnce(&Self::V) -> R,
Runs a function on the inner view, returning the result. Read more
source§fn with_view_mut<F, R>(&mut self, f: F) -> Option<R>where
F: FnOnce(&mut Self::V) -> R,
fn with_view_mut<F, R>(&mut self, f: F) -> Option<R>where
F: FnOnce(&mut Self::V) -> R,
Runs a function on the inner view, returning the result. Read more
source§fn into_inner(self) -> Result<Self::V, Self>where
Self::V: Sized,
fn into_inner(self) -> Result<Self::V, Self>where
Self::V: Sized,
Attempts to retrieve the inner view.
source§fn wrap_layout(&mut self, size: Vec2)
fn wrap_layout(&mut self, size: Vec2)
Wraps the
layout
method.source§fn wrap_required_size(&mut self, req: Vec2) -> Vec2
fn wrap_required_size(&mut self, req: Vec2) -> Vec2
Wraps the
required_size
method.source§fn wrap_on_event(&mut self, ch: Event) -> EventResult
fn wrap_on_event(&mut self, ch: Event) -> EventResult
Wraps the
on_event
method.source§fn wrap_take_focus(
&mut self,
source: Direction
) -> Result<EventResult, CannotFocus>
fn wrap_take_focus(
&mut self,
source: Direction
) -> Result<EventResult, CannotFocus>
Wraps the
take_focus
method.source§fn wrap_call_on_any<'a>(&mut self, selector: &Selector<'_>, callback: AnyCb<'a>)
fn wrap_call_on_any<'a>(&mut self, selector: &Selector<'_>, callback: AnyCb<'a>)
Wraps the
find
method.source§fn wrap_focus_view(
&mut self,
selector: &Selector<'_>
) -> Result<EventResult, ViewNotFound>
fn wrap_focus_view(
&mut self,
selector: &Selector<'_>
) -> Result<EventResult, ViewNotFound>
Wraps the
focus_view
method.source§fn wrap_needs_relayout(&self) -> bool
fn wrap_needs_relayout(&self) -> bool
Wraps the
needs_relayout
method.source§fn wrap_important_area(&self, size: Vec2) -> Rect
fn wrap_important_area(&self, size: Vec2) -> Rect
Wraps the
important_area
method.