mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-09 05:06:43 +01:00
wip: refactor arranger to device
This commit is contained in:
parent
fa73821a0b
commit
89288f2920
40 changed files with 2015 additions and 1919 deletions
|
|
@ -17,173 +17,6 @@ handle!(TuiIn: |self: App, input|Ok(if let Some(command) = self.config.keys.comm
|
|||
None
|
||||
}));
|
||||
|
||||
#[tengri_proc::expose] impl App {
|
||||
fn _todo_isize_stub (&self) -> isize {
|
||||
todo!()
|
||||
}
|
||||
fn _todo_item_theme_stub (&self) -> ItemTheme {
|
||||
todo!()
|
||||
}
|
||||
fn focus_editor (&self) -> bool {
|
||||
self.is_editing()
|
||||
}
|
||||
fn focus_message (&self) -> bool {
|
||||
matches!(self.dialog, Some(Dialog::Message(..)))
|
||||
}
|
||||
fn focus_device_add (&self) -> bool {
|
||||
matches!(self.dialog, Some(Dialog::Device(..)))
|
||||
}
|
||||
fn focus_clip (&self) -> bool {
|
||||
!self.is_editing() && self.selected.is_clip()
|
||||
}
|
||||
fn focus_track (&self) -> bool {
|
||||
!self.is_editing() && self.selected.is_track()
|
||||
}
|
||||
fn focus_scene (&self) -> bool {
|
||||
!self.is_editing() && self.selected.is_scene()
|
||||
}
|
||||
fn focus_mix (&self) -> bool {
|
||||
!self.is_editing() && self.selected.is_mix()
|
||||
}
|
||||
fn focus_pool_import (&self) -> bool {
|
||||
matches!(self.pool.as_ref().map(|p|p.mode.as_ref()).flatten(), Some(PoolMode::Import(..)))
|
||||
}
|
||||
fn focus_pool_export (&self) -> bool {
|
||||
matches!(self.pool.as_ref().map(|p|p.mode.as_ref()).flatten(), Some(PoolMode::Export(..)))
|
||||
}
|
||||
fn focus_pool_rename (&self) -> bool {
|
||||
matches!(self.pool.as_ref().map(|p|p.mode.as_ref()).flatten(), Some(PoolMode::Rename(..)))
|
||||
}
|
||||
fn focus_pool_length (&self) -> bool {
|
||||
matches!(self.pool.as_ref().map(|p|p.mode.as_ref()).flatten(), Some(PoolMode::Length(..)))
|
||||
}
|
||||
fn dialog_help (&self) -> Dialog {
|
||||
Dialog::Help
|
||||
}
|
||||
fn dialog_menu (&self) -> Dialog {
|
||||
Dialog::Menu
|
||||
}
|
||||
fn dialog_save (&self) -> Dialog {
|
||||
Dialog::Save
|
||||
}
|
||||
fn dialog_load (&self) -> Dialog {
|
||||
Dialog::Load
|
||||
}
|
||||
fn dialog_options (&self) -> Dialog {
|
||||
Dialog::Options
|
||||
}
|
||||
fn editor_pitch (&self) -> Option<u7> {
|
||||
Some((self.editor().map(|e|e.get_note_pos()).unwrap() as u8).into())
|
||||
}
|
||||
/// Width of display
|
||||
pub(crate) fn w (&self) -> u16 {
|
||||
self.size.w() as u16
|
||||
}
|
||||
/// Width allocated for sidebar.
|
||||
pub(crate) fn w_sidebar (&self) -> u16 {
|
||||
self.w() / if self.is_editing() { 16 } else { 8 } as u16
|
||||
}
|
||||
/// Width taken by all tracks.
|
||||
pub(crate) fn w_tracks (&self) -> u16 {
|
||||
self.tracks_with_sizes().last().map(|(_, _, _, x)|x as u16).unwrap_or(0)
|
||||
}
|
||||
/// Width available to display tracks.
|
||||
pub(crate) fn w_tracks_area (&self) -> u16 {
|
||||
self.w().saturating_sub(2 * self.w_sidebar())
|
||||
}
|
||||
/// Height of display
|
||||
pub(crate) fn h (&self) -> u16 {
|
||||
self.size.h() as u16
|
||||
}
|
||||
/// Height available to display track headers.
|
||||
pub(crate) fn h_tracks_area (&self) -> u16 {
|
||||
5 // FIXME
|
||||
//self.h().saturating_sub(self.h_inputs() + self.h_outputs())
|
||||
}
|
||||
/// Height available to display tracks.
|
||||
pub(crate) fn h_scenes_area (&self) -> u16 {
|
||||
//15
|
||||
self.h().saturating_sub(
|
||||
self.h_inputs() +
|
||||
self.h_outputs() +
|
||||
self.h_devices() +
|
||||
13 // FIXME
|
||||
)
|
||||
}
|
||||
/// Height taken by all scenes.
|
||||
pub(crate) fn h_scenes (&self) -> u16 {
|
||||
self.scenes_with_sizes(self.is_editing(), Self::H_SCENE, Self::H_EDITOR).last()
|
||||
.map(|(_, _, _, y)|y as u16).unwrap_or(0)
|
||||
}
|
||||
/// Height taken by all inputs.
|
||||
pub(crate) fn h_inputs (&self) -> u16 {
|
||||
self.inputs_with_sizes().last().map(|(_, _, _, _, y)|y as u16).unwrap_or(0)
|
||||
}
|
||||
/// Height taken by all outputs.
|
||||
pub(crate) fn h_outputs (&self) -> u16 {
|
||||
self.outputs_with_sizes().last().map(|(_, _, _, _, y)|y as u16).unwrap_or(0)
|
||||
}
|
||||
/// Height taken by visible device slots.
|
||||
pub(crate) fn h_devices (&self) -> u16 {
|
||||
2
|
||||
//1 + self.devices_with_sizes().last().map(|(_, _, _, _, y)|y as u16).unwrap_or(0)
|
||||
}
|
||||
fn scene_count (&self) -> usize {
|
||||
self.scenes.len()
|
||||
}
|
||||
fn scene_selected (&self) -> Option<usize> {
|
||||
self.selected.scene()
|
||||
}
|
||||
fn track_count (&self) -> usize {
|
||||
self.tracks.len()
|
||||
}
|
||||
fn track_selected (&self) -> Option<usize> {
|
||||
self.selected.track()
|
||||
}
|
||||
fn select_scene_next (&self) -> Selection {
|
||||
self.selected.scene_next(self.scenes.len())
|
||||
}
|
||||
fn select_scene_prev (&self) -> Selection {
|
||||
self.selected.scene_prev()
|
||||
}
|
||||
fn select_track_header (&self) -> Selection {
|
||||
self.selected.track_header(self.tracks.len())
|
||||
}
|
||||
fn select_track_next (&self) -> Selection {
|
||||
self.selected.track_next(self.tracks.len())
|
||||
}
|
||||
fn select_track_prev (&self) -> Selection {
|
||||
self.selected.track_prev()
|
||||
}
|
||||
fn clip_selected (&self) -> Option<Arc<RwLock<MidiClip>>> {
|
||||
match self.selected {
|
||||
Selection::TrackClip { track, scene } => self.scenes[scene].clips[track].clone(),
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
fn device_kind (&self) -> usize {
|
||||
if let Some(Dialog::Device(index)) = self.dialog {
|
||||
index
|
||||
} else {
|
||||
0
|
||||
}
|
||||
}
|
||||
fn device_kind_prev (&self) -> usize {
|
||||
if let Some(Dialog::Device(index)) = self.dialog {
|
||||
index.overflowing_sub(1).0.min(self.device_kinds().len().saturating_sub(1))
|
||||
} else {
|
||||
0
|
||||
}
|
||||
}
|
||||
fn device_kind_next (&self) -> usize {
|
||||
if let Some(Dialog::Device(index)) = self.dialog {
|
||||
(index + 1) % self.device_kinds().len()
|
||||
} else {
|
||||
0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[tengri_proc::command(App)] impl AppCommand {
|
||||
fn toggle_dialog (app: &mut App, dialog: Dialog) -> Perhaps<Self> {
|
||||
app.toggle_dialog(Some(dialog));
|
||||
|
|
@ -313,150 +146,9 @@ impl<'state> Context<'state, SamplerCommand> for App {
|
|||
}
|
||||
}
|
||||
|
||||
#[tengri_proc::command(App)] impl InputCommand {
|
||||
fn add (app: &mut App) -> Perhaps<Self> {
|
||||
app.midi_in_add()?;
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
#[tengri_proc::command(App)] impl OutputCommand {
|
||||
fn add (app: &mut App) -> Perhaps<Self> {
|
||||
app.midi_out_add()?;
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
#[tengri_proc::command(App)] impl DeviceCommand {
|
||||
fn cancel (app: &mut App) -> Perhaps<Self> {
|
||||
app.dialog = None;
|
||||
Ok(None)
|
||||
}
|
||||
fn picker (app: &mut App) -> Perhaps<Self> {
|
||||
app.device_picker_show();
|
||||
Ok(None)
|
||||
}
|
||||
fn pick (app: &mut App, i: usize) -> Perhaps<Self> {
|
||||
app.device_pick(i);
|
||||
Ok(None)
|
||||
}
|
||||
fn add (app: &mut App, i: usize) -> Perhaps<Self> {
|
||||
app.device_add(i);
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
#[tengri_proc::command(App)] impl MessageCommand {
|
||||
fn dismiss (app: &mut App) -> Perhaps<Self> {
|
||||
app.message_dismiss();
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
#[tengri_proc::command(App)] impl TrackCommand {
|
||||
fn toggle_play (app: &mut App) -> Perhaps<Self> {
|
||||
todo!()
|
||||
}
|
||||
fn toggle_solo (app: &mut App) -> Perhaps<Self> {
|
||||
todo!()
|
||||
}
|
||||
fn toggle_rec (app: &mut App) -> Perhaps<Self> {
|
||||
app.track_toggle_record();
|
||||
Ok(Some(Self::ToggleRec))
|
||||
}
|
||||
fn toggle_mon (app: &mut App) -> Perhaps<Self> {
|
||||
app.track_toggle_monitor();
|
||||
Ok(Some(Self::ToggleMon))
|
||||
}
|
||||
fn set_size (app: &mut App, size: usize) -> Perhaps<Self> {
|
||||
todo!()
|
||||
}
|
||||
fn set_zoom (app: &mut App, zoom: usize) -> Perhaps<Self> {
|
||||
todo!()
|
||||
}
|
||||
fn swap (app: &mut App, index: usize, other: usize) -> Perhaps<Self> {
|
||||
todo!();
|
||||
Ok(Some(Self::Swap { index, other }))
|
||||
}
|
||||
fn del (app: &mut App, index: usize) -> Perhaps<Self> {
|
||||
app.track_del(index);
|
||||
Ok(None)
|
||||
}
|
||||
fn stop (app: &mut App, index: usize) -> Perhaps<Self> {
|
||||
app.tracks[index].sequencer.enqueue_next(None);
|
||||
Ok(None)
|
||||
}
|
||||
fn add (app: &mut App) -> Perhaps<Self> {
|
||||
Ok(Some(Self::Del { index: app.track_add_focus()? }))
|
||||
}
|
||||
fn set_color (app: &mut App, index: usize, color: ItemTheme) -> Perhaps<Self> {
|
||||
Ok(Some(Self::SetColor { index, color: app.track_set_color(index, color) }))
|
||||
}
|
||||
}
|
||||
|
||||
#[tengri_proc::command(App)] impl SceneCommand {
|
||||
fn add (app: &mut App) -> Perhaps<Self> {
|
||||
todo!()
|
||||
}
|
||||
fn del (app: &mut App, index: usize) -> Perhaps<Self> {
|
||||
app.scene_del(index);
|
||||
Ok(None)
|
||||
}
|
||||
fn enqueue (app: &mut App, index: usize) -> Perhaps<Self> {
|
||||
app.scene_enqueue(index);
|
||||
Ok(None)
|
||||
}
|
||||
fn set_color (app: &mut App, index: usize, color: ItemTheme) -> Perhaps<Self> {
|
||||
Ok(Some(Self::SetColor { index, color: app.scene_set_color(index, color) }))
|
||||
}
|
||||
fn set_size (app: &mut App, index: usize, size: usize) -> Perhaps<Self> {
|
||||
todo!()
|
||||
}
|
||||
fn set_zoom (app: &mut App, index: usize, zoom: usize) -> Perhaps<Self> {
|
||||
todo!()
|
||||
}
|
||||
fn swap (app: &mut App, index: usize, other: usize) -> Perhaps<Self> {
|
||||
todo!();
|
||||
Ok(Some(Self::Swap { index, other }))
|
||||
}
|
||||
}
|
||||
|
||||
#[tengri_proc::command(App)] impl ClipCommand {
|
||||
fn get (app: &mut App, a: usize, b: usize) -> Perhaps<Self> {
|
||||
//(Get [a: usize, b: usize] cmd_todo!("\n\rtodo: clip: get: {a} {b}"))
|
||||
//("get" [a: usize, b: usize] Some(Self::Get(a.unwrap(), b.unwrap())))
|
||||
todo!()
|
||||
}
|
||||
fn edit (app: &mut App, a: usize, b: usize) -> Perhaps<Self> {
|
||||
//(Edit [clip: MaybeClip] cmd_todo!("\n\rtodo: clip: edit: {clip:?}"))
|
||||
//("edit" [a: MaybeClip] Some(Self::Edit(a.unwrap())))
|
||||
todo!()
|
||||
}
|
||||
fn set_loop (app: &mut App, a: usize, b: usize) -> Perhaps<Self> {
|
||||
//(SetLoop [t: usize, s: usize, l: bool] cmd_todo!("\n\rtodo: {self:?}"))
|
||||
//("loop" [a: usize, b: usize, c: bool] Some(Self::SetLoop(a.unwrap(), b.unwrap(), c.unwrap())))
|
||||
todo!()
|
||||
}
|
||||
fn put (app: &mut App, a: usize, b: usize) -> Perhaps<Self> {
|
||||
//(Put [t: usize, s: usize, c: MaybeClip]
|
||||
//Some(Self::Put(t, s, app.clip_put(t, s, c))))
|
||||
//("put" [a: usize, b: usize, c: MaybeClip] Some(Self::Put(a.unwrap(), b.unwrap(), c.unwrap())))
|
||||
todo!()
|
||||
}
|
||||
fn del (app: &mut App, a: usize, b: usize) -> Perhaps<Self> {
|
||||
//("delete" [a: usize, b: usize] Some(Self::Put(a.unwrap(), b.unwrap(), None))))
|
||||
todo!()
|
||||
}
|
||||
fn enqueue (app: &mut App, a: usize, b: usize) -> Perhaps<Self> {
|
||||
//(Enqueue [t: usize, s: usize]
|
||||
//cmd!(app.tracks[t].sequencer.enqueue_next(app.scenes[s].clips[t].as_ref())))
|
||||
//("enqueue" [a: usize, b: usize] Some(Self::Enqueue(a.unwrap(), b.unwrap())))
|
||||
todo!()
|
||||
}
|
||||
fn set_color (app: &mut App, a: usize, b: usize) -> Perhaps<Self> {
|
||||
//(SetColor [t: usize, s: usize, c: ItemTheme]
|
||||
//app.clip_set_color(t, s, c).map(|o|Self::SetColor(t, s, o)))));
|
||||
//("color" [a: usize, b: usize] Some(Self::SetColor(a.unwrap(), b.unwrap(), ItemTheme::random())))
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue