[][src]Struct cursive::views::FixedLayout

pub struct FixedLayout { /* fields omitted */ }

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() -> FixedLayout[src]

Returns a new, empty FixedLayout.

pub fn child<V>(self, position: Rect, view: V) -> FixedLayout where
    V: IntoBoxedView
[src]

Adds a child. Chainable variant.

pub fn add_child<V>(&mut self, position: Rect, view: V) where
    V: IntoBoxedView
[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 + 'static)>[src]

Returns a reference to a child.

pub fn get_child_mut(&mut self, i: usize) -> Option<&mut (dyn View + 'static)>[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 + 'static, Global>>
[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]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> AnyView for T where
    T: View
[src]

pub fn as_any(&self) -> &(dyn Any + 'static)[src]

Downcast self to a Any.

pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)[src]

Downcast self to a mutable Any.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Erased for T

impl<T> Finder for T where
    T: View
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> IntoBoxedView for T where
    T: View
[src]

impl<T> Nameable for T where
    T: View
[src]

impl<T> Resizable for T where
    T: View
[src]

impl<T> Scrollable for T where
    T: View
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> With for T[src]