trait Run

This commit is contained in:
🪞👃🪞 2024-07-02 22:25:33 +03:00
parent cc2b59d772
commit 3ae2467acc
11 changed files with 212 additions and 141 deletions

View file

@ -1,8 +1,12 @@
use crate::core::*;
use super::*;
pub fn handle (state: &mut Launcher, event: &AppEvent) -> Usually<bool> {
//if let Some(ref modal) = state.modal {
//if modal.handle_with_state(state, event)? {
//return Ok(true)
//}
//}
Ok(handle_keymap(state, event, KEYMAP)? || match state.view {
LauncherView::Modal(ref mut device) => device.handle(event)?,
LauncherView::Tracks => handle_keymap(state, event, KEYMAP_TRACKS)?,
LauncherView::Sequencer => {
let i = state.col().saturating_sub(1);

View file

@ -18,8 +18,13 @@ pub struct Launcher {
scenes: Vec<Scene>,
show_help: bool,
view: LauncherView,
modal: Option<Box<dyn Modal<Self>>>,
}
pub enum LauncherView {
Tracks,
Sequencer,
Chains
}
pub enum LauncherView { Tracks, Sequencer, Chains, Modal(Box<dyn Device>) }
impl LauncherView {
fn is_tracks (&self) -> bool {
match self { Self::Tracks => true, _ => false }
@ -70,6 +75,7 @@ impl Launcher {
]))?,
] },
show_help: true,
modal: None
}).activate(client)
}
fn cols (&self) -> usize {
@ -209,6 +215,13 @@ pub fn render (state: &Launcher, buf: &mut Buffer, mut area: Rect) -> Usually<Re
let hide = "[Tab] Mode [Arrows] Move [.,] Value [F1] Toggle help ";
hide.blit(buf, x + (width - hide.len() as u16) / 2, height - 1, style);
}
if let Some(ref modal) = state.modal {
for cell in buf.content.iter_mut() {
cell.fg = ::ratatui::style::Color::Gray;
cell.modifier = ::ratatui::style::Modifier::DIM;
}
}
Ok(area)
}
fn draw_section_sequencer (state: &Launcher, buf: &mut Buffer, area: Rect) -> Usually<Rect> {