Struct ratatui_widgets::stack_container::StackContainer
source · pub struct StackContainer { /* private fields */ }
Expand description
A container that stacks widgets in a given direction
§Examples
use ratatui::prelude::*;
use ratatui::widgets::*;
use ratatui_widgets::StackContainer;
let mut stack = StackContainer::horizontal();
stack.push(Box::new(Paragraph::new("Left")), Constraint::Fill(1));
stack.push(Box::new(Paragraph::new("Center")), Constraint::Fill(2));
stack.push(Box::new(Paragraph::new("Right")), Constraint::Fill(1));
// or
let stack = StackContainer::horizontal().with_widgets(vec![
(Box::new(Paragraph::new("Left")), Constraint::Fill(1)),
(Box::new(Paragraph::new("Center")), Constraint::Fill(2)),
(Box::new(Paragraph::new("Right")), Constraint::Fill(1)),
]);
Implementations§
source§impl StackContainer
impl StackContainer
pub fn new(direction: Direction) -> Self
pub fn horizontal() -> Self
pub fn vertical() -> Self
pub fn with_margin(self, margin: u16) -> Self
pub fn with_spacing(self, spacing: u16) -> Self
pub fn with_flex(self, flex: Flex) -> Self
pub fn with_widget( self, widget: Box<dyn WidgetRef>, constraint: Constraint ) -> Self
pub fn with_widgets( self, widgets: Vec<(Box<dyn WidgetRef>, Constraint)> ) -> Self
pub fn push(&mut self, widget: Box<dyn WidgetRef>, constraint: Constraint)
pub fn remove(&mut self, index: usize)
Trait Implementations§
source§impl Debug for StackContainer
impl Debug for StackContainer
source§impl Default for StackContainer
impl Default for StackContainer
source§fn default() -> StackContainer
fn default() -> StackContainer
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for StackContainer
impl !RefUnwindSafe for StackContainer
impl !Send for StackContainer
impl !Sync for StackContainer
impl Unpin for StackContainer
impl !UnwindSafe for StackContainer
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
Mutably borrows from an owned value. Read more