mirror of
https://github.com/ratatui-org/ratatui
synced 2024-11-10 07:04:17 +00:00
815757fcbb
Many widgets can be rendered without changing their state. This commit implements The `Widget` trait for references to widgets and changes their implementations to be immutable. This allows us to render widgets without consuming them by passing a ref to the widget when calling `Frame::render_widget()`. ```rust // this might be stored in a struct let paragraph = Paragraph::new("Hello world!"); let [left, right] = area.split(&Layout::horizontal([20, 20])); frame.render_widget(¶graph, left); frame.render_widget(¶graph, right); // we can reuse the widget ``` Implemented for all widgets except BarChart (which has an implementation that modifies the internal state and requires a rewrite to fix. Other widgets will be implemented in follow up commits. Fixes: https://github.com/ratatui-org/ratatui/discussions/164 Replaces PRs: https://github.com/ratatui-org/ratatui/pull/122 and https://github.com/ratatui-org/ratatui/pull/16 Enables: https://github.com/ratatui-org/ratatui/issues/132 Validated as a viable working solution by: https://github.com/ratatui-org/ratatui/pull/836 |
||
---|---|---|
.. | ||
backend_termion.rs | ||
border_macro.rs | ||
state_serde.rs | ||
stylize.rs | ||
terminal.rs | ||
widgets_barchart.rs | ||
widgets_block.rs | ||
widgets_calendar.rs | ||
widgets_canvas.rs | ||
widgets_chart.rs | ||
widgets_gauge.rs | ||
widgets_list.rs | ||
widgets_paragraph.rs | ||
widgets_table.rs | ||
widgets_tabs.rs |