[][src]Struct cursive::views::LinearLayout

pub struct LinearLayout { /* fields omitted */ }

Arranges its children linearly according to its orientation.

Examples

use cursive_core::traits::Boxable;
use cursive_core::views::{Button, LinearLayout, TextArea, TextView};

let linear_layout = LinearLayout::horizontal()
    .child(TextView::new("Top of the page"))
    .child(TextArea::new().fixed_size((20, 5)))
    .child(Button::new("Ok", |s| s.quit()));

Implementations

impl LinearLayout[src]

pub fn new(orientation: Orientation) -> LinearLayout[src]

Creates a new layout with the given orientation.

pub fn set_weight(&mut self, i: usize, weight: usize)[src]

Sets the weight of the given child.

Panics

Panics if i >= self.len().

pub fn weight(self, weight: usize) -> LinearLayout[src]

Modifies the weight of the last child added.

It is an error to call this before adding a child (and it will panic).

pub fn child<V>(self, view: V) -> LinearLayout where
    V: 'static + IntoBoxedView
[src]

Adds a child to the layout.

Chainable variant.

pub fn add_child<V>(&mut self, view: V) where
    V: 'static + IntoBoxedView
[src]

Adds a child to the layout.

pub fn insert_child<V>(&mut self, i: usize, view: V) where
    V: 'static + IntoBoxedView
[src]

Inserts a child at the given position.

Panics

Panics if i > self.len().

pub fn swap_children(&mut self, i: usize, j: usize)[src]

Swaps two children.

pub fn len(&self) -> usize[src]

Returns the number of children.

pub fn is_empty(&self) -> bool[src]

Returns true if this view has no children.

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

Creates a new vertical layout.

pub fn horizontal() -> LinearLayout[src]

Creates a new horizontal layout.

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 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 View for LinearLayout[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]