Kaynağa Gözat

map: split screen

lunar-mining 4 yıl önce
ebeveyn
işleme
fbb113b6c8
1 değiştirilmiş dosya ile 8 ekleme ve 3 silme
  1. 8 3
      bin/map/src/main.rs

+ 8 - 3
bin/map/src/main.rs

@@ -27,7 +27,12 @@ fn main() -> Result<()> {
         // Lock the terminal and start a drawing session.
         // Lock the terminal and start a drawing session.
         terminal.draw(|frame| {
         terminal.draw(|frame| {
             // Create a layout into which to place our blocks.
             // Create a layout into which to place our blocks.
-            let size = frame.size();
+            let chunks = Layout::default()
+                .direction(Direction::Vertical)
+                .constraints([Constraint::Percentage(6), Constraint::Percentage(94)].as_ref())
+                .split(frame.size());
+
+            //let size = frame.size();
 
 
             // The text lines for our text box.
             // The text lines for our text box.
             let txt = vec![Spans::from("\n Press q to quit.\n")];
             let txt = vec![Spans::from("\n Press q to quit.\n")];
@@ -39,7 +44,7 @@ fn main() -> Result<()> {
                 .style(Style::default().fg(Color::White).bg(Color::Black));
                 .style(Style::default().fg(Color::White).bg(Color::Black));
 
 
             // Render into the layout.
             // Render into the layout.
-            frame.render_widget(graph, size);
+            frame.render_widget(graph, chunks[0]);
 
 
             // create a list
             // create a list
             let mut items: Vec<ListItem> = Vec::new();
             let mut items: Vec<ListItem> = Vec::new();
@@ -55,7 +60,7 @@ fn main() -> Result<()> {
                 .highlight_symbol(">>");
                 .highlight_symbol(">>");
 
 
             // draw a list
             // draw a list
-            frame.render_widget(list, size);
+            frame.render_widget(list, chunks[1]);
         })?;
         })?;
 
 
         // Iterate over all the keys that have been pressed since the
         // Iterate over all the keys that have been pressed since the