pub struct BoxBorder { /* private fields */ }Expand description
A single-line box border drawn around a Rect.
The interior of the rectangle is not touched. area must be at least
2×2, or Widget::render is a no-op. style defaults to Theme::DARK (as if
BoxBorder::theme had been called); set it with BoxBorder::style.
§Examples
use retroglyph_core::grid::{Grid, Rect};
use retroglyph_ui::widget::{BoxBorder, Widget};
use retroglyph_ui::Surface;
let area = Rect::new(0, 0, 10, 4);
let mut grid = Grid::new(10, 4);
BoxBorder::new().render(&mut Surface::new(&mut grid, area, 0));Implementations§
Source§impl BoxBorder
impl BoxBorder
Sourcepub fn new() -> Self
pub fn new() -> Self
A box border styled from Theme::DARK (as if BoxBorder::theme had been called); see
BoxBorder::style to override it.
Sourcepub const fn border_type(self, border_type: BorderType) -> Self
pub const fn border_type(self, border_type: BorderType) -> Self
Set which box-drawing glyphs the border is drawn with. Defaults to
BorderType::Plain.
Sourcepub fn theme(self, theme: Theme) -> Self
pub fn theme(self, theme: Theme) -> Self
Sets style to theme.border on theme.panel_bg.
The background is set explicitly for the same reason, and with the same caveat, as
super::Gauge::theme; see its doc comment for the full explanation. Unlike
super::Panel, which also owns and fills its own interior, a standalone BoxBorder
genuinely doesn’t know what it’s drawn over: theme.panel_bg is the closest default,
matching what a themed super::Panel/super::Modal around it would use. Drawing this
border directly on the raw screen background instead needs a manual BoxBorder::style
override afterwards.
Call before any manual BoxBorder::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 BoxBorder::theme, but style is drawn on bg instead of theme.panel_bg –
for a border drawn directly on a backdrop other than a themed super::Panel/
super::Modal’s fill. BoxBorder::theme is exactly theme_on(theme, theme.panel_bg).