pub trait Widget {
// Required methods
fn draw(&mut self, buf: &mut Buffer);
fn get_area(&self) -> Rect;
// Provided methods
fn background(&self, buf: &mut Buffer, color: Color) { ... }
fn render<B>(&mut self, f: &mut Frame<'_, B>)
where Self: Sized,
B: Backend { ... }
fn top(&self) -> u16 { ... }
fn bottom(&self) -> u16 { ... }
fn left(&self) -> u16 { ... }
fn right(&self) -> u16 { ... }
}
Expand description
Base requirements for a Widget
Required Methods§
Sourcefn draw(&mut self, buf: &mut Buffer)
fn draw(&mut self, buf: &mut Buffer)
Draws the current state of the widget in the given buffer. That the only method required to implement a custom widget.
fn get_area(&self) -> Rect
Provided Methods§
Sourcefn background(&self, buf: &mut Buffer, color: Color)
fn background(&self, buf: &mut Buffer, color: Color)
Helper method to quickly set the background of all cells inside the specified area.
Sourcefn render<B>(&mut self, f: &mut Frame<'_, B>)
fn render<B>(&mut self, f: &mut Frame<'_, B>)
Helper method that can be chained with a widget’s builder methods to render it.