pub struct Panel { /* private fields */ }Expand description
A bordered box around a renderable. Mirrors rich.panel.Panel.
Implementations§
Source§impl Panel
impl Panel
Sourcepub fn new(child: Box<dyn Renderable>) -> Self
pub fn new(child: Box<dyn Renderable>) -> Self
A panel around child with default box (ROUNDED) and padding (0,1).
Sourcepub fn fit(child: Box<dyn Renderable>) -> Self
pub fn fit(child: Box<dyn Renderable>) -> Self
A panel that fits its content rather than expanding to the available
width. Port of Panel.fit (expand=False).
Sourcepub fn expand(self, expand: bool) -> Self
pub fn expand(self, expand: bool) -> Self
Expand to the full available width (upstream expand, default on), or
fit the measured width of the content and title.
Sourcepub fn width(self, width: usize) -> Self
pub fn width(self, width: usize) -> Self
A fixed width for the whole panel, borders included (upstream width),
capped at the available width.
Sourcepub fn title(self, title: impl Into<String>) -> Self
pub fn title(self, title: impl Into<String>) -> Self
Set a title (drawn into the top border, centered by default).
Sourcepub fn title_align(self, align: HorizontalAlign) -> Self
pub fn title_align(self, align: HorizontalAlign) -> Self
Set the title alignment within the top border.
Sourcepub fn subtitle(self, subtitle: impl Into<String>) -> Self
pub fn subtitle(self, subtitle: impl Into<String>) -> Self
Set a subtitle (drawn into the bottom border, centered by default).
Sourcepub fn subtitle_align(self, align: HorizontalAlign) -> Self
pub fn subtitle_align(self, align: HorizontalAlign) -> Self
Set the subtitle alignment within the bottom border.
Sourcepub fn padding(self, padding: (usize, usize, usize, usize)) -> Self
pub fn padding(self, padding: (usize, usize, usize, usize)) -> Self
Set the inner padding (top, right, bottom, left).
Sourcepub fn border_style(self, style: Style) -> Self
pub fn border_style(self, style: Style) -> Self
Set the border style.
Trait Implementations§
Source§impl Renderable for Panel
impl Renderable for Panel
Source§fn measure(&self, console: &Console, options: &ConsoleOptions) -> Measurement
fn measure(&self, console: &Console, options: &ConsoleOptions) -> Measurement
Port of Panel.__rich_measure__: the widest of the content and the
title, measured inside the borders and padding, plus both; or the
fixed width. Either way the panel asks for exactly one width.
fn rich_render( &self, console: &Console, options: &ConsoleOptions, ) -> Vec<Segment>
Source§fn fit_to_measurement(&self) -> bool
fn fit_to_measurement(&self) -> bool
Console::print shrinks this renderable to its
measured width. Upstream renders every top-level renderable at the full
console width, so the default is false; an extension may opt in.