diff options
author | ClementTsang <cjhtsang@uwaterloo.ca> | 2021-09-07 21:40:47 -0400 |
---|---|---|
committer | ClementTsang <cjhtsang@uwaterloo.ca> | 2021-09-07 22:49:10 -0400 |
commit | 955840b412a341a08f582529064d31cc821ccff3 (patch) | |
tree | d92fca67fa6944cf9b9a09adf3cc310680b2f5b1 /src/app/widgets/bottom_widgets/disk.rs | |
parent | d8a6a2344e813bb72a21bac0b050a79ab595bd5f (diff) |
refactor: Add back scroll position and expanded
Diffstat (limited to 'src/app/widgets/bottom_widgets/disk.rs')
-rw-r--r-- | src/app/widgets/bottom_widgets/disk.rs | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/app/widgets/bottom_widgets/disk.rs b/src/app/widgets/bottom_widgets/disk.rs index 9d128475..1f5383da 100644 --- a/src/app/widgets/bottom_widgets/disk.rs +++ b/src/app/widgets/bottom_widgets/disk.rs @@ -48,6 +48,7 @@ pub struct DiskTable { width: LayoutRule, height: LayoutRule, block_border: Borders, + show_scroll_index: bool, } impl Default for DiskTable { @@ -69,6 +70,7 @@ impl Default for DiskTable { width: LayoutRule::default(), height: LayoutRule::default(), block_border: Borders::ALL, + show_scroll_index: false, } } } @@ -94,6 +96,12 @@ impl DiskTable { self } + + /// Sets whether to show the scroll index. + pub fn show_scroll_index(mut self, show_scroll_index: bool) -> Self { + self.show_scroll_index = show_scroll_index; + self + } } impl Component for DiskTable { @@ -121,15 +129,23 @@ impl Widget for DiskTable { fn draw<B: Backend>( &mut self, painter: &Painter, f: &mut Frame<'_, B>, area: Rect, selected: bool, + expanded: bool, ) { let block = self .block() .selected(selected) .borders(self.block_border) - .build(painter); - - self.table - .draw_tui_table(painter, f, &self.display_data, block, area, selected); + .expanded(expanded); + + self.table.draw_tui_table( + painter, + f, + &self.display_data, + block, + area, + selected, + self.show_scroll_index, + ); } fn update_data(&mut self, data_collection: &DataCollection) { |