liftof_tui/
layout.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//! Main laoyt of the app

use ratatui::layout::{
  Constraint,
  Direction,
  Layout,
  Rect
};

#[derive(Debug, Clone)]
pub struct MainLayout {
  pub menu : Rect,
  pub main : Rect,
  pub log  : Rect,
  pub help : Rect
}

impl MainLayout {

  pub fn new(size : Rect) -> MainLayout {
    let chunks = Layout::default()
    .direction(Direction::Vertical)
    //.margin(1)
    .constraints(
      [
        Constraint::Length(3),
        Constraint::Min(2),
        Constraint::Length(5),
      ]
      .as_ref(),
    )
    .split(size);
    // logs and help
    let logs_n_help = Layout::default()
    .direction(Direction::Horizontal)
    .constraints(
      [Constraint::Percentage(80),
       Constraint::Percentage(20)]
       .as_ref(),
    )
    .split(chunks[2]);  
    MainLayout {
      //rect : chunks.to_vec()
      menu : chunks[0],
      main : chunks[1],
      log  : logs_n_help[0],
      help : logs_n_help[1],
    }
  }
}