From d2d03f563957d2689b107c61cbb5410ba26530ef Mon Sep 17 00:00:00 2001 From: Valentin271 Date: Sun, 4 Feb 2024 16:46:37 +0100 Subject: [PATCH] chore: update ratatui to 0.26 --- Cargo.toml | 3 ++- examples/pixel_size.rs | 9 ++++----- examples/stopwatch.rs | 34 ++++++++++++++-------------------- 3 files changed, 20 insertions(+), 26 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 52d685a..d90be66 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ keywords = ["cli", "console", "ratatui", "terminal", "tui"] derive_builder = "0.13.0" font8x8 = "0.3.1" itertools = "0.12.0" -ratatui = "0.25.0" +ratatui = ">=0.25.0" [dev-dependencies] anyhow = "1.0.44" @@ -22,3 +22,4 @@ crossterm = { version = "0.27.0", features = ["event-stream"] } futures = "0.3" strum = { version = "0.26.1", features = ["derive"] } tokio = { version = "1.16", features = ["full"] } +ratatui = "0.26.0" diff --git a/examples/pixel_size.rs b/examples/pixel_size.rs index 4c6968c..639cb45 100644 --- a/examples/pixel_size.rs +++ b/examples/pixel_size.rs @@ -25,11 +25,10 @@ fn main() -> Result<()> { fn render(frame: &mut Frame) -> Result<()> { // Setup layout for 4 blocks use Constraint::*; - let layout = - Layout::new(Direction::Vertical, [Length(8), Length(4), Length(8)]).split(frame.size()); - let [top, middle, bottom] = [layout[0], layout[1], layout[2]]; - let bottom_layout = Layout::new(Direction::Horizontal, [Length(32), Length(32)]).split(bottom); - let [bottom_left, bottom_right] = [bottom_layout[0], bottom_layout[1]]; + let [top, middle, bottom] = + Layout::new(Direction::Vertical, [Length(8), Length(4), Length(8)]).areas(frame.size()); + let [bottom_left, bottom_right] = + Layout::new(Direction::Horizontal, [Length(32), Length(32)]).areas(bottom); // render one block for each font size // Draw block showing Full size diff --git a/examples/stopwatch.rs b/examples/stopwatch.rs index d40382c..2a0f964 100644 --- a/examples/stopwatch.rs +++ b/examples/stopwatch.rs @@ -128,9 +128,7 @@ impl StopwatchApp { fn fps_paragraph(&mut self) -> Paragraph<'_> { let fps = format!("{:.2} fps", self.fps_counter.fps); - Paragraph::new(fps) - .style(Style::new().dim()) - .alignment(Alignment::Right) + Paragraph::new(fps).dim().right_aligned() } fn timer_paragraph(&mut self) -> BigText<'_> { @@ -187,23 +185,19 @@ impl StopwatchApp { } fn layout(area: Rect) -> Vec { - let layout = Layout::default() - .direction(Direction::Vertical) - .constraints(vec![ - Constraint::Length(2), // top bar - Constraint::Length(8), // timer - Constraint::Length(1), // splits header - Constraint::Min(0), // splits - Constraint::Length(1), // help - ]) - .split(area); - let top_layout = Layout::default() - .direction(Direction::Horizontal) - .constraints(vec![ - Constraint::Length(20), // title - Constraint::Min(0), // fps counter - ]) - .split(layout[0]); + let layout = Layout::vertical(vec![ + Constraint::Length(2), // top bar + Constraint::Length(8), // timer + Constraint::Length(1), // splits header + Constraint::Min(0), // splits + Constraint::Length(1), // help + ]) + .split(area); + let top_layout = Layout::horizontal(vec![ + Constraint::Length(20), // title + Constraint::Min(0), // fps counter + ]) + .split(layout[0]); // return a new vec with the top_layout rects and then rest of layout top_layout[..]