add widget trait

This commit is contained in:
Clement Tsang 2024-01-01 22:36:11 -05:00
parent 9efe60c66f
commit 80b91b4eb8
No known key found for this signature in database
GPG Key ID: B17834EA2182446B
2 changed files with 13 additions and 0 deletions

View File

@ -13,3 +13,11 @@ pub use mem_graph::*;
pub use net_graph::*;
pub use process_table::*;
pub use temperature_table::*;
use tui::{layout::Rect, Frame};
/// A [`Widget`] converts raw data into something that a user can see and interact with.
pub trait Widget<Data> {
/// How to actually draw the widget to the terminal.
fn draw(&self, f: &mut Frame<'_>, draw_location: Rect, widget_id: u64);
}

View File

@ -0,0 +1,5 @@
#[derive(Default)]
pub struct BatteryWidgetState {
pub currently_selected_battery_index: usize,
pub tab_click_locs: Option<Vec<((u16, u16), (u16, u16))>>,
}