pre generate grayscale palettes

This commit is contained in:
🪞👃🪞 2025-01-19 22:16:39 +01:00
parent cfa3cad5cb
commit ee28d431bd
7 changed files with 16 additions and 12 deletions

View file

@ -132,9 +132,7 @@ impl MidiEditor {
pub fn clip_status (&self) -> impl Content<TuiOut> + '_ {
let (color, name, length, looped) = if let Some(clip) = self.clip().as_ref().map(|p|p.read().unwrap()) {
(clip.color, clip.name.clone(), clip.length, clip.looped)
} else {
(ItemPalette::from(Tui::g(64)), String::new().into(), 0, false)
};
} else { (ItemPalette::G[64], String::new().into(), 0, false) };
row!(
FieldV(color, "Edit", format!("{name} ({length})")),
FieldV(color, "Loop", looped.to_string())
@ -143,9 +141,7 @@ impl MidiEditor {
pub fn edit_status (&self) -> impl Content<TuiOut> + '_ {
let (color, length) = if let Some(clip) = self.clip().as_ref().map(|p|p.read().unwrap()) {
(clip.color, clip.length)
} else {
(ItemPalette::from(Tui::g(64)), 0)
};
} else { (ItemPalette::G[64], 0) };
let time_pos = self.time_pos();
let time_zoom = self.time_zoom().get();
let time_lock = if self.time_lock().get() { "[lock]" } else { " " };

View file

@ -47,7 +47,7 @@ pub trait HasPlayClip: HasClock {
fn next_status (&self) -> impl Content<TuiOut> {
let mut time: Arc<str> = String::from("--.-.--").into();
let mut name: Arc<str> = String::from("").into();
let mut color = ItemPalette::from(Tui::g(64));
let mut color = ItemPalette::G[64];
let clock = self.clock();
if let Some((t, Some(clip))) = self.next_clip() {
let clip = clip.read().unwrap();

View file

@ -28,9 +28,7 @@ impl PianoHorizontal {
buffer: RwLock::new(Default::default()).into(),
point: MidiPointModel::default(),
clip: clip.cloned(),
color: clip.as_ref()
.map(|p|p.read().unwrap().color)
.unwrap_or(ItemPalette::from(ItemColor::from(Tui::g(64)))),
color: clip.as_ref().map(|p|p.read().unwrap().color).unwrap_or(ItemPalette::G[64]),
};
piano.redraw();
piano
@ -270,7 +268,7 @@ impl MidiViewer for PianoHorizontal {
fn set_clip (&mut self, clip: Option<&Arc<RwLock<MidiClip>>>) {
*self.clip_mut() = clip.cloned();
self.color = clip.map(|p|p.read().unwrap().color)
.unwrap_or(ItemPalette::from(ItemColor::from(Tui::g(64))));
.unwrap_or(ItemPalette::G[64]);
self.redraw();
}
}