Struct cursive_core::views::LinearLayout
source · pub struct LinearLayout { /* private fields */ }
Expand description
Arranges its children linearly according to its orientation.
Examples
use cursive_core::traits::Resizable;
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§
source§impl LinearLayout
impl LinearLayout
sourcepub fn new(orientation: Orientation) -> Self
pub fn new(orientation: Orientation) -> Self
Creates a new layout with the given orientation.
sourcepub fn set_weight(&mut self, i: usize, weight: usize)
pub fn set_weight(&mut self, i: usize, weight: usize)
Sets the weight of the given child. This weight is currently unused by the layout process.
Panics
Panics if i >= self.len()
.
sourcepub fn weight(self, weight: usize) -> Self
pub fn weight(self, weight: usize) -> Self
Modifies the weight of the last child added. This weight is currently unused by the layout process.
It is an error to call this before adding a child (and it will panic).
sourcepub fn child<V: IntoBoxedView + 'static>(self, view: V) -> Self
pub fn child<V: IntoBoxedView + 'static>(self, view: V) -> Self
Adds a child to the layout.
Chainable variant.
sourcepub fn add_child<V: IntoBoxedView + 'static>(&mut self, view: V)
pub fn add_child<V: IntoBoxedView + 'static>(&mut self, view: V)
Adds a child to the layout.
sourcepub fn insert_child<V: IntoBoxedView + 'static>(&mut self, i: usize, view: V)
pub fn insert_child<V: IntoBoxedView + 'static>(&mut self, i: usize, view: V)
sourcepub fn swap_children(&mut self, i: usize, j: usize)
pub fn swap_children(&mut self, i: usize, j: usize)
Swaps two children.
sourcepub fn get_focus_index(&self) -> usize
pub fn get_focus_index(&self) -> usize
Returns index of focused inner view
sourcepub fn set_focus_index(
&mut self,
index: usize
) -> Result<EventResult, ViewNotFound>
pub fn set_focus_index(
&mut self,
index: usize
) -> Result<EventResult, ViewNotFound>
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.
sourcepub fn horizontal() -> Self
pub fn horizontal() -> Self
Creates a new horizontal layout.
sourcepub fn get_child_mut(&mut self, i: usize) -> Option<&mut dyn View>
pub fn get_child_mut(&mut self, i: usize) -> Option<&mut dyn View>
Returns a mutable reference to a child.
sourcepub fn remove_child(&mut self, i: usize) -> Option<Box<dyn View>>
pub fn remove_child(&mut self, i: usize) -> Option<Box<dyn View>>
Removes a child.
If i
is within bounds, the removed child will be returned.
sourcepub fn find_child_from_name(&mut self, name: &str) -> Option<usize>
pub fn find_child_from_name(&mut self, name: &str) -> Option<usize>
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.