mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-13 07:06:41 +01:00
impl TuiTheme on Tui; need to to reduce number of ItemPalette invocations
This commit is contained in:
parent
9d250daa04
commit
cfa3cad5cb
9 changed files with 157 additions and 177 deletions
|
|
@ -30,7 +30,7 @@ impl PianoHorizontal {
|
|||
clip: clip.cloned(),
|
||||
color: clip.as_ref()
|
||||
.map(|p|p.read().unwrap().color)
|
||||
.unwrap_or(ItemPalette::from(ItemColor::from(TuiTheme::g(64)))),
|
||||
.unwrap_or(ItemPalette::from(ItemColor::from(Tui::g(64)))),
|
||||
};
|
||||
piano.redraw();
|
||||
piano
|
||||
|
|
@ -39,14 +39,14 @@ impl PianoHorizontal {
|
|||
pub(crate) fn note_y_iter (note_lo: usize, note_hi: usize, y0: u16) -> impl Iterator<Item=(usize, u16, usize)> {
|
||||
(note_lo..=note_hi).rev().enumerate().map(move|(y, n)|(y, y0 + y as u16, n))
|
||||
}
|
||||
content!(TuiOut:|self: PianoHorizontal| Tui::bg(TuiTheme::g(40), Bsp::s(
|
||||
content!(TuiOut:|self: PianoHorizontal| Tui::bg(Tui::g(40), Bsp::s(
|
||||
Bsp::e(
|
||||
Fixed::x(5, format!("{}x{}", self.size.w(), self.size.h())),
|
||||
self.timeline()
|
||||
),
|
||||
Bsp::e(
|
||||
self.keys(),
|
||||
self.size.of(Tui::bg(TuiTheme::g(32), Bsp::b(
|
||||
self.size.of(Tui::bg(Tui::g(32), Bsp::b(
|
||||
Fill::xy(self.notes()),
|
||||
Fill::xy(self.cursor()),
|
||||
)))
|
||||
|
|
@ -185,8 +185,8 @@ impl PianoHorizontal {
|
|||
let note_hi = state.note_hi();
|
||||
let note_pos = state.note_pos();
|
||||
let key_style = Some(Style::default().fg(Color::Rgb(192, 192, 192)).bg(Color::Rgb(0, 0, 0)));
|
||||
let off_style = Some(Style::default().fg(TuiTheme::g(160)));
|
||||
let on_style = Some(Style::default().fg(TuiTheme::g(255)).bg(color.base.rgb).bold());
|
||||
let off_style = Some(Style::default().fg(Tui::g(160)));
|
||||
let on_style = Some(Style::default().fg(Tui::g(255)).bg(color.base.rgb).bold());
|
||||
Fill::y(Fixed::x(self.keys_width, ThunkRender::new(move|to: &mut TuiOut|{
|
||||
let [x, y0, _w, _h] = to.area().xywh();
|
||||
for (_area_y, screen_y, note) in note_y_iter(note_lo, note_hi, y0) {
|
||||
|
|
@ -270,7 +270,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(TuiTheme::g(64))));
|
||||
.unwrap_or(ItemPalette::from(ItemColor::from(Tui::g(64))));
|
||||
self.redraw();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue