From a55f58e5fc988ace92d2f6d13a81cee931c77ec2 Mon Sep 17 00:00:00 2001 From: Huck Boles Date: Mon, 29 May 2023 20:59:52 -0500 Subject: [PATCH] added: layout structure --- src/graphics/layout.rs | 51 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 src/graphics/layout.rs diff --git a/src/graphics/layout.rs b/src/graphics/layout.rs new file mode 100644 index 0000000..f4d2ae4 --- /dev/null +++ b/src/graphics/layout.rs @@ -0,0 +1,51 @@ +use crossterm::terminal; +use eyre::Result; + +use super::*; + +pub struct Area { + pub origin: Point, + pub max: Point, +} + +pub struct Layout { + pub screen: Area, + pub cells: Area, + pub mask: Area, + pub channels: Area, +} + +impl Layout { + pub fn build() -> Result { + let (col, row) = terminal::size()?; + let col: usize = col.into(); + let row: usize = row.into(); + + let screen = Area { + origin: Point::new(0, 0), + max: Point::new(col, row), + }; + + let cells = Area { + origin: Point::new(1, 1), + max: Point::new(col / 2 - 5, row / 2 - 2), + }; + + let mask = Area { + origin: Point::new(col / 2 + 5, 1), + max: Point::new(col - 2, row / 2 - 2), + }; + + let channels = Area { + origin: Point::new(1, row / 2 + 2), + max: Point::new(col - 2, row - 2), + }; + + Ok(Self { + screen, + cells, + mask, + channels, + }) + } +} -- 2.45.2