From f49615d59855261a927972b344c3e6c50f9d106c Mon Sep 17 00:00:00 2001 From: unspeaker Date: Sat, 13 Jul 2024 23:29:51 +0300 Subject: [PATCH] update docs and extract handle_modal --- src/control.rs | 21 ++++++++++++++------- src/devices.rs | 9 --------- src/devices/arranger.rs | 2 +- src/devices/looper.rs | 3 ++- src/devices/mixer.rs | 5 +++-- src/devices/plugin.rs | 3 ++- src/devices/sampler.rs | 3 ++- src/devices/sequencer.rs | 2 +- src/devices/transport.rs | 2 ++ 9 files changed, 27 insertions(+), 23 deletions(-) diff --git a/src/control.rs b/src/control.rs index 63ac5277..c80bc48d 100644 --- a/src/control.rs +++ b/src/control.rs @@ -4,13 +4,8 @@ use crate::{core::*, handle, App, AppFocus}; handle!{ App |self, e| { - if let Some(ref mut modal) = self.modal { - if modal.handle(e)? { - if modal.exited() { - self.modal = None; - } - return Ok(true) - }; + if handle_modal(self, e)? { + return Ok(true) } Ok(if self.entered { handle_focused(self, e)? @@ -24,6 +19,18 @@ handle!{ } } +fn handle_modal (state: &mut App, e: &AppEvent) -> Usually { + if let Some(ref mut modal) = state.modal { + if modal.handle(e)? { + if modal.exited() { + state.modal = None; + } + return Ok(true) + }; + } + Ok(false) +} + fn handle_focused (state: &mut App, e: &AppEvent) -> Usually { match state.section { AppFocus::Transport => diff --git a/src/devices.rs b/src/devices.rs index af7041ff..f3b167f2 100644 --- a/src/devices.rs +++ b/src/devices.rs @@ -1,11 +1,2 @@ //! Music-making apparatuses. -//! -//! The following devices are provided: -//! -//! - Transport controller -//! - Arranger (clip launcher) -//! - Sequencer (phrase editor) -//! - Plugin (currently LV2 only) -//! - Sampler (currently 16bit samples only) - crate::core::pubmod!{arranger looper mixer plugin sampler sequencer transport} diff --git a/src/devices/arranger.rs b/src/devices/arranger.rs index 8e430af0..9416409d 100644 --- a/src/devices/arranger.rs +++ b/src/devices/arranger.rs @@ -1,4 +1,4 @@ -/// Arrangement editor. +//! Clip launcher and arrangement editor. use crate::{core::*, model::*, view::*}; diff --git a/src/devices/looper.rs b/src/devices/looper.rs index daa27295..9a8cf879 100644 --- a/src/devices/looper.rs +++ b/src/devices/looper.rs @@ -1,6 +1,7 @@ +//! TODO: audio looper (merge with [crate::devices::sampler::Sampler]?) + use crate::core::*; -/// TODO: audio looper. (Integrate with [crate::model::Sampler]?) pub struct Looper { pub name: String } diff --git a/src/devices/mixer.rs b/src/devices/mixer.rs index 43222fb0..0d195eef 100644 --- a/src/devices/mixer.rs +++ b/src/devices/mixer.rs @@ -1,4 +1,6 @@ -use crate::{core::*, model::*}; +//! TODO: audio mixer (merge with [crate::devices::arranger::Arranger]?) + +use crate::core::*; // TODO: // - Meters: propagate clipping: @@ -10,7 +12,6 @@ use crate::{core::*, model::*}; //("Ins/Del", "Add/remove track"), //]; -/// TODO: audio mixer. pub struct Mixer { pub name: String, pub tracks: Vec, diff --git a/src/devices/plugin.rs b/src/devices/plugin.rs index 552d523f..b2d7dacd 100644 --- a/src/devices/plugin.rs +++ b/src/devices/plugin.rs @@ -1,5 +1,6 @@ -use crate::core::*; +//! Plugin (currently LV2 only; TODO other formats) +use crate::core::*; use ::livi::{ World, Instance, diff --git a/src/devices/sampler.rs b/src/devices/sampler.rs index f77cd32e..ca34d460 100644 --- a/src/devices/sampler.rs +++ b/src/devices/sampler.rs @@ -1,5 +1,6 @@ -use crate::{core::*, model::*}; +//! Sampler (currently 16bit WAVs at system rate; TODO convert/resample) +use crate::{core::*, model::*}; /// Key bindings for sampler device. pub const KEYMAP_SAMPLER: &'static [KeyBinding] = keymap!(Sampler { diff --git a/src/devices/sequencer.rs b/src/devices/sequencer.rs index 9c1dae52..69525d4a 100644 --- a/src/devices/sequencer.rs +++ b/src/devices/sequencer.rs @@ -1,4 +1,4 @@ -/// Phrase editor. +//! Phrase editor. use crate::{core::*, model::*, view::*}; diff --git a/src/devices/transport.rs b/src/devices/transport.rs index 9e564c44..78c31024 100644 --- a/src/devices/transport.rs +++ b/src/devices/transport.rs @@ -1,3 +1,5 @@ +//! Transport controller. + use crate::{core::*, view::*, model::App}; /// Key bindings for transport toolbar.