From 21554b3f6f93b4bc0bc3f76a471f46c99575c2f2 Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Wed, 7 Sep 2022 20:07:56 +0400 Subject: [PATCH] Move code to Rust --- src/geom.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/geom.rs b/src/geom.rs index 573745e..d7fc4ef 100644 --- a/src/geom.rs +++ b/src/geom.rs @@ -85,6 +85,14 @@ impl WinGeom { pub fn border_width(&self) -> c_int { self.border_width } + + pub fn total_width(&self) -> c_int { + self.basic.sizes.width + 2 * self.border_width + } + + pub fn total_height(&self) -> c_int { + self.basic.sizes.height + 2 * self.border_width + } } #[cfg(test)] @@ -107,4 +115,13 @@ mod tests { fn win_geom_default() { assert_eq!(WinGeom::default().border_width(), 0); } + + #[test] + fn win_geom_total_width_height() { + let sizes = Sizes::new(34, 56); + let basic_geom = BasicGeom::new(Default::default(), sizes); + let win_geom = WinGeom::new(basic_geom, 12); + assert_eq!(win_geom.total_width(), 58); + assert_eq!(win_geom.total_height(), 80); + } }