Skip to main content

Panel

Struct Panel 

Source
pub struct Panel { /* private fields */ }
Expand description

A bordered box around a renderable. Mirrors rich.panel.Panel.

Implementations§

Source§

impl Panel

Source

pub fn new(child: Box<dyn Renderable>) -> Self

A panel around child with default box (ROUNDED) and padding (0,1).

Source

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).

Source

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.

Source

pub fn width(self, width: usize) -> Self

A fixed width for the whole panel, borders included (upstream width), capped at the available width.

Source

pub fn title(self, title: impl Into<String>) -> Self

Set a title (drawn into the top border, centered by default).

Source

pub fn title_align(self, align: HorizontalAlign) -> Self

Set the title alignment within the top border.

Source

pub fn subtitle(self, subtitle: impl Into<String>) -> Self

Set a subtitle (drawn into the bottom border, centered by default).

Source

pub fn subtitle_align(self, align: HorizontalAlign) -> Self

Set the subtitle alignment within the bottom border.

Source

pub fn box_set(self, box_set: BoxSet) -> Self

Choose the box-drawing set.

Source

pub fn padding(self, padding: (usize, usize, usize, usize)) -> Self

Set the inner padding (top, right, bottom, left).

Source

pub fn border_style(self, style: Style) -> Self

Set the border style.

Trait Implementations§

Source§

impl Renderable for Panel

Source§

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.

Source§

fn rich_render( &self, console: &Console, options: &ConsoleOptions, ) -> Vec<Segment>

Source§

fn fit_to_measurement(&self) -> bool

Whether a top-level 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.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Panel

§

impl !Send for Panel

§

impl !Sync for Panel

§

impl !UnwindSafe for Panel

§

impl Freeze for Panel

§

impl Unpin for Panel

§

impl UnsafeUnpin for Panel

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.