[−][src]Struct cursive_core::views::FixedLayout
Arranges its children in a fixed layout.
Usually meant to use an external layout engine.
Examples
use cursive_core::{ views::{Button, FixedLayout, TextView}, Rect, }; let layout = FixedLayout::new() .child(Rect::from_size((0, 0), (1, 1)), TextView::new("/")) .child(Rect::from_size((14, 0), (1, 1)), TextView::new(r"\")) .child(Rect::from_size((0, 2), (1, 1)), TextView::new(r"\")) .child(Rect::from_size((14, 2), (1, 1)), TextView::new("/")) .child( Rect::from_size((3, 1), (11, 1)), Button::new("Clickme", |s| s.quit()), );
Implementations
impl FixedLayout
[src]
pub fn new() -> Self
[src]
Returns a new, empty FixedLayout
.
pub fn child<V: IntoBoxedView>(self, position: Rect, view: V) -> Self
[src]
Adds a child. Chainable variant.
pub fn add_child<V: IntoBoxedView>(&mut self, position: Rect, view: V)
[src]
Adds a child.
pub fn get_focus_index(&self) -> usize
[src]
Returns index of focused inner view
pub fn set_focus_index(&mut self, index: usize) -> Result<(), ViewNotFound>
[src]
Attemps to set the focus on the given child.
Returns Err(())
if index >= self.len()
, or if the view at the
given index does not accept focus.
pub fn len(&self) -> usize
[src]
How many children are in this view.
pub fn is_empty(&self) -> bool
[src]
Returns true
if this view has no children.
pub fn get_child(&self, i: usize) -> Option<&dyn View>
[src]
Returns a reference to a child.
pub fn get_child_mut(&mut self, i: usize) -> Option<&mut dyn View>
[src]
Returns a mutable reference to a child.
pub fn set_child_position(&mut self, i: usize, position: Rect)
[src]
Sets the position for the given child.
pub fn remove_child(&mut self, i: usize) -> Option<Box<dyn View>>
[src]
Removes a child.
If i
is within bounds, the removed child will be returned.
pub fn find_child_from_name(&mut self, name: &str) -> Option<usize>
[src]
Looks for the child containing a view with the given name.
Returns Some(i)
if self.get_child(i)
has the given name, or
contains a view with the given name.
Returns None
if the given name was not found.
Trait Implementations
impl Default for FixedLayout
[src]
impl View for FixedLayout
[src]
pub fn draw(&self, printer: &Printer<'_, '_>)
[src]
pub fn layout(&mut self, _size: Vec2)
[src]
pub fn on_event(&mut self, event: Event) -> EventResult
[src]
pub fn important_area(&self, size: Vec2) -> Rect
[src]
pub fn required_size(&mut self, _constraint: Vec2) -> Vec2
[src]
pub fn take_focus(&mut self, source: Direction) -> bool
[src]
pub fn call_on_any<'a>(&mut self, selector: &Selector<'_>, callback: AnyCb<'a>)
[src]
pub fn focus_view(
&mut self,
selector: &Selector<'_>
) -> Result<(), ViewNotFound>
[src]
&mut self,
selector: &Selector<'_>
) -> Result<(), ViewNotFound>
pub fn needs_relayout(&self) -> bool
[src]
pub fn type_name(&self) -> &'static str
[src]
Auto Trait Implementations
impl !RefUnwindSafe for FixedLayout
[src]
impl !Send for FixedLayout
[src]
impl !Sync for FixedLayout
[src]
impl Unpin for FixedLayout
[src]
impl !UnwindSafe for FixedLayout
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Erased for T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,