Rename Layer parts
This commit is contained in:
parent
95a01d5fc8
commit
f25ce49e77
2 changed files with 18 additions and 18 deletions
|
|
@ -49,12 +49,12 @@ pub trait WidgetExt: Sized {
|
||||||
Float::new(self)
|
Float::new(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn below<W>(self, top: W) -> Layer<Self, W> {
|
fn below<W>(self, above: W) -> Layer<Self, W> {
|
||||||
Layer::new(self, top)
|
Layer::new(self, above)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn above<W>(self, bottom: W) -> Layer<W, Self> {
|
fn above<W>(self, below: W) -> Layer<W, Self> {
|
||||||
Layer::new(bottom, self)
|
Layer::new(below, self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn padding(self) -> Padding<Self> {
|
fn padding(self) -> Padding<Self> {
|
||||||
|
|
|
||||||
|
|
@ -3,17 +3,17 @@ use async_trait::async_trait;
|
||||||
use crate::{AsyncWidget, Frame, Size, Widget};
|
use crate::{AsyncWidget, Frame, Size, Widget};
|
||||||
|
|
||||||
pub struct Layer<I1, I2> {
|
pub struct Layer<I1, I2> {
|
||||||
bottom: I1,
|
below: I1,
|
||||||
top: I2,
|
above: I2,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<I1, I2> Layer<I1, I2> {
|
impl<I1, I2> Layer<I1, I2> {
|
||||||
pub fn new(bottom: I1, top: I2) -> Self {
|
pub fn new(below: I1, above: I2) -> Self {
|
||||||
Self { bottom, top }
|
Self { below, above }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn size(bottom: Size, top: Size) -> Size {
|
fn size(below: Size, above: Size) -> Size {
|
||||||
Size::new(bottom.width.max(top.width), bottom.height.max(top.height))
|
Size::new(below.width.max(above.width), below.height.max(above.height))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -28,14 +28,14 @@ where
|
||||||
max_width: Option<u16>,
|
max_width: Option<u16>,
|
||||||
max_height: Option<u16>,
|
max_height: Option<u16>,
|
||||||
) -> Result<Size, E> {
|
) -> Result<Size, E> {
|
||||||
let bottom = self.bottom.size(frame, max_width, max_height)?;
|
let bottom = self.below.size(frame, max_width, max_height)?;
|
||||||
let top = self.top.size(frame, max_width, max_height)?;
|
let top = self.above.size(frame, max_width, max_height)?;
|
||||||
Ok(Self::size(bottom, top))
|
Ok(Self::size(bottom, top))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw(self, frame: &mut Frame) -> Result<(), E> {
|
fn draw(self, frame: &mut Frame) -> Result<(), E> {
|
||||||
self.bottom.draw(frame)?;
|
self.below.draw(frame)?;
|
||||||
self.top.draw(frame)?;
|
self.above.draw(frame)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -52,14 +52,14 @@ where
|
||||||
max_width: Option<u16>,
|
max_width: Option<u16>,
|
||||||
max_height: Option<u16>,
|
max_height: Option<u16>,
|
||||||
) -> Result<Size, E> {
|
) -> Result<Size, E> {
|
||||||
let bottom = self.bottom.size(frame, max_width, max_height).await?;
|
let bottom = self.below.size(frame, max_width, max_height).await?;
|
||||||
let top = self.top.size(frame, max_width, max_height).await?;
|
let top = self.above.size(frame, max_width, max_height).await?;
|
||||||
Ok(Self::size(bottom, top))
|
Ok(Self::size(bottom, top))
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn draw(self, frame: &mut Frame) -> Result<(), E> {
|
async fn draw(self, frame: &mut Frame) -> Result<(), E> {
|
||||||
self.bottom.draw(frame).await?;
|
self.below.draw(frame).await?;
|
||||||
self.top.draw(frame).await?;
|
self.above.draw(frame).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue