pub struct Panel<'a> { /* private fields */ }Expand description
A bordered panel: a filled background with a box border and an optional title in the top edge.
border_style (the box outline and title) and fill_style (the
interior background) both default to Style::new(); there is no
title by default, and the title (if any) defaults to Align::Center.
Set whichever of these a caller needs via
Panel::border_style/Panel::fill_style/Panel::title/Panel::title_align.
§Examples
use retroglyph_core::{Headless, Rect, Terminal};
use retroglyph_widgets::{Panel, Widget};
let mut term = Terminal::new(Headless::new(20, 5));
Panel::new().title("Status").render(Rect::new(0, 0, 20, 5), &mut term);Implementations§
Source§impl<'a> Panel<'a>
impl<'a> Panel<'a>
Sourcepub const fn title_align(self, align: Align) -> Self
pub const fn title_align(self, align: Align) -> Self
Set how the title is aligned along the top border. Defaults to
Align::Center.
Sourcepub const fn border_style(self, style: Style) -> Self
pub const fn border_style(self, style: Style) -> Self
Set the box outline and title’s style.
Sourcepub const fn fill_style(self, style: Style) -> Self
pub const fn fill_style(self, style: Style) -> Self
Set the interior background’s style.
Sourcepub fn theme(self, theme: Theme) -> Self
pub fn theme(self, theme: Theme) -> Self
Applies theme’s named roles to this panel’s border and fill: border_style becomes
theme.border on theme.title_bg (the same background the title, if any, is drawn on),
and fill_style becomes theme.panel_bg.
Like every other builder method here, whichever call comes last wins – call .theme(...)
before any manual Panel::border_style/Panel::fill_style override you want to keep.
Sourcepub fn theme_on(self, theme: Theme, bg: Color) -> Self
pub fn theme_on(self, theme: Theme, bg: Color) -> Self
Same as Panel::theme, but fill_style is drawn on bg instead of theme.panel_bg –
for a panel whose interior should read as a different surface than theme.panel_bg
(border_style still uses theme.title_bg, unaffected by bg). Panel::theme is
exactly theme_on(theme, theme.panel_bg).