mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
add Bordered, need to fix Inset
This commit is contained in:
parent
418e662aaf
commit
49c892328a
2 changed files with 20 additions and 2 deletions
|
|
@ -408,6 +408,9 @@ pub trait TuiStyle: Widget<Engine = Tui> + Sized {
|
|||
fn background (self, color: Color) -> impl Widget<Engine = Tui> {
|
||||
Layers::new(move |add|{ add(&Background(color))?; add(&self) })
|
||||
}
|
||||
fn border (self, style: impl BorderStyle) -> impl Widget<Engine = Tui> {
|
||||
Bordered(style, self)
|
||||
}
|
||||
}
|
||||
impl<W: Widget<Engine = Tui>> TuiStyle for W {}
|
||||
|
||||
|
|
@ -457,8 +460,19 @@ impl<S: BorderStyle> Widget for Border<S> {
|
|||
Ok(())
|
||||
}
|
||||
}
|
||||
pub struct Bordered<S: BorderStyle, W: Widget<Engine = Tui>>(pub S, pub W);
|
||||
impl<S: BorderStyle, W: Widget<Engine = Tui>> Content for Bordered<S, W> {
|
||||
type Engine = Tui;
|
||||
fn content (&self) -> impl Widget<Engine = Tui> {
|
||||
let style = self.0;
|
||||
Layers::new(move|add|{
|
||||
add(&Border(style))?;
|
||||
add(&Inset::XY(1, 1, &self.1 as &dyn Widget<Engine = Tui>))
|
||||
}).fill_xy()
|
||||
}
|
||||
}
|
||||
|
||||
pub trait BorderStyle: Send + Sync {
|
||||
pub trait BorderStyle: Send + Sync + Copy {
|
||||
const NW: &'static str = "";
|
||||
const N: &'static str = "";
|
||||
const NE: &'static str = "";
|
||||
|
|
@ -553,6 +567,7 @@ macro_rules! border {
|
|||
const SE: &'static str = $se;
|
||||
$($x)*
|
||||
}
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct $T(pub Style);
|
||||
impl Widget for $T {
|
||||
type Engine = Tui;
|
||||
|
|
|
|||
|
|
@ -1431,7 +1431,10 @@ impl Content for Sequencer<Tui> {
|
|||
row!(toolbar, content)
|
||||
.fill_x()
|
||||
//.inset_x(1)
|
||||
.background(Color::Rgb(50,40,30))
|
||||
.background(Color::Rgb(40,50,30))
|
||||
.border(Lozenge(Style::default()
|
||||
.bg(Color::Rgb(40,50,30))
|
||||
.fg(Color::Rgb(70,80,50))))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue