mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
wip: midi import/export browser, pt.7
This commit is contained in:
parent
f12a1dc2ca
commit
86f37fb278
3 changed files with 33 additions and 6 deletions
|
|
@ -265,20 +265,28 @@ pub enum FileBrowserCommand {
|
|||
impl<T: PhrasesControl> Command<T> for FileBrowserCommand {
|
||||
fn execute (self, state: &mut T) -> Perhaps<Self> {
|
||||
use FileBrowserCommand::*;
|
||||
use PhrasesMode::{Import, Export};
|
||||
let mode = state.phrases_mode_mut();
|
||||
match mode {
|
||||
Some(PhrasesMode::Import(index, ref mut browser)) => match self {
|
||||
Some(Import(index, ref mut browser)) => match self {
|
||||
Cancel => {
|
||||
*mode = None;
|
||||
},
|
||||
Chdir(cwd) => {
|
||||
*mode = Some(PhrasesMode::Import(*index, FileBrowser::new(Some(cwd))?));
|
||||
*mode = Some(Import(*index, FileBrowser::new(Some(cwd))?));
|
||||
},
|
||||
Select(index) => {
|
||||
browser.index = index;
|
||||
},
|
||||
Confirm => {
|
||||
todo!("import midi to phrase");
|
||||
if browser.is_file() {
|
||||
let index = *index;
|
||||
let path = browser.path();
|
||||
*mode = None;
|
||||
PhrasePoolCommand::Import(index, path).execute(state)?;
|
||||
} else if browser.is_dir() {
|
||||
*mode = Some(Import(*index, browser.chdir()?));
|
||||
}
|
||||
},
|
||||
_ => todo!(),
|
||||
_ => unreachable!()
|
||||
|
|
|
|||
|
|
@ -209,6 +209,24 @@ impl FileBrowser {
|
|||
pub fn len (&self) -> usize {
|
||||
self.dirs.len() + self.files.len()
|
||||
}
|
||||
pub fn is_dir (&self) -> bool {
|
||||
self.index < self.dirs.len()
|
||||
}
|
||||
pub fn is_file (&self) -> bool {
|
||||
self.index >= self.dirs.len()
|
||||
}
|
||||
pub fn path (&self) -> PathBuf {
|
||||
self.cwd.join(if self.is_dir() {
|
||||
&self.dirs[self.index].0
|
||||
} else if self.is_file() {
|
||||
&self.files[self.index - self.dirs.len()].0
|
||||
} else {
|
||||
unreachable!()
|
||||
})
|
||||
}
|
||||
pub fn chdir (&self) -> Usually<Self> {
|
||||
Self::new(Some(self.path()))
|
||||
}
|
||||
}
|
||||
|
||||
/// Displays and edits phrase length.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue