From dc1f5f4a17d92b16f59d4562f3cec055534f4fd4 Mon Sep 17 00:00:00 2001 From: unspeaker Date: Fri, 12 Jul 2024 20:32:11 +0300 Subject: [PATCH] more doc string and reexport fixes --- src/model.rs | 32 ++++++++++++++------------------ src/model/looper.rs | 1 + src/model/mixer.rs | 4 +++- src/model/phrase.rs | 1 + src/model/plugin.rs | 10 ++++------ src/model/plugin/lv2.rs | 1 + src/model/sampler.rs | 1 + src/model/scene.rs | 1 + src/model/track.rs | 1 + src/model/transport.rs | 5 +++-- src/view.rs | 22 ++++------------------ src/view/help.rs | 4 ++-- src/view/plugin.rs | 2 +- 13 files changed, 37 insertions(+), 48 deletions(-) diff --git a/src/model.rs b/src/model.rs index 967a4d0a..809232a4 100644 --- a/src/model.rs +++ b/src/model.rs @@ -1,24 +1,10 @@ //! Application state. -pub mod looper; -pub mod mixer; -pub mod phrase; -pub mod plugin; -pub mod sampler; -pub mod scene; -pub mod track; -pub mod transport; - -pub use self::phrase::{Phrase, PhraseData}; -pub use self::scene::Scene; -pub use self::track::Track; -pub use self::sampler::{Sampler, Sample, read_sample_data}; -pub use self::mixer::Mixer; -pub use self::plugin::{Plugin, PluginKind, lv2::LV2Plugin}; -pub use self::transport::{TransportToolbar, TransportFocus}; +submod! { looper mixer phrase plugin sampler scene track transport } use crate::{core::*, view::*}; +/// Root of application state. pub struct App { /// Main JACK client. pub jack: Option, @@ -156,9 +142,19 @@ impl App { } } +/// Different sections of the UI that may be focused. #[derive(PartialEq, Clone, Copy)] -pub enum AppFocus { Transport, Arranger, Sequencer, Chain, } -impl Default for AppFocus { fn default () -> Self { Self::Arranger } } +pub enum AppFocus { + Transport, + Arranger, + Sequencer, + Chain, +} + +impl Default for AppFocus { + fn default () -> Self { Self::Arranger } +} + impl AppFocus { pub fn prev (&mut self) { *self = match self { diff --git a/src/model/looper.rs b/src/model/looper.rs index 0e2e1756..9166aff5 100644 --- a/src/model/looper.rs +++ b/src/model/looper.rs @@ -1,5 +1,6 @@ use crate::core::*; +/// TODO: audio looper. (Integrate with [crate::model::Sampler]?) pub struct Looper { pub name: String } diff --git a/src/model/mixer.rs b/src/model/mixer.rs index cd69ecdc..e126dfea 100644 --- a/src/model/mixer.rs +++ b/src/model/mixer.rs @@ -1,5 +1,6 @@ use crate::core::*; +/// TODO: audio mixer. pub struct Mixer { pub name: String, pub tracks: Vec, @@ -31,7 +32,7 @@ impl Mixer { } } -pub fn process ( +fn process ( _: &mut Mixer, _: &Client, _: &ProcessScope @@ -39,6 +40,7 @@ pub fn process ( Control::Continue } +/// TODO: A track in the mixer. (Integrate with [crate::model::Track]?) pub struct MixerTrack { pub name: String, pub channels: u8, diff --git a/src/model/phrase.rs b/src/model/phrase.rs index ce64149d..7be3e904 100644 --- a/src/model/phrase.rs +++ b/src/model/phrase.rs @@ -60,6 +60,7 @@ impl App { pub type PhraseData = Vec>; #[derive(Debug)] +/// A MIDI sequence. pub struct Phrase { pub name: String, pub length: usize, diff --git a/src/model/plugin.rs b/src/model/plugin.rs index 26a00861..540ec10f 100644 --- a/src/model/plugin.rs +++ b/src/model/plugin.rs @@ -1,11 +1,8 @@ use crate::core::*; -pub mod lv2; -pub mod vst2; -pub mod vst3; - -use self::lv2::*; +submod! { lv2 vst2 vst3 } +/// A plugin device. pub struct Plugin { pub name: String, pub path: Option, @@ -14,10 +11,11 @@ pub struct Plugin { pub mapping: bool, pub ports: JackPorts, } -render!(Plugin = crate::view::plugin::render); +render!(Plugin = crate::view::render_plugin); handle!(Plugin = crate::control::handle_plugin); process!(Plugin = Plugin::process); +/// Supported plugin formats. pub enum PluginKind { LV2(LV2Plugin), VST2 { diff --git a/src/model/plugin/lv2.rs b/src/model/plugin/lv2.rs index 3002ee39..544ae21c 100644 --- a/src/model/plugin/lv2.rs +++ b/src/model/plugin/lv2.rs @@ -10,6 +10,7 @@ use ::livi::{ event::LV2AtomSequence, }; +/// A LV2 plugin. pub struct LV2Plugin { pub world: World, pub instance: Instance, diff --git a/src/model/sampler.rs b/src/model/sampler.rs index fc0841a4..c3c2ebc6 100644 --- a/src/model/sampler.rs +++ b/src/model/sampler.rs @@ -1,5 +1,6 @@ use crate::core::*; +/// The sampler plugin plays sounds. pub struct Sampler { pub name: String, pub cursor: (usize, usize), diff --git a/src/model/scene.rs b/src/model/scene.rs index ecf55480..272a3576 100644 --- a/src/model/scene.rs +++ b/src/model/scene.rs @@ -43,6 +43,7 @@ impl App { } } +/// A collection of phrases to play on each track. pub struct Scene { pub name: String, pub clips: Vec>, diff --git a/src/model/track.rs b/src/model/track.rs index fb3ae537..ca1c4782 100644 --- a/src/model/track.rs +++ b/src/model/track.rs @@ -41,6 +41,7 @@ impl App { } } +/// A sequencer track. pub struct Track { pub name: String, /// Play input through output. diff --git a/src/model/transport.rs b/src/model/transport.rs index b1c4610f..2fa89ae8 100644 --- a/src/model/transport.rs +++ b/src/model/transport.rs @@ -1,6 +1,7 @@ use crate::core::*; #[derive(PartialEq)] +/// Which section of the transport is focused pub enum TransportFocus { BPM, Quant, Sync } impl TransportFocus { @@ -20,9 +21,10 @@ impl TransportFocus { } } +/// Stored and displays time-related state. pub struct TransportToolbar { + /// Enable metronome? pub metronome: bool, - pub mode: bool, pub focused: bool, pub entered: bool, pub selected: TransportFocus, @@ -48,7 +50,6 @@ impl TransportToolbar { Self { selected: TransportFocus::BPM, metronome: false, - mode: false, focused: false, entered: false, playhead: 0, diff --git a/src/view.rs b/src/view.rs index 6e1017ec..61cb2500 100644 --- a/src/view.rs +++ b/src/view.rs @@ -1,25 +1,11 @@ //! Rendering of application to display. -pub mod arranger; -pub mod border; -pub mod chain; -pub mod help; -pub mod plugin; -pub mod sequencer; -pub mod split; -pub mod theme; -pub mod transport; - -pub use self::arranger::*; -pub use self::border::*; -pub use self::chain::ChainView; -pub use self::help::*; -pub use self::sequencer::{SequencerView, BufferedSequencerView}; -pub use self::split::*; -pub use self::theme::*; - use crate::{render, App, core::*}; +submod! { + arranger border chain help plugin sequencer split theme transport +} + render!(App |self, buf, area| { Split::down([ &self.transport, diff --git a/src/view/help.rs b/src/view/help.rs index a3d0799e..f231cdf6 100644 --- a/src/view/help.rs +++ b/src/view/help.rs @@ -1,11 +1,11 @@ use crate::{core::*, view::*}; +/// Command palette. pub struct HelpModal { cursor: usize, search: Option, exited: bool, } - impl HelpModal { pub fn new () -> Self { Self { cursor: 0, search: None, exited: false } @@ -52,7 +52,7 @@ render!(HelpModal |self, buf, area|{ format!("{:?}", command.0).blit(buf, x, y, Some(Style::default().white().bold()))?; command.2.blit(buf, x + 11, y, Some(Style::default().white().bold()))?; command.3.blit(buf, x + 26, y, Some(Style::default().white().dim()))?; - } else if let Some(command) = crate::control::KEYMAP.get((i as usize) - crate::control::KEYMAP_FOCUS.len()) { + } else if let Some(command) = crate::control::KEYMAP_GLOBAL.get((i as usize) - crate::control::KEYMAP_FOCUS.len()) { format!("{:?}", command.0).blit(buf, x, y, Some(Style::default().white().bold()))?; command.2.blit(buf, x + 11, y, Some(Style::default().white().bold()))?; command.3.blit(buf, x + 26, y, Some(Style::default().white().dim()))?; diff --git a/src/view/plugin.rs b/src/view/plugin.rs index d79c2168..2433f40a 100644 --- a/src/view/plugin.rs +++ b/src/view/plugin.rs @@ -1,6 +1,6 @@ use crate::{core::*, model::*}; -pub fn render (state: &Plugin, buf: &mut Buffer, area: Rect) +pub fn render_plugin (state: &Plugin, buf: &mut Buffer, area: Rect) -> Usually { let Rect { x, y, height, .. } = area;