Add dynamic render call to Frame

pull/667/head
kroonhorstdino-raldir-hp 2 years ago
parent a6b25a4877
commit c8984e5127

@ -101,6 +101,10 @@ where
widget.render(area, self.terminal.current_buffer_mut());
}
pub fn render_widget_dynamic(&mut self, widget : &dyn Widget, area: Rect) {
widget.render(area, self.terminal.current_buffer_mut());
}
/// Render a [`StatefulWidget`] to the current buffer using [`StatefulWidget::render`].
///
/// The last argument should be an instance of the [`StatefulWidget::State`] associated to the
@ -321,4 +325,4 @@ where
pub fn size(&self) -> io::Result<Rect> {
self.backend.size()
}
}
}

@ -64,7 +64,7 @@ bitflags! {
pub trait Widget {
/// Draws the current state of the widget in the given buffer. That is the only method required
/// to implement a custom widget.
fn render(self, area: Rect, buf: &mut Buffer);
fn render(&self, area: Rect, buf: &mut Buffer);
}
/// A `StatefulWidget` is a widget that can take advantage of some local state to remember things
@ -181,4 +181,4 @@ pub trait Widget {
pub trait StatefulWidget {
type State;
fn render(self, area: Rect, buf: &mut Buffer, state: &mut Self::State);
}
}
Loading…
Cancel
Save