From: Huck Boles Date: Tue, 30 May 2023 01:59:52 +0000 (-0500) Subject: added: layout structure X-Git-Url: https://git.huck.website/?a=commitdiff_plain;h=a55f58e5fc988ace92d2f6d13a81cee931c77ec2;p=cellseq.git added: layout structure --- 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, + }) + } +}