Trait Widget

Source
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§

Source

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.

Source

fn get_area(&self) -> Rect

Provided Methods§

Source

fn background(&self, buf: &mut Buffer, color: Color)

Helper method to quickly set the background of all cells inside the specified area.

Source

fn render<B>(&mut self, f: &mut Frame<'_, B>)
where Self: Sized, B: Backend,

Helper method that can be chained with a widget’s builder methods to render it.

Source

fn top(&self) -> u16

Source

fn bottom(&self) -> u16

Source

fn left(&self) -> u16

Source

fn right(&self) -> u16

Implementors§

Source§

impl<'a, 't, 'b, T, MSG> Widget for Paragraph<'a, 't, T, MSG>
where T: Iterator<Item = &'t Text<'t>>, MSG: 'static,

Source§

impl<'a, MSG> Widget for Block<'a, MSG>

Source§

impl<'a, T, H, I, D, R, MSG> Widget for Table<'a, T, H, I, D, R, MSG>
where T: Display, H: Iterator<Item = T>, I: Display, D: Iterator<Item = I>, R: Iterator<Item = Row<D, I>>, MSG: 'static,

Source§

impl<'a, T, MSG> Widget for Tabs<'a, T, MSG>
where T: AsRef<str>, MSG: 'static,

Source§

impl<'b, L, MSG> Widget for List<'b, L, MSG>
where L: Iterator<Item = Text<'b>>, MSG: 'static,

Source§

impl<'b, MSG> Widget for SelectableList<'b, MSG>
where MSG: Clone + 'static,

Source§

impl<MSG> Widget for Button<MSG>
where MSG: 'static,