From f25ce49e77f4813b3c9e80fa61ba10cf7f9d24ef Mon Sep 17 00:00:00 2001 From: Joscha Date: Sat, 18 Feb 2023 02:49:52 +0100 Subject: [PATCH] Rename Layer parts --- src/widget.rs | 8 ++++---- src/widgets/layer.rs | 28 ++++++++++++++-------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/widget.rs b/src/widget.rs index d54cebd..97e5ee2 100644 --- a/src/widget.rs +++ b/src/widget.rs @@ -49,12 +49,12 @@ pub trait WidgetExt: Sized { Float::new(self) } - fn below(self, top: W) -> Layer { - Layer::new(self, top) + fn below(self, above: W) -> Layer { + Layer::new(self, above) } - fn above(self, bottom: W) -> Layer { - Layer::new(bottom, self) + fn above(self, below: W) -> Layer { + Layer::new(below, self) } fn padding(self) -> Padding { diff --git a/src/widgets/layer.rs b/src/widgets/layer.rs index 39cd9d7..cb1e4a9 100644 --- a/src/widgets/layer.rs +++ b/src/widgets/layer.rs @@ -3,17 +3,17 @@ use async_trait::async_trait; use crate::{AsyncWidget, Frame, Size, Widget}; pub struct Layer { - bottom: I1, - top: I2, + below: I1, + above: I2, } impl Layer { - pub fn new(bottom: I1, top: I2) -> Self { - Self { bottom, top } + pub fn new(below: I1, above: I2) -> Self { + Self { below, above } } - fn size(bottom: Size, top: Size) -> Size { - Size::new(bottom.width.max(top.width), bottom.height.max(top.height)) + fn size(below: Size, above: Size) -> Size { + Size::new(below.width.max(above.width), below.height.max(above.height)) } } @@ -28,14 +28,14 @@ where max_width: Option, max_height: Option, ) -> Result { - let bottom = self.bottom.size(frame, max_width, max_height)?; - let top = self.top.size(frame, max_width, max_height)?; + let bottom = self.below.size(frame, max_width, max_height)?; + let top = self.above.size(frame, max_width, max_height)?; Ok(Self::size(bottom, top)) } fn draw(self, frame: &mut Frame) -> Result<(), E> { - self.bottom.draw(frame)?; - self.top.draw(frame)?; + self.below.draw(frame)?; + self.above.draw(frame)?; Ok(()) } } @@ -52,14 +52,14 @@ where max_width: Option, max_height: Option, ) -> Result { - let bottom = self.bottom.size(frame, max_width, max_height).await?; - let top = self.top.size(frame, max_width, max_height).await?; + let bottom = self.below.size(frame, max_width, max_height).await?; + let top = self.above.size(frame, max_width, max_height).await?; Ok(Self::size(bottom, top)) } async fn draw(self, frame: &mut Frame) -> Result<(), E> { - self.bottom.draw(frame).await?; - self.top.draw(frame).await?; + self.below.draw(frame).await?; + self.above.draw(frame).await?; Ok(()) } }