mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-09 05:06:43 +01:00
arranger: open and close rename modal
This commit is contained in:
parent
b0f4919030
commit
c8bdee060c
7 changed files with 92 additions and 17 deletions
51
crates/tek_sequencer/src/arranger_modal.rs
Normal file
51
crates/tek_sequencer/src/arranger_modal.rs
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
use crate::*;
|
||||
|
||||
/// Appears on first run (i.e. if state dir is missing).
|
||||
pub struct ArrangerRenameModal(bool, ArrangerFocus);
|
||||
|
||||
impl ArrangerRenameModal {
|
||||
pub fn new (focus: ArrangerFocus) -> Self {
|
||||
Self(false, focus)
|
||||
}
|
||||
}
|
||||
|
||||
render!(ArrangerRenameModal |self, buf, area| {
|
||||
let y = area.y + area.height / 2;
|
||||
Lozenge(Style::default().bold().white().dim()).draw(buf, Rect {
|
||||
x: 1,
|
||||
y: y - 1,
|
||||
width: area.width - 2,
|
||||
height: 3
|
||||
})?;
|
||||
let label = match self.1 {
|
||||
ArrangerFocus::Mix => "Rename project:",
|
||||
ArrangerFocus::Track(_) => "Rename track:",
|
||||
ArrangerFocus::Scene(_) => "Rename scene:",
|
||||
ArrangerFocus::Clip(_, _) => "Rename clip:",
|
||||
};
|
||||
label.blit(buf, area.x + 3, y, Some(Style::default().not_bold().white().not_dim()))?;
|
||||
Ok(area)
|
||||
});
|
||||
|
||||
handle!(ArrangerRenameModal |self, e| {
|
||||
match e {
|
||||
AppEvent::Input(Event::Key(k)) => {
|
||||
if k.code == KeyCode::Esc {
|
||||
self.exit();
|
||||
} else {
|
||||
todo!();
|
||||
};
|
||||
Ok(true)
|
||||
},
|
||||
_ => Ok(false),
|
||||
}
|
||||
});
|
||||
|
||||
impl Exit for ArrangerRenameModal {
|
||||
fn exited (&self) -> bool {
|
||||
self.0
|
||||
}
|
||||
fn exit (&mut self) {
|
||||
self.0 = true
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue