diff options
author | ClementTsang <clementjhtsang@gmail.com> | 2019-09-08 14:14:50 -0400 |
---|---|---|
committer | ClementTsang <clementjhtsang@gmail.com> | 2019-09-08 14:14:50 -0400 |
commit | d80c2387fb70f6a2c1234b211cf677711e280cba (patch) | |
tree | a6c92441de035e35eb24d69afde0d105675ccc5d | |
parent | 8b1e48a6b4cd72aab75c8f0db688c6d70cda3966 (diff) |
Setup layout.
-rw-r--r-- | src/window/mod.rs | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/src/window/mod.rs b/src/window/mod.rs index 585767c0..bfb6a46f 100644 --- a/src/window/mod.rs +++ b/src/window/mod.rs @@ -13,7 +13,40 @@ pub fn create_terminal() -> Result<(), io::Error> { let mut terminal = Terminal::new(backend)?; terminal.clear()?; terminal.draw(|mut f| { - let size = f.size(); - Block::default().title("CPU Usage").borders(Borders::ALL).render(&mut f, size); + let vertical_chunks = Layout::default() + .direction(Direction::Vertical) + .margin(1) + .constraints([Constraint::Percentage(33), Constraint::Percentage(34), Constraint::Percentage(33)].as_ref()) + .split(f.size()); + let top_chunks = Layout::default() + .direction(Direction::Horizontal) + .margin(0) + .constraints([Constraint::Percentage(50), Constraint::Percentage(50)].as_ref()) + .split(vertical_chunks[0]); + let middle_chunks = Layout::default() + .direction(Direction::Horizontal) + .margin(0) + .constraints([Constraint::Percentage(40), Constraint::Percentage(60)].as_ref()) + .split(vertical_chunks[1]); + let middle_divided_chunk = Layout::default() + .direction(Direction::Vertical) + .margin(0) + .constraints([Constraint::Percentage(50), Constraint::Percentage(50)].as_ref()) + .split(middle_chunks[0]); + let bottom_chunks = Layout::default() + .direction(Direction::Horizontal) + .margin(0) + .constraints([Constraint::Percentage(50), Constraint::Percentage(50)].as_ref()) + .split(vertical_chunks[2]); + + Block::default().title("CPU Usage").borders(Borders::ALL).render(&mut f, top_chunks[0]); + Block::default().title("Memory Usage").borders(Borders::ALL).render(&mut f, top_chunks[1]); + + Block::default().title("Temperatures").borders(Borders::ALL).render(&mut f, middle_divided_chunk[0]); + Block::default().title("Disk Usage").borders(Borders::ALL).render(&mut f, middle_divided_chunk[1]); + Block::default().title("IO Usage").borders(Borders::ALL).render(&mut f, middle_chunks[1]); + + Block::default().title("Network").borders(Borders::ALL).render(&mut f, bottom_chunks[0]); + Block::default().title("Processes").borders(Borders::ALL).render(&mut f, bottom_chunks[1]); }) } |