mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
fix gaps net to empty clips
This commit is contained in:
parent
5d6592bbdf
commit
2ef668ef0b
1 changed files with 49 additions and 50 deletions
|
|
@ -31,7 +31,6 @@ impl<T: PartialEq, U> ViewMemo<T, U> {
|
|||
trks: ViewMemo<Option<(usize, usize)>, String>,
|
||||
stop: Arc<str>,
|
||||
edit: Arc<str>,
|
||||
last_color: Arc<RwLock<ItemPalette>>
|
||||
}
|
||||
impl Default for ViewCache {
|
||||
fn default () -> Self {
|
||||
|
|
@ -46,7 +45,6 @@ impl Default for ViewCache {
|
|||
trks: ViewMemo::new(None, String::with_capacity(16)),
|
||||
stop: "⏹".into(),
|
||||
edit: "edit".into(),
|
||||
last_color: Arc::new(RwLock::new(ItemPalette::G[0]))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -288,23 +286,20 @@ impl Tek {
|
|||
let tracks = move||self.tracks_sizes(editing, self.editor_w());
|
||||
let selected_track = self.selected().track();
|
||||
let selected_scene = self.selected().scene();
|
||||
let header_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,
|
||||
content: Tui::bold(true, Bsp::e("🭬", name.clone())),
|
||||
colors: colors(
|
||||
bg, last, selected, neighbor, s == self.scenes.len().saturating_sub(1)
|
||||
)
|
||||
}
|
||||
};
|
||||
let header = move||{
|
||||
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,
|
||||
content: Tui::bold(true, Bsp::e("🭬", name.clone())),
|
||||
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 {
|
||||
|
|
@ -315,7 +310,7 @@ impl Tek {
|
|||
move|(_, scene, y1, y2, last), s| {
|
||||
let height = (1 + y2 - y1) as u16;
|
||||
map_south(y1 as u16, height, Fixed::y(height,
|
||||
cell(true, s, &scene.color, last, scene.name.clone()))) })).boxed()
|
||||
header_cell(true, s, &scene.color, last, scene.name.clone()))) })).boxed()
|
||||
};
|
||||
let content: ThunkBox<_> = per_track!(self.size.w(); |self, track, t|{
|
||||
let tab = " Tab ";
|
||||
|
|
@ -325,8 +320,9 @@ impl Tek {
|
|||
move|(s, scene, y1, y2)|if y2 > size_h { None } else { Some((s, scene, y1, y2, if s == 0 {
|
||||
None
|
||||
} else {
|
||||
self.scenes[s-1].clips[t].as_ref().map(|c|c.read().unwrap().color)
|
||||
})) }),
|
||||
Some(self.scenes[s-1].clips[t].as_ref()
|
||||
.map(|c|c.read().unwrap().color)
|
||||
.unwrap_or(ItemPalette::G[32])) })) }),
|
||||
move|(_, scene, y1, y2, last), s| {
|
||||
let height = (1 + y2 - y1) as u16;
|
||||
let mut fg = Tui::g(64);
|
||||
|
|
@ -336,7 +332,6 @@ impl Tek {
|
|||
fg = clip.color.lightest.rgb;
|
||||
bg = clip.color
|
||||
};
|
||||
// weird offsetting:
|
||||
let selected = same_track && selected_scene == Some(s+1);
|
||||
let neighbor = same_track && selected_scene == Some(s);
|
||||
let active = editing && selected;
|
||||
|
|
@ -346,34 +341,15 @@ impl Tek {
|
|||
let name = clip.map(|c|c.read().unwrap().name.clone());
|
||||
Align::nw(Tui::fg(fg, Bsp::e(icon, Bsp::e(Tui::bold(true, name), " "))))
|
||||
};
|
||||
map_south(y1 as u16, height, Fixed::y(height, Either::new(active,
|
||||
Thunk::new(move||Bsp::a(
|
||||
Fill::xy(Align::nw(button(tab, content()))),
|
||||
&self.editor)),
|
||||
Thunk::new(move||Bsp::a(
|
||||
When::new(selected, Fill::y(Align::n(button(tab, "edit")))),
|
||||
Phat {
|
||||
width: 0,
|
||||
height: 0,
|
||||
selected,
|
||||
content: content(),
|
||||
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
|
||||
},
|
||||
],
|
||||
})))))
|
||||
map_south(y1 as u16, height, Fixed::y(height, Phat {
|
||||
width: 0,
|
||||
height: 0,
|
||||
selected,
|
||||
content: content(),
|
||||
colors: colors(
|
||||
&bg, last, selected, neighbor, s == self.scenes.len().saturating_sub(1)
|
||||
),
|
||||
}))
|
||||
})
|
||||
});
|
||||
//let border = move|x|Outer(false, bstyle).enclose_bg(x);
|
||||
|
|
@ -416,3 +392,26 @@ fn button <'a> (
|
|||
Margin::x(1, Tui::fg_bg(Tui::g(255), Tui::g(96), label)),
|
||||
))
|
||||
}
|
||||
fn colors (
|
||||
this: &ItemPalette,
|
||||
prev: Option<ItemPalette>,
|
||||
selected: bool,
|
||||
neighbor: bool,
|
||||
is_last: bool,
|
||||
) -> [Color;4] {
|
||||
let fg = this.lightest.rgb;
|
||||
let bg = if selected { this.light } else { this.base }.rgb;
|
||||
let hi = if neighbor {
|
||||
prev.map(|prev|prev.light.rgb)
|
||||
} else {
|
||||
prev.map(|prev|prev.base.rgb)
|
||||
}.unwrap_or(Reset);
|
||||
let lo = if is_last {
|
||||
Reset
|
||||
} else if selected {
|
||||
this.light.rgb
|
||||
} else {
|
||||
this.base.rgb
|
||||
};
|
||||
[fg, bg, hi, lo]
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue