mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
align scene cells at both edges
This commit is contained in:
parent
7dc435754a
commit
76cefdca61
2 changed files with 37 additions and 25 deletions
|
|
@ -298,31 +298,33 @@ impl Tek {
|
||||||
let selected_track = self.selected().track();
|
let selected_track = self.selected().track();
|
||||||
let selected_scene = self.selected().scene();
|
let selected_scene = self.selected().scene();
|
||||||
let header = move||{
|
let header = move||{
|
||||||
let cell = move|s, bg: &ItemPalette, last: Option<ItemPalette>, name: Arc<str>|{
|
let cell = move|t, s, bg: &ItemPalette, last: Option<ItemPalette>, name: Arc<str>|{
|
||||||
let selected = self.selected().scene() == Some(s+1);
|
let selected = t && self.selected().scene() == Some(s+1);
|
||||||
let neighbor = self.selected().scene() == Some(s);
|
let neighbor = t && self.selected().scene() == Some(s);
|
||||||
Phat {
|
Phat {
|
||||||
width: 0,
|
width: 0,
|
||||||
height: 0,
|
height: 0,
|
||||||
selected: selected,
|
selected,
|
||||||
content: Tui::bold(true, Bsp::e("🭬", name.clone())),
|
content: Tui::bold(true, Bsp::e("🭬", name.clone())),
|
||||||
fg: bg.lightest.rgb,
|
colors: [
|
||||||
top: if neighbor { last.map(|last|last.light.rgb) } else { last.map(|last|last.base.rgb) },
|
bg.lightest.rgb,
|
||||||
mid: if selected { bg.light } else { bg.base }.rgb,
|
if selected { bg.light } else { bg.base }.rgb,
|
||||||
low: Some(Reset)
|
if neighbor { last.map(|last|last.light.rgb) } else { last.map(|last|last.base.rgb) }.unwrap_or(Reset),
|
||||||
|
Reset,
|
||||||
|
]
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Align::y(Map::new(
|
Align::y(Map::new(
|
||||||
move||self.scenes_sizes(editing, 2, 15).map_while(
|
move||self.scenes_sizes(editing, 2, 15).map_while(
|
||||||
move|(s, scene, y1, y2)|if y2 > size_h { None } else { Some((s, scene, y1, y2, if s == 0 {
|
move|(s, scene, y1, y2)|if y2 > size_h { None } else { Some((s, scene, y1, y2, if s == 0 {
|
||||||
Some(self.scenes[s].color)
|
None
|
||||||
} else {
|
} else {
|
||||||
Some(self.scenes[s-1].color)
|
Some(self.scenes[s-1].color)
|
||||||
})) }),
|
})) }),
|
||||||
move|(_, scene, y1, y2, last), s| {
|
move|(_, scene, y1, y2, last), s| {
|
||||||
let height = (1 + y2 - y1) as u16;
|
let height = (1 + y2 - y1) as u16;
|
||||||
map_south(y1 as u16, height, Fixed::y(height,
|
map_south(y1 as u16, height, Fixed::y(height,
|
||||||
cell(s, &scene.color, last, scene.name.clone()))) })).boxed()
|
cell(true, s, &scene.color, last, scene.name.clone()))) })).boxed()
|
||||||
};
|
};
|
||||||
let content: ThunkBox<_> = per_track!(self.size.w(); |self, track, t|{
|
let content: ThunkBox<_> = per_track!(self.size.w(); |self, track, t|{
|
||||||
let tab = " Tab ";
|
let tab = " Tab ";
|
||||||
|
|
@ -330,7 +332,7 @@ impl Tek {
|
||||||
Map::new(
|
Map::new(
|
||||||
move||self.scenes_sizes(editing, 2, 15).map_while(
|
move||self.scenes_sizes(editing, 2, 15).map_while(
|
||||||
move|(s, scene, y1, y2)|if y2 > size_h { None } else { Some((s, scene, y1, y2, if s == 0 {
|
move|(s, scene, y1, y2)|if y2 > size_h { None } else { Some((s, scene, y1, y2, if s == 0 {
|
||||||
self.scenes[s].clips[t].as_ref().map(|c|c.read().unwrap().color)
|
None
|
||||||
} else {
|
} else {
|
||||||
self.scenes[s-1].clips[t].as_ref().map(|c|c.read().unwrap().color)
|
self.scenes[s-1].clips[t].as_ref().map(|c|c.read().unwrap().color)
|
||||||
})) }),
|
})) }),
|
||||||
|
|
@ -364,10 +366,22 @@ impl Tek {
|
||||||
height: 0,
|
height: 0,
|
||||||
selected,
|
selected,
|
||||||
content: content(),
|
content: content(),
|
||||||
fg,
|
colors: [
|
||||||
top: if neighbor { last.map(|last|last.light.rgb) } else { last.map(|last|last.base.rgb) },
|
fg,
|
||||||
mid: if selected { bg.light } else { bg.base }.rgb,
|
if selected { bg.light } else { bg.base }.rgb,
|
||||||
low: Some(Reset)
|
if neighbor {
|
||||||
|
last.map(|last|last.light.rgb)
|
||||||
|
} else {
|
||||||
|
last.map(|last|last.base.rgb)
|
||||||
|
}.unwrap_or(Reset),
|
||||||
|
if s == self.scenes.len().saturating_sub(1) {
|
||||||
|
Reset
|
||||||
|
} else if selected {
|
||||||
|
bg.light.rgb
|
||||||
|
} else {
|
||||||
|
bg.base.rgb
|
||||||
|
},
|
||||||
|
],
|
||||||
})))))
|
})))))
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
use crate::Color::*;
|
||||||
macro_rules! impl_content_layout_render {
|
macro_rules! impl_content_layout_render {
|
||||||
($Output:ty: |$self:ident: $Struct:ty, $to:ident| layout = $layout:expr; render = $render:expr) => {
|
($Output:ty: |$self:ident: $Struct:ty, $to:ident| layout = $layout:expr; render = $render:expr) => {
|
||||||
impl Content<$Output> for $Struct {
|
impl Content<$Output> for $Struct {
|
||||||
|
|
@ -114,11 +115,8 @@ pub struct Phat<T> {
|
||||||
pub width: u16,
|
pub width: u16,
|
||||||
pub height: u16,
|
pub height: u16,
|
||||||
pub content: T,
|
pub content: T,
|
||||||
pub fg: Color,
|
pub colors: [Color;4],
|
||||||
pub top: Option<Color>,
|
pub selected: bool,
|
||||||
pub mid: Color,
|
|
||||||
pub low: Option<Color>,
|
|
||||||
pub selected: bool
|
|
||||||
}
|
}
|
||||||
impl<T> Phat<T> {
|
impl<T> Phat<T> {
|
||||||
/// A phat line
|
/// A phat line
|
||||||
|
|
@ -132,11 +130,11 @@ impl<T> Phat<T> {
|
||||||
}
|
}
|
||||||
impl<T: Content<TuiOut>> Content<TuiOut> for Phat<T> {
|
impl<T: Content<TuiOut>> Content<TuiOut> for Phat<T> {
|
||||||
fn content (&self) -> impl Render<TuiOut> {
|
fn content (&self) -> impl Render<TuiOut> {
|
||||||
let top = Fixed::y(1, self.top.map(|top|Self::lo(self.mid, top)));
|
let [fg, bg, hi, lo] = self.colors;
|
||||||
let low = Fixed::y(1, self.low.map(|low|Self::hi(self.mid, low)));
|
let top = Fixed::y(1, Self::lo(bg, hi));
|
||||||
let content = Tui::fg_bg(self.fg, self.mid, &self.content);
|
let low = Fixed::y(1, Self::hi(bg, lo));
|
||||||
let phat = Bsp::s(top, Bsp::n(low, Fill::xy(content)));
|
let content = Tui::fg_bg(fg, bg, &self.content);
|
||||||
Min::xy(self.width, self.height, phat)
|
Min::xy(self.width, self.height, Bsp::s(top, Bsp::n(low, Fill::xy(content))))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue