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) -> LinearLayout
pub fn new(orientation: Orientation) -> LinearLayout
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) -> LinearLayout
pub fn weight(self, weight: usize) -> LinearLayout
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>(self, view: V) -> LinearLayoutwhere
V: IntoBoxedView + 'static,
pub fn child<V>(self, view: V) -> LinearLayoutwhere
V: IntoBoxedView + 'static,
Adds a child to the layout.
Chainable variant.
Sourcepub fn add_child<V>(&mut self, view: V)where
V: IntoBoxedView + 'static,
pub fn add_child<V>(&mut self, view: V)where
V: IntoBoxedView + 'static,
Adds a child to the layout.
Sourcepub fn insert_child<V>(&mut self, i: usize, view: V)where
V: IntoBoxedView + 'static,
pub fn insert_child<V>(&mut self, i: usize, view: V)where
V: IntoBoxedView + 'static,
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>
Attempts to set the focus on the given child.
Returns Err(ViewNotFound)
if index >= self.len()
, or if the view at the
given index does not accept focus.
Sourcepub fn vertical() -> LinearLayout
pub fn vertical() -> LinearLayout
Creates a new vertical layout.
Sourcepub fn horizontal() -> LinearLayout
pub fn horizontal() -> LinearLayout
Creates a new horizontal layout.
Sourcepub fn get_child(&self, i: usize) -> Option<&(dyn View + 'static)>
pub fn get_child(&self, i: usize) -> Option<&(dyn View + 'static)>
Returns a reference to a child.
Sourcepub fn get_child_mut(&mut self, i: usize) -> Option<&mut (dyn View + 'static)>
pub fn get_child_mut(&mut self, i: usize) -> Option<&mut (dyn View + 'static)>
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.
Trait Implementations§
Source§impl View for LinearLayout
impl View for LinearLayout
Source§fn draw(&self, printer: &Printer<'_, '_>)
fn draw(&self, printer: &Printer<'_, '_>)
Source§fn needs_relayout(&self) -> bool
fn needs_relayout(&self) -> bool
Source§fn layout(&mut self, size: XY<usize>)
fn layout(&mut self, size: XY<usize>)
Source§fn required_size(&mut self, req: XY<usize>) -> XY<usize>
fn required_size(&mut self, req: XY<usize>) -> XY<usize>
Source§fn take_focus(&mut self, source: Direction) -> Result<EventResult, CannotFocus>
fn take_focus(&mut self, source: Direction) -> Result<EventResult, CannotFocus>
Source§fn on_event(&mut self, event: Event) -> EventResult
fn on_event(&mut self, event: Event) -> EventResult
Source§fn call_on_any(
&mut self,
selector: &Selector<'_>,
callback: &mut dyn FnMut(&mut (dyn View + 'static)),
)
fn call_on_any( &mut self, selector: &Selector<'_>, callback: &mut dyn FnMut(&mut (dyn View + 'static)), )
Source§fn focus_view(
&mut self,
selector: &Selector<'_>,
) -> Result<EventResult, ViewNotFound>
fn focus_view( &mut self, selector: &Selector<'_>, ) -> Result<EventResult, ViewNotFound>
Auto Trait Implementations§
impl Freeze for LinearLayout
impl !RefUnwindSafe for LinearLayout
impl Send for LinearLayout
impl Sync for LinearLayout
impl Unpin for LinearLayout
impl !UnwindSafe for LinearLayout
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Finder for Twhere
T: View,
impl<T> Finder for Twhere
T: View,
Source§fn call_on_all<V, F>(&mut self, sel: &Selector<'_>, callback: F)
fn call_on_all<V, F>(&mut self, sel: &Selector<'_>, callback: F)
sel
. Read moreSource§fn call_on<V, F, R>(&mut self, sel: &Selector<'_>, callback: F) -> Option<R>
fn call_on<V, F, R>(&mut self, sel: &Selector<'_>, callback: F) -> Option<R>
sel
. Read moreSource§fn call_on_name<V, F, R>(&mut self, name: &str, callback: F) -> Option<R>
fn call_on_name<V, F, R>(&mut self, name: &str, callback: F) -> Option<R>
call_on
with a view::Selector::Name
.Source§impl<T> IntoBoxedView for Twhere
T: View,
impl<T> IntoBoxedView for Twhere
T: View,
Source§fn into_boxed_view(self) -> Box<dyn View>
fn into_boxed_view(self) -> Box<dyn View>
Box<View>
.Source§impl<T> Resizable for Twhere
T: View,
impl<T> Resizable for Twhere
T: View,
Source§fn resized(
self,
width: SizeConstraint,
height: SizeConstraint,
) -> ResizedView<Self>
fn resized( self, width: SizeConstraint, height: SizeConstraint, ) -> ResizedView<Self>
self
in a ResizedView
with the given size constraints.Source§fn fixed_size<S>(self, size: S) -> ResizedView<Self>
fn fixed_size<S>(self, size: S) -> ResizedView<Self>
self
into a fixed-size ResizedView
.Source§fn fixed_width(self, width: usize) -> ResizedView<Self>
fn fixed_width(self, width: usize) -> ResizedView<Self>
self
into a fixed-width ResizedView
.Source§fn fixed_height(self, height: usize) -> ResizedView<Self>
fn fixed_height(self, height: usize) -> ResizedView<Self>
self
into a fixed-width ResizedView
.Source§fn full_screen(self) -> ResizedView<Self>
fn full_screen(self) -> ResizedView<Self>
self
into a full-screen ResizedView
.Source§fn full_width(self) -> ResizedView<Self>
fn full_width(self) -> ResizedView<Self>
self
into a full-width ResizedView
.Source§fn full_height(self) -> ResizedView<Self>
fn full_height(self) -> ResizedView<Self>
self
into a full-height ResizedView
.Source§fn max_size<S>(self, size: S) -> ResizedView<Self>
fn max_size<S>(self, size: S) -> ResizedView<Self>
self
into a limited-size ResizedView
.Source§fn max_width(self, max_width: usize) -> ResizedView<Self>
fn max_width(self, max_width: usize) -> ResizedView<Self>
self
into a limited-width ResizedView
.Source§fn max_height(self, max_height: usize) -> ResizedView<Self>
fn max_height(self, max_height: usize) -> ResizedView<Self>
self
into a limited-height ResizedView
.Source§fn min_size<S>(self, size: S) -> ResizedView<Self>
fn min_size<S>(self, size: S) -> ResizedView<Self>
self
into a ResizedView
at least sized size
.Source§fn min_width(self, min_width: usize) -> ResizedView<Self>
fn min_width(self, min_width: usize) -> ResizedView<Self>
self
in a ResizedView
at least min_width
wide.Source§fn min_height(self, min_height: usize) -> ResizedView<Self>
fn min_height(self, min_height: usize) -> ResizedView<Self>
self
in a ResizedView
at least min_height
tall.Source§impl<T> Scrollable for Twhere
T: View,
impl<T> Scrollable for Twhere
T: View,
Source§fn scrollable(self) -> ScrollView<Self>
fn scrollable(self) -> ScrollView<Self>
self
in a ScrollView
.