mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-09 13:16:44 +01:00
colorize transport
This commit is contained in:
parent
761ec78282
commit
1ceb2dd2da
5 changed files with 55 additions and 48 deletions
|
|
@ -118,12 +118,13 @@ impl Audio for ArrangerTui {
|
||||||
render!(|self: ArrangerTui|{
|
render!(|self: ArrangerTui|{
|
||||||
let arranger_focused = self.arranger_focused();
|
let arranger_focused = self.arranger_focused();
|
||||||
let border = Lozenge(Style::default().bg(TuiTheme::border_bg()).fg(TuiTheme::border_fg(arranger_focused)));
|
let border = Lozenge(Style::default().bg(TuiTheme::border_bg()).fg(TuiTheme::border_fg(arranger_focused)));
|
||||||
col!([
|
let transport_focused = if let ArrangerFocus::Transport(_) = self.focus.inner() {
|
||||||
TransportView::from((self, if let ArrangerFocus::Transport(_) = self.focus.inner() {
|
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
})),
|
};
|
||||||
|
col!([
|
||||||
|
TransportView::from((self, None, transport_focused)),
|
||||||
col!([
|
col!([
|
||||||
Tui::fixed_y(self.splits[0], lay!([
|
Tui::fixed_y(self.splits[0], lay!([
|
||||||
border.wrap(Tui::grow_y(1, Layers::new(move |add|{
|
border.wrap(Tui::grow_y(1, Layers::new(move |add|{
|
||||||
|
|
|
||||||
|
|
@ -110,11 +110,15 @@ impl Audio for SequencerTui {
|
||||||
render!(|self: SequencerTui|lay!([self.size, Tui::split_up(1,
|
render!(|self: SequencerTui|lay!([self.size, Tui::split_up(1,
|
||||||
Tui::fill_xy(Tui::at_s(SequencerStatusBar::from(self))),
|
Tui::fill_xy(Tui::at_s(SequencerStatusBar::from(self))),
|
||||||
Tui::split_up(2,
|
Tui::split_up(2,
|
||||||
TransportView::from((self, if let SequencerFocus::Transport(_) = self.focus.inner() {
|
TransportView::from((
|
||||||
|
self,
|
||||||
|
self.player.play_phrase().as_ref().map(|(_,p)|p.as_ref().map(|p|p.read().unwrap().color)).flatten(),
|
||||||
|
if let SequencerFocus::Transport(_) = self.focus.inner() {
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
})),
|
}
|
||||||
|
)),
|
||||||
row!([
|
row!([
|
||||||
Tui::fixed_x(20, Tui::split_up(4, col!([
|
Tui::fixed_x(20, Tui::split_up(4, col!([
|
||||||
PhraseSelector::next_phrase(
|
PhraseSelector::next_phrase(
|
||||||
|
|
|
||||||
|
|
@ -55,9 +55,10 @@ impl Audio for TransportTui {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
render!(|self: TransportTui|TransportView::from((self, true)));
|
render!(|self: TransportTui|TransportView::from((self, None, true)));
|
||||||
|
|
||||||
pub struct TransportView {
|
pub struct TransportView {
|
||||||
|
bg: Color,
|
||||||
focused: bool,
|
focused: bool,
|
||||||
|
|
||||||
sr: String,
|
sr: String,
|
||||||
|
|
@ -74,17 +75,20 @@ pub struct TransportView {
|
||||||
current_second: f64,
|
current_second: f64,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: HasClock> From<(&T, bool)> for TransportView {
|
impl<T: HasClock> From<(&T, Option<ItemColorTriplet>, bool)> for TransportView {
|
||||||
fn from ((state, focused): (&T, bool)) -> Self {
|
fn from ((state, color, focused): (&T, Option<ItemColorTriplet>, bool)) -> Self {
|
||||||
let clock = state.clock();
|
let clock = state.clock();
|
||||||
let sr = format!("{:.1}k", clock.timebase.sr.get() / 1000.0);
|
let sr = format!("{:.1}k", clock.timebase.sr.get() / 1000.0);
|
||||||
let bpm = format!("{:.3}", clock.timebase.bpm.get());
|
let bpm = format!("{:.3}", clock.timebase.bpm.get());
|
||||||
let ppq = format!("{:.0}", clock.timebase.ppq.get());
|
let ppq = format!("{:.0}", clock.timebase.ppq.get());
|
||||||
|
let color = color.unwrap_or(ItemColorTriplet::from(ItemColor::from(TuiTheme::g(100))));
|
||||||
|
let bg = if focused { color.light.rgb } else { color.dark.rgb };
|
||||||
if let Some(started) = clock.started.read().unwrap().as_ref() {
|
if let Some(started) = clock.started.read().unwrap().as_ref() {
|
||||||
let current_sample = (clock.global.sample.get() - started.sample.get())/1000.;
|
let current_sample = (clock.global.sample.get() - started.sample.get())/1000.;
|
||||||
let current_usec = clock.global.usec.get() - started.usec.get();
|
let current_usec = clock.global.usec.get() - started.usec.get();
|
||||||
let current_second = current_usec/1000000.;
|
let current_second = current_usec/1000000.;
|
||||||
Self {
|
Self {
|
||||||
|
bg,
|
||||||
focused,
|
focused,
|
||||||
sr,
|
sr,
|
||||||
bpm,
|
bpm,
|
||||||
|
|
@ -100,6 +104,7 @@ impl<T: HasClock> From<(&T, bool)> for TransportView {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Self {
|
Self {
|
||||||
|
bg,
|
||||||
focused,
|
focused,
|
||||||
sr,
|
sr,
|
||||||
bpm,
|
bpm,
|
||||||
|
|
@ -124,7 +129,7 @@ render!(|self: TransportField<'a>|{
|
||||||
});
|
});
|
||||||
|
|
||||||
render!(|self: TransportView|{
|
render!(|self: TransportView|{
|
||||||
let bg = if self.focused { TuiTheme::border_bg() } else { TuiTheme::bg() };
|
let bg = self.bg;
|
||||||
let border_style = Style::default()
|
let border_style = Style::default()
|
||||||
.bg(bg)
|
.bg(bg)
|
||||||
.fg(TuiTheme::border_fg(self.focused));
|
.fg(TuiTheme::border_fg(self.focused));
|
||||||
|
|
|
||||||
|
|
@ -210,39 +210,12 @@ render!(|self: PhraseView<'a>|{
|
||||||
//now: _,
|
//now: _,
|
||||||
..
|
..
|
||||||
} = self;
|
} = self;
|
||||||
|
let phrase_color = phrase.as_ref().map(|p|p.read().unwrap().color.clone())
|
||||||
|
.unwrap_or(ItemColorTriplet::from(ItemColor::from(TuiTheme::g(64))));
|
||||||
|
let title_color = if *focused{phrase_color.light.rgb}else{phrase_color.dark.rgb};
|
||||||
|
let bg = if self.focused { TuiTheme::bg() } else { Color::Reset };
|
||||||
lay!([
|
lay!([
|
||||||
lay!(move|add|{
|
Tui::bg(bg, Tui::inset_x(1, Tui::fill_x(row!([
|
||||||
//if *focused {
|
|
||||||
add(&Lozenge(Style::default().bg(Color::Rgb(40, 50, 30)).fg(TuiTheme::border_fg(true))))?;
|
|
||||||
//}
|
|
||||||
let title_color = if *focused{Color::Rgb(150, 160, 90)}else{Color::Rgb(120, 130, 100)};
|
|
||||||
let upper_left = format!("{}",
|
|
||||||
phrase.as_ref().map(|p|p.read().unwrap().name.clone()).unwrap_or(String::new())
|
|
||||||
);
|
|
||||||
let lower_left = format!("");
|
|
||||||
let mut lower_right = format!(" {} ", size.format());
|
|
||||||
if *focused && *entered {
|
|
||||||
lower_right = format!("Note: {} ({}) {} {lower_right}",
|
|
||||||
note_point, to_note_name(*note_point), pulses_to_name(*note_len)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
let mut upper_right = format!("[{}]", if *entered {"■"} else {" "});
|
|
||||||
if let Some(phrase) = phrase {
|
|
||||||
upper_right = format!("Time: {}/{} {} {upper_right}",
|
|
||||||
time_point, phrase.read().unwrap().length, pulses_to_name(view_mode.time_zoom()),
|
|
||||||
)
|
|
||||||
};
|
|
||||||
add(&Tui::push_x(1, Tui::at_nw(Tui::fg(title_color, upper_left))))?;
|
|
||||||
add(&Tui::at_sw(Tui::fg(title_color, lower_left)))?;
|
|
||||||
add(&Tui::fill_xy(Tui::at_ne(Tui::pull_x(1, Tui::fg(title_color, upper_right)))))?;
|
|
||||||
add(&Tui::fill_xy(Tui::at_se(Tui::pull_x(1, Tui::fg(title_color, lower_right)))))?;
|
|
||||||
Ok(())
|
|
||||||
}),
|
|
||||||
Tui::bg(if self.focused {
|
|
||||||
TuiTheme::bg()
|
|
||||||
} else {
|
|
||||||
Color::Reset
|
|
||||||
}, Tui::inset_x(1, Tui::fill_x(row!([
|
|
||||||
Tui::push_y(1, Tui::fill_y(Widget::new(|to:[u16;2]|Ok(Some(to.clip_w(5))), move|to: &mut TuiOutput|{
|
Tui::push_y(1, Tui::fill_y(Widget::new(|to:[u16;2]|Ok(Some(to.clip_w(5))), move|to: &mut TuiOutput|{
|
||||||
Ok(if to.area().h() >= 2 { view_mode.render_keys(to, *note_hi, *note_lo) })
|
Ok(if to.area().h() >= 2 { view_mode.render_keys(to, *note_hi, *note_lo) })
|
||||||
}))),
|
}))),
|
||||||
|
|
@ -262,7 +235,31 @@ render!(|self: PhraseView<'a>|{
|
||||||
})
|
})
|
||||||
}))
|
}))
|
||||||
])),
|
])),
|
||||||
]))))
|
])))),
|
||||||
|
lay!(move|add|{
|
||||||
|
add(&Lozenge(Style::default().bg(phrase_color.base.rgb).fg(phrase_color.base.rgb)))?;
|
||||||
|
let upper_left = format!("{}",
|
||||||
|
phrase.as_ref().map(|p|p.read().unwrap().name.clone()).unwrap_or(String::new())
|
||||||
|
);
|
||||||
|
let lower_left = format!("");
|
||||||
|
let mut lower_right = format!(" {} ", size.format());
|
||||||
|
if *focused && *entered {
|
||||||
|
lower_right = format!("Note: {} ({}) {} {lower_right}",
|
||||||
|
note_point, to_note_name(*note_point), pulses_to_name(*note_len)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
let mut upper_right = format!("[{}]", if *entered {"■"} else {" "});
|
||||||
|
if let Some(phrase) = phrase {
|
||||||
|
upper_right = format!("Time: {}/{} {} {upper_right}",
|
||||||
|
time_point, phrase.read().unwrap().length, pulses_to_name(view_mode.time_zoom()),
|
||||||
|
)
|
||||||
|
};
|
||||||
|
add(&Tui::push_x(1, Tui::at_nw(Tui::fg(TuiTheme::g(224), Tui::bg(title_color, upper_left)))))?;
|
||||||
|
add(&Tui::at_sw(Tui::bg(title_color, Tui::fg(TuiTheme::g(224), lower_left))))?;
|
||||||
|
add(&Tui::fill_xy(Tui::at_ne(Tui::pull_x(1, Tui::bg(title_color, Tui::fg(TuiTheme::g(224), upper_right))))))?;
|
||||||
|
add(&Tui::fill_xy(Tui::at_se(Tui::pull_x(1, Tui::bg(title_color, Tui::fg(TuiTheme::g(224), lower_right))))))?;
|
||||||
|
Ok(())
|
||||||
|
}),
|
||||||
])
|
])
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ render!(|self: PhraseSelector|{
|
||||||
add(&Tui::push_y(0, Tui::fill_xy(Layers::new(move|add|{
|
add(&Tui::push_y(0, Tui::fill_xy(Layers::new(move|add|{
|
||||||
if let Some((instant, Some(phrase))) = phrase {
|
if let Some((instant, Some(phrase))) = phrase {
|
||||||
let Phrase { ref name, color, length, .. } = *phrase.read().unwrap();
|
let Phrase { ref name, color, length, .. } = *phrase.read().unwrap();
|
||||||
add(&Tui::pull_y(0, Tui::inset_x(0, Tui::bg(color.dark.rgb, Tui::fill_x(col!([
|
add(&Tui::pull_y(0, Tui::inset_x(0, Tui::bg(color.base.rgb, Tui::fill_x(col!([
|
||||||
Tui::fill_x(lay!([
|
Tui::fill_x(lay!([
|
||||||
Tui::fill_x(Tui::at_w(Tui::fg(TuiTheme::g(255), format!(" ")))),
|
Tui::fill_x(Tui::at_w(Tui::fg(TuiTheme::g(255), format!(" ")))),
|
||||||
Tui::fill_x(Tui::at_e(Tui::fg(TuiTheme::g(255), PhraseLength::new(length, None))))
|
Tui::fill_x(Tui::at_e(Tui::fg(TuiTheme::g(255), PhraseLength::new(length, None))))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue