ratatui_toolkit/primitives/pane/constructors/
mod.rs

1use ratatui::style::{Color, Modifier, Style};
2use ratatui::text::Line;
3use ratatui::widgets::BorderType;
4
5use crate::primitives::pane::Pane;
6
7impl<'a> Pane<'a> {
8    pub fn new(title: impl Into<String>) -> Self {
9        Self {
10            title: title.into(),
11            icon: None,
12            padding: (0, 0, 0, 0),
13            text_footer: None,
14            footer_height: 0,
15            border_style: Style::default().fg(Color::White),
16            border_type: BorderType::Rounded,
17            title_style: Style::default().add_modifier(Modifier::BOLD),
18            footer_style: Style::default().fg(Color::DarkGray),
19        }
20    }
21
22    pub fn with_icon(mut self, icon: impl Into<String>) -> Self {
23        self.icon = Some(icon.into());
24        self
25    }
26
27    pub fn with_padding(mut self, top: u16, right: u16, bottom: u16, left: u16) -> Self {
28        self.padding = (top, right, bottom, left);
29        self
30    }
31
32    pub fn with_uniform_padding(mut self, padding: u16) -> Self {
33        self.padding = (padding, padding, padding, padding);
34        self
35    }
36
37    pub fn with_text_footer(mut self, footer: Line<'a>) -> Self {
38        self.text_footer = Some(footer);
39        self
40    }
41
42    pub fn with_footer_height(mut self, height: u16) -> Self {
43        self.footer_height = height;
44        self
45    }
46
47    pub fn border_style(mut self, style: Style) -> Self {
48        self.border_style = style;
49        self
50    }
51
52    pub fn border_type(mut self, border_type: BorderType) -> Self {
53        self.border_type = border_type;
54        self
55    }
56
57    pub fn title_style(mut self, style: Style) -> Self {
58        self.title_style = style;
59        self
60    }
61
62    pub fn footer_style(mut self, style: Style) -> Self {
63        self.footer_style = style;
64        self
65    }
66}