mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
wip: reworking phat cell overlap
This commit is contained in:
parent
854f198e36
commit
77809ca289
2 changed files with 57 additions and 64 deletions
|
|
@ -295,39 +295,43 @@ impl Tek {
|
|||
let size_h = self.size.h();
|
||||
let editing = self.is_editing();
|
||||
let tracks = move||self.tracks_sizes(editing, self.editor_w());
|
||||
let scenes = move||self.scenes_sizes(editing, 2, 15);
|
||||
let selected_track = self.selected().track();
|
||||
let selected_scene = self.selected().scene();
|
||||
let header = move||{
|
||||
let last_color = Arc::new(RwLock::new(ItemPalette::G[0]));
|
||||
let header = move||{
|
||||
let cell = {
|
||||
let last_color = last_color.clone();
|
||||
move|i, color: &ItemPalette, name: Arc<str>|phat_sel_3(
|
||||
self.selected().scene() == Some(i),
|
||||
Tui::bold(true, Bsp::e("🭬", name.clone())),
|
||||
Tui::bold(true, Bsp::e("🭬", name)),
|
||||
if i == 0 { Some(Reset) }
|
||||
else if self.selected().scene() == Some(i) { None }
|
||||
else { Some(last_color.read().unwrap().base.rgb) },
|
||||
if self.selected().scene() == Some(i+1) { color.light } else { color.base }.rgb,
|
||||
Some(Reset)
|
||||
)
|
||||
move|i, color: &ItemPalette, last: Option<ItemPalette>, name: Arc<str>|Phat {
|
||||
width: 0,
|
||||
height: 0,
|
||||
selected: self.selected().scene() == Some(i),
|
||||
content: Tui::bold(true, Bsp::e("🭬", name.clone())),
|
||||
fg: color.lightest.rgb,
|
||||
top: if self.selected().scene() == Some(i) { last.map(|last|last.light.rgb) } else { last.map(|last|last.base.rgb) },
|
||||
mid: if self.selected().scene() == Some(i+1) { color.light } else { color.base }.rgb,
|
||||
low: Some(Reset)
|
||||
}
|
||||
};
|
||||
Align::y(Map::new(scenes, move|(_, scene, y1, y2), s| {
|
||||
Align::y(Map::new(move||self.scenes_sizes(editing, 2, 15)
|
||||
.map(|(s, scene, y1, y2)|(s, scene, y1, y2, if s == 0 {
|
||||
None
|
||||
} else {
|
||||
Some(self.scenes[s-1].color)
|
||||
})), move|(_, scene, y1, y2, last), s| {
|
||||
let height = (1 + y2 - y1) as u16;
|
||||
*last_color.write().unwrap() = scene.color;
|
||||
Either(y2 > size_h, (), map_south(y1 as u16, height,
|
||||
Fixed::y(height, Outer(false, bstyle)
|
||||
.enclose(cell(s, &scene.color, scene.name.clone())))))
|
||||
.enclose(cell(s, &scene.color, last, scene.name.clone())))))
|
||||
})).boxed()
|
||||
};
|
||||
let content: ThunkBox<_> = per_track!(self.size.w(); |self, track, t|{
|
||||
let tab = " Tab ";
|
||||
let last_color = self.fmtd.read().unwrap().last_color.clone();
|
||||
let same_track = selected_track == Some(t+1);
|
||||
Map::new(scenes, move|(_, scene, y1, y2), s| {
|
||||
Map::new(move||self.scenes_sizes(editing, 2, 15)
|
||||
.map(|(s, scene, y1, y2)|(s, scene, y1, y2, if s == 0 {
|
||||
None
|
||||
} else {
|
||||
Some(self.scenes[s-1].color)
|
||||
})), move|(_, scene, y1, y2, last), s| {
|
||||
let height = (1 + y2 - y1) as u16;
|
||||
let last_color = last_color.clone();
|
||||
Thunk::new(move||{
|
||||
let mut fg = Tui::g(64);
|
||||
let mut bg = ItemPalette::G[32];
|
||||
|
|
@ -340,14 +344,11 @@ impl Tek {
|
|||
let selected = same_track && selected_scene == Some(s+1);
|
||||
let neighbor = same_track && selected_scene == Some(s);
|
||||
let active = editing && selected;
|
||||
let top = if s == 0 {
|
||||
Some(Reset)
|
||||
} else if neighbor {
|
||||
Some(last_color.read().unwrap().light.rgb)
|
||||
let top = if neighbor {
|
||||
last.map(|last|last.light.rgb)
|
||||
} else {
|
||||
Some(last_color.read().unwrap().base.rgb)
|
||||
last.map(|last|last.base.rgb)
|
||||
};
|
||||
*last_color.write().unwrap() = bg;
|
||||
let label = move||{
|
||||
let clip = scene.clips[t].clone();
|
||||
let icon = " ⏹ ";
|
||||
|
|
@ -363,14 +364,21 @@ impl Tek {
|
|||
&self.editor)),
|
||||
Thunk::new(move||Bsp::a(
|
||||
When::new(selected, Fill::y(Align::n(button(tab, "edit")))),
|
||||
phat_sel_3(
|
||||
Phat {
|
||||
width: 0,
|
||||
height: 3,
|
||||
selected,
|
||||
label(),
|
||||
label(),
|
||||
content: {
|
||||
let clip = scene.clips[t].clone();
|
||||
let icon = " ⏹ ";
|
||||
let name = clip.map(|c|c.read().unwrap().name.clone());
|
||||
Align::nw(Tui::fg(fg, Bsp::e(icon, Bsp::e(Tui::bold(true, name), " "))))
|
||||
},
|
||||
fg,
|
||||
top,
|
||||
if selected { bg.light } else { bg.base }.rgb,
|
||||
Some(Reset)
|
||||
))))))))
|
||||
mid: if selected { bg.light } else { bg.base }.rgb,
|
||||
low: Some(Reset)
|
||||
})))))))
|
||||
})
|
||||
})
|
||||
});
|
||||
|
|
|
|||
|
|
@ -110,13 +110,15 @@ impl Content<TuiOut> for RepeatH<'_> {
|
|||
|
||||
/// A cell that takes up 3 rows on its own,
|
||||
/// but stacks, giving (N+1)*2 rows per N cells.
|
||||
pub struct Phat<T: Content<T>> {
|
||||
pub width: u16,
|
||||
pub height: u16,
|
||||
pub content: T,
|
||||
pub top: Option<Color>,
|
||||
pub mid: Option<Color>,
|
||||
pub low: Option<Color>,
|
||||
pub struct Phat<T> {
|
||||
pub width: u16,
|
||||
pub height: u16,
|
||||
pub content: T,
|
||||
pub fg: Color,
|
||||
pub top: Option<Color>,
|
||||
pub mid: Color,
|
||||
pub low: Option<Color>,
|
||||
pub selected: bool
|
||||
}
|
||||
impl<T> Phat<T> {
|
||||
/// A phat line
|
||||
|
|
@ -128,32 +130,15 @@ impl<T> Phat<T> {
|
|||
Fixed::y(1, Tui::fg_bg(fg, bg, RepeatH(&"▀")))
|
||||
}
|
||||
}
|
||||
impl<T: Content<T>> for Phat<T> {
|
||||
fn content () -> impl Render<T> {
|
||||
Bsp::s(Self::lo(color.base.rgb, last.base.rgb),
|
||||
Bsp::n(Self::hi(color.base.rgb, last.base.rgb),
|
||||
Fixed::y(1, Fill::x(Tui::fg_bg(color.lightest.rgb, color.base.rgb, field))),
|
||||
)
|
||||
)
|
||||
impl<T: Content<TuiOut>> Content<TuiOut> for Phat<T> {
|
||||
fn content (&self) -> impl Render<TuiOut> {
|
||||
let top = self.top.map(|top|Self::lo(self.mid, top));
|
||||
let low = self.low.map(|low|Self::hi(self.mid, low));
|
||||
let content = Tui::fg_bg(self.fg, self.mid, &self.content);
|
||||
let phat = Bsp::s(top, Bsp::n(low, Fill::xy(content)));
|
||||
Min::xy(self.width, self.height, phat)
|
||||
}
|
||||
}
|
||||
pub fn phat_sel_3 <T: Content<TuiOut>> (
|
||||
selected: bool, field_1: T, field_2: T,
|
||||
top: Option<Color>,
|
||||
mid: Color,
|
||||
low: Option<Color>,
|
||||
) -> impl Content<TuiOut> {
|
||||
let border = Style::default().fg(Color::Rgb(255,255,255)).bg(mid);
|
||||
let top = top.map(|top|phat_lo(mid, top));
|
||||
let low = low.map(|low|phat_hi(mid, low));
|
||||
let a = Tui::bg(mid, Outer(true, border).enclose(Align::w(Bsp::s("", Bsp::n("", Fill::y(field_1))))));
|
||||
let b = Bsp::s(Fixed::y(1, top), Bsp::n(Fixed::y(1, low), Fill::xy(Tui::bg(mid, field_2))));
|
||||
Either::new(selected, a, b)
|
||||
}
|
||||
pub struct PhatOverlapIterator<T: Content<T>, I: Iterator<Item=T>> {
|
||||
items: I,
|
||||
color: Color
|
||||
}
|
||||
|
||||
pub trait TuiStyle {
|
||||
fn fg <R: Content<TuiOut>> (color: Color, w: R) -> Foreground<R> {
|
||||
|
|
@ -423,7 +408,7 @@ border! {
|
|||
const S0: &'static str = "⎵";
|
||||
fn style (&self) -> Option<Style> { Some(self.1) }
|
||||
},
|
||||
Phat {
|
||||
Thick {
|
||||
"▄" "▄" "▄"
|
||||
"█" "█"
|
||||
"▀" "▀" "▀"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue