pub struct Block<'a> { /* private fields */ }Expand description
A widget that draws a block with optional borders, title, and padding.
Implementations§
Source§impl<'a> Block<'a>
impl<'a> Block<'a>
Sourcepub fn styled(sheet: &StyleSheet, name: &str) -> Self
pub fn styled(sheet: &StyleSheet, name: &str) -> Self
Create a new block styled from a StyleSheet by name.
Sets the block’s inner style to sheet.get_or_default(name) and composes
its border style from [name, format!("{name}{BLOCK_BORDER_SUFFIX}")]
(e.g. ["heading", "heading.border"]), allowing a border-specific style
to override base properties.
Subsequent calls to style or
border_style will override these values.
Sourcepub fn with_stylesheet(self, sheet: &StyleSheet, name: &str) -> Self
pub fn with_stylesheet(self, sheet: &StyleSheet, name: &str) -> Self
Apply styles from a StyleSheet to this block.
Sets the block’s inner style to sheet.get_or_default(name) and composes
its border style from [name, format!("{name}{BLOCK_BORDER_SUFFIX}")]
(e.g. ["heading", "heading.border"]), allowing a border-specific style
to override base properties.
Subsequent calls to style or
border_style will override these values.
Sourcepub fn border_style(self, style: Style) -> Self
pub fn border_style(self, style: Style) -> Self
Set the style applied to border characters.
Sourcepub fn border_type(self, border_type: BorderType) -> Self
pub fn border_type(self, border_type: BorderType) -> Self
Set the border character set (e.g. square, rounded, double).
Sourcepub fn title_text(&self) -> Option<&str>
pub fn title_text(&self) -> Option<&str>
Return the title text, if any.
Sourcepub fn title_alignment(self, alignment: Alignment) -> Self
pub fn title_alignment(self, alignment: Alignment) -> Self
Set the horizontal alignment of the title.
Sourcepub fn inner(&self, area: Rect) -> Rect
pub fn inner(&self, area: Rect) -> Rect
Compute the inner area inside the block’s borders and padding.
Sourcepub fn chrome_size(&self) -> (u16, u16)
pub fn chrome_size(&self) -> (u16, u16)
Calculate the chrome (border + padding) size consumed by this block.
Returns (horizontal_chrome, vertical_chrome) representing the
total width and height consumed by borders and padding.