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_scene = self.selected().scene();
|
||||
let header = move||{
|
||||
let cell = move|s, bg: &ItemPalette, last: Option<ItemPalette>, name: Arc<str>|{
|
||||
let selected = self.selected().scene() == Some(s+1);
|
||||
let neighbor = self.selected().scene() == Some(s);
|
||||
let cell = move|t, s, bg: &ItemPalette, last: Option<ItemPalette>, name: Arc<str>|{
|
||||
let selected = t && self.selected().scene() == Some(s+1);
|
||||
let neighbor = t && self.selected().scene() == Some(s);
|
||||
Phat {
|
||||
width: 0,
|
||||
height: 0,
|
||||
selected: selected,
|
||||
selected,
|
||||
content: Tui::bold(true, Bsp::e("🭬", name.clone())),
|
||||
fg: bg.lightest.rgb,
|
||||
top: if neighbor { last.map(|last|last.light.rgb) } else { last.map(|last|last.base.rgb) },
|
||||
mid: if selected { bg.light } else { bg.base }.rgb,
|
||||
low: Some(Reset)
|
||||
colors: [
|
||||
bg.lightest.rgb,
|
||||
if selected { bg.light } else { bg.base }.rgb,
|
||||
if neighbor { last.map(|last|last.light.rgb) } else { last.map(|last|last.base.rgb) }.unwrap_or(Reset),
|
||||
Reset,
|
||||
]
|
||||
}
|
||||
};
|
||||
Align::y(Map::new(
|
||||
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 {
|
||||
Some(self.scenes[s].color)
|
||||
None
|
||||
} else {
|
||||
Some(self.scenes[s-1].color)
|
||||
})) }),
|
||||
move|(_, scene, y1, y2, last), s| {
|
||||
let height = (1 + y2 - y1) as u16;
|
||||
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 tab = " Tab ";
|
||||
|
|
@ -330,7 +332,7 @@ impl Tek {
|
|||
Map::new(
|
||||
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 {
|
||||
self.scenes[s].clips[t].as_ref().map(|c|c.read().unwrap().color)
|
||||
None
|
||||
} else {
|
||||
self.scenes[s-1].clips[t].as_ref().map(|c|c.read().unwrap().color)
|
||||
})) }),
|
||||
|
|
@ -364,10 +366,22 @@ impl Tek {
|
|||
height: 0,
|
||||
selected,
|
||||
content: content(),
|
||||
fg,
|
||||
top: if neighbor { last.map(|last|last.light.rgb) } else { last.map(|last|last.base.rgb) },
|
||||
mid: if selected { bg.light } else { bg.base }.rgb,
|
||||
low: Some(Reset)
|
||||
colors: [
|
||||
fg,
|
||||
if selected { bg.light } else { bg.base }.rgb,
|
||||
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::Color::*;
|
||||
macro_rules! impl_content_layout_render {
|
||||
($Output:ty: |$self:ident: $Struct:ty, $to:ident| layout = $layout:expr; render = $render:expr) => {
|
||||
impl Content<$Output> for $Struct {
|
||||
|
|
@ -114,11 +115,8 @@ 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
|
||||
pub colors: [Color;4],
|
||||
pub selected: bool,
|
||||
}
|
||||
impl<T> Phat<T> {
|
||||
/// A phat line
|
||||
|
|
@ -132,11 +130,11 @@ impl<T> Phat<T> {
|
|||
}
|
||||
impl<T: Content<TuiOut>> Content<TuiOut> for Phat<T> {
|
||||
fn content (&self) -> impl Render<TuiOut> {
|
||||
let top = Fixed::y(1, self.top.map(|top|Self::lo(self.mid, top)));
|
||||
let low = Fixed::y(1, 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)
|
||||
let [fg, bg, hi, lo] = self.colors;
|
||||
let top = Fixed::y(1, Self::lo(bg, hi));
|
||||
let low = Fixed::y(1, Self::hi(bg, lo));
|
||||
let content = Tui::fg_bg(fg, bg, &self.content);
|
||||
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