mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
remove tek_proc; add Border
This commit is contained in:
parent
6624fb476c
commit
70cef99931
9 changed files with 103 additions and 81 deletions
10
Cargo.lock
generated
10
Cargo.lock
generated
|
|
@ -2544,26 +2544,16 @@ dependencies = [
|
|||
"suil-rs",
|
||||
"symphonia",
|
||||
"tek_core",
|
||||
"tek_proc",
|
||||
"vst",
|
||||
"wavers",
|
||||
"winit",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tek_proc"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"syn 2.0.77",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tek_sequencer"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"tek_core",
|
||||
"tek_proc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
|
|||
|
|
@ -36,26 +36,30 @@ impl Demo<Tui> {
|
|||
impl Content for Demo<Tui> {
|
||||
type Engine = Tui;
|
||||
fn content (&self) -> impl Widget<Engine = Tui> {
|
||||
Align::Center(Layers::new(|add|{
|
||||
let border_style = Style::default().fg(Color::Rgb(0,0,0));
|
||||
Align::Center(Layers::new(move|add|{
|
||||
|
||||
add(&Background(Color::Rgb(0,128,128)))?;
|
||||
|
||||
add(&Outset::XY(1, 1, Split::down(|add|{
|
||||
|
||||
add(&Layers::new(|add|{
|
||||
add(&Background(Color::Rgb(255,255,0)))?;
|
||||
add(&Background(Color::Rgb(128,96,0)))?;
|
||||
add(&Border(Square(border_style)))?;
|
||||
add(&Outset::XY(2, 1, "..."))?;
|
||||
Ok(())
|
||||
}))?;
|
||||
|
||||
add(&Layers::new(|add|{
|
||||
add(&Background(Color::Rgb(255,128,0)))?;
|
||||
add(&Background(Color::Rgb(128,64,0)))?;
|
||||
add(&Border(Lozenge(border_style)))?;
|
||||
add(&Outset::XY(4, 2, "---"))?;
|
||||
Ok(())
|
||||
}))?;
|
||||
|
||||
add(&Layers::new(|add|{
|
||||
add(&Background(Color::Rgb(128,128,0)))?;
|
||||
add(&Background(Color::Rgb(96,64,0)))?;
|
||||
add(&Border(SquareBold(border_style)))?;
|
||||
add(&Outset::XY(6, 3, "~~~"))?;
|
||||
Ok(())
|
||||
}))?;
|
||||
|
|
|
|||
|
|
@ -22,8 +22,8 @@ pub trait Area<N: Number>: Copy {
|
|||
fn y (&self) -> N;
|
||||
fn w (&self) -> N;
|
||||
fn h (&self) -> N;
|
||||
fn x2 (&self) -> N { self.x() + self.w() }
|
||||
fn y2 (&self) -> N { self.y() + self.h() }
|
||||
fn x2 (&self) -> N { self.x() + self.w() - 1.into() }
|
||||
fn y2 (&self) -> N { self.y() + self.h() - 1.into() }
|
||||
fn xywh (&self) -> [N;4] {
|
||||
[self.x(), self.y(), self.w(), self.h()]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -619,21 +619,35 @@ impl<T: Widget<Engine = Tui>> Widget for Outset<u16, T> {
|
|||
}.render(to)
|
||||
}
|
||||
}
|
||||
//impl<T: Widget<Engine = Tui>> Content for Outset<u16, T> {
|
||||
//type Engine = Tui;
|
||||
//fn content (&self) -> impl Widget<Engine = Tui> {
|
||||
//match *self {
|
||||
//Self::X(x, ref inner) =>
|
||||
//Grow::X(x + x, inner as &dyn Widget<Engine = Tui>),
|
||||
//Self::Y(y, ref inner) =>
|
||||
//Grow::Y(y + y, inner as &dyn Widget<Engine = Tui>),
|
||||
//Self::XY(x, y, ref inner) =>
|
||||
//Grow::XY(x, y, inner as &dyn Widget<Engine = Tui>),
|
||||
//}
|
||||
//}
|
||||
//}
|
||||
|
||||
pub trait BorderStyle {
|
||||
pub struct Border<S: BorderStyle>(pub S);
|
||||
|
||||
impl<S: BorderStyle> Widget for Border<S> {
|
||||
type Engine = Tui;
|
||||
fn layout (&self, to: [u16;4]) -> Perhaps<[u16;4]> {
|
||||
Outset::XY(1, 1, "").layout(to)
|
||||
}
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
let area = to.area();
|
||||
if area.w() > 2 && area.y() > 2 {
|
||||
to.blit(&self.0.nw(), area.x(), area.y(), self.0.style())?;
|
||||
to.blit(&self.0.ne(), area.x() + area.w() - 1, area.y(), self.0.style())?;
|
||||
to.blit(&self.0.sw(), area.x(), area.y() + area.h() - 1, self.0.style())?;
|
||||
to.blit(&self.0.se(), area.x() + area.w() - 1, area.y() + area.h() - 1, self.0.style())?;
|
||||
for x in area.x()+1..area.x()+area.w()-1 {
|
||||
to.blit(&self.0.n(), x, area.y(), self.0.style())?;
|
||||
to.blit(&self.0.s(), x, area.y() + area.h() - 1, self.0.style())?;
|
||||
}
|
||||
for y in area.y()+1..area.y()+area.h()-1 {
|
||||
to.blit(&self.0.w(), area.x(), y, self.0.style())?;
|
||||
to.blit(&self.0.e(), area.x() + area.w() - 1, y, self.0.style())?;
|
||||
}
|
||||
}
|
||||
Ok(Some(area))
|
||||
}
|
||||
}
|
||||
|
||||
pub trait BorderStyle: Send + Sync {
|
||||
const NW: &'static str = "";
|
||||
const N: &'static str = "";
|
||||
const NE: &'static str = "";
|
||||
|
|
@ -643,6 +657,31 @@ pub trait BorderStyle {
|
|||
const SW: &'static str = "";
|
||||
const W: &'static str = "";
|
||||
|
||||
fn n (&self) -> &str {
|
||||
Self::N
|
||||
}
|
||||
fn s (&self) -> &str {
|
||||
Self::S
|
||||
}
|
||||
fn e (&self) -> &str {
|
||||
Self::E
|
||||
}
|
||||
fn w (&self) -> &str {
|
||||
Self::W
|
||||
}
|
||||
fn nw (&self) -> &str {
|
||||
Self::NW
|
||||
}
|
||||
fn ne (&self) -> &str {
|
||||
Self::NE
|
||||
}
|
||||
fn sw (&self) -> &str {
|
||||
Self::SW
|
||||
}
|
||||
fn se (&self) -> &str {
|
||||
Self::SE
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn draw <'a> (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
self.draw_horizontal(to, None)?;
|
||||
|
|
@ -743,8 +782,11 @@ macro_rules! border {
|
|||
)+}
|
||||
}
|
||||
|
||||
pub struct Square(pub Style);
|
||||
pub struct SquareBold(pub Style);
|
||||
pub struct Tab(pub Style);
|
||||
pub struct Lozenge(pub Style);
|
||||
pub struct LozengeV(pub Style);
|
||||
pub struct Brace(pub Style);
|
||||
pub struct LozengeDotted(pub Style);
|
||||
pub struct Quarter(pub Style);
|
||||
pub struct QuarterV(pub Style);
|
||||
|
|
@ -752,6 +794,30 @@ pub struct Chamfer(pub Style);
|
|||
pub struct Corners(pub Style);
|
||||
|
||||
border! {
|
||||
Square {
|
||||
"┌" "─" "┐"
|
||||
"│" "│"
|
||||
"└" "─" "┘"
|
||||
fn style (&self) -> Option<Style> {
|
||||
Some(self.0)
|
||||
}
|
||||
},
|
||||
SquareBold {
|
||||
"┏" "━" "┓"
|
||||
"┃" "┃"
|
||||
"┗" "━" "┛"
|
||||
fn style (&self) -> Option<Style> {
|
||||
Some(self.0)
|
||||
}
|
||||
},
|
||||
Tab {
|
||||
"╭" "─" "╮"
|
||||
"│" "│"
|
||||
"│" " " "│"
|
||||
fn style (&self) -> Option<Style> {
|
||||
Some(self.0)
|
||||
}
|
||||
},
|
||||
Lozenge {
|
||||
"╭" "─" "╮"
|
||||
"│" "│"
|
||||
|
|
@ -760,7 +826,7 @@ border! {
|
|||
Some(self.0)
|
||||
}
|
||||
},
|
||||
LozengeV {
|
||||
Brace {
|
||||
"╭" "" "╮"
|
||||
"│" "│"
|
||||
"╰" "" "╯"
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ version = "0.1.0"
|
|||
|
||||
[dependencies]
|
||||
tek_core = { path = "../tek_core" }
|
||||
tek_proc = { path = "../tek_proc" }
|
||||
|
||||
livi = "0.7.4"
|
||||
suil-rs = { path = "../suil" }
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
[package]
|
||||
name = "tek_proc"
|
||||
edition = "2021"
|
||||
version = "0.1.0"
|
||||
|
||||
[lib]
|
||||
proc-macro = true
|
||||
|
||||
[dependencies]
|
||||
syn = { version = "2.0", features = ["full"] }
|
||||
quote = "1.0"
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
use proc_macro::TokenStream;
|
||||
use syn::{parse_macro_input, Attribute, Meta};
|
||||
|
||||
#[proc_macro_attribute]
|
||||
pub fn render (attr: TokenStream, item: TokenStream) -> TokenStream {
|
||||
println!("attr: \"{attr}\"");
|
||||
println!("item: \"{item}\"");
|
||||
let input = syn::parse_macro_input!(attr as Meta);
|
||||
panic!("attr: \"{input:?}\"");
|
||||
item
|
||||
}
|
||||
|
||||
#[proc_macro_attribute]
|
||||
pub fn handle (attr: TokenStream, item: TokenStream) -> TokenStream {
|
||||
println!("attr: \"{attr}\"");
|
||||
println!("item: \"{item}\"");
|
||||
item
|
||||
}
|
||||
|
|
@ -5,7 +5,6 @@ version = "0.1.0"
|
|||
|
||||
[dependencies]
|
||||
tek_core = { path = "../tek_core" }
|
||||
tek_proc = { path = "../tek_proc" }
|
||||
|
||||
[lib]
|
||||
path = "src/lib.rs"
|
||||
|
|
|
|||
|
|
@ -73,29 +73,22 @@ impl ArrangerStandalone<Tui> {
|
|||
}
|
||||
}
|
||||
|
||||
impl Widget for ArrangerStandalone<Tui> {
|
||||
impl Content for ArrangerStandalone<Tui> {
|
||||
type Engine = Tui;
|
||||
fn layout (&self, to: [u16;4]) -> Perhaps<[u16;4]> {
|
||||
Ok(Some(to))
|
||||
}
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
let area = to.area();
|
||||
let sequencer = self.arranger.sequencer()
|
||||
.map(|t|t as &dyn Widget<Engine = Tui>);
|
||||
let result = Split::down(|add|{
|
||||
fn content (&self) -> impl Widget<Engine = Tui> {
|
||||
Split::down(|add|{
|
||||
add(&self.transport)?;
|
||||
add(&self.arranger)?;
|
||||
add(&sequencer)?;
|
||||
if let Some(sequencer) = self.arranger.sequencer() {
|
||||
add(sequencer)?;
|
||||
}
|
||||
Ok(())
|
||||
})
|
||||
//.focus(Some(self.focus))
|
||||
.render(to)?;
|
||||
if let Some(ref modal) = self.arranger.modal {
|
||||
to.fill_bg(area, Nord::bg_lo(false, false));
|
||||
to.fill_fg(area, Nord::bg_hi(false, false));
|
||||
modal.render(to)?;
|
||||
}
|
||||
Ok(result)
|
||||
//if let Some(ref modal) = self.arranger.modal {
|
||||
//to.fill_bg(area, Nord::bg_lo(false, false));
|
||||
//to.fill_fg(area, Nord::bg_hi(false, false));
|
||||
//modal.render(to)?;
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue