rename AppSection -> AppFocus

This commit is contained in:
🪞👃🪞 2024-07-12 19:11:47 +03:00
parent 94738d3e89
commit 58cd51dfbf
7 changed files with 19 additions and 18 deletions

View file

@ -22,10 +22,11 @@ See `demos/project.edn` for the initial contents of the session.
* [ ] Customize key map * [ ] Customize key map
* [ ] MIDI map * [ ] MIDI map
* [ ] Scriptable * [ ] Scriptable
* Save project * Save project:
* [ ] Preserve layout * [ ] Preserve EDN layout
* Samples: * Samples:
* [ ] Sample browser * [ ] Sample browser
* [ ] Sample editor
* [ ] Envelope * [ ] Envelope
* [ ] Stretch sample to BPM * [ ] Stretch sample to BPM
* [ ] Set BPM to sample * [ ] Set BPM to sample

View file

@ -1,4 +1,4 @@
use crate::{core::*, handle, App, AppSection}; use crate::{core::*, handle, App, AppFocus};
pubmod!{ arranger chain focus mixer plugin sampler sequencer transport } pubmod!{ arranger chain focus mixer plugin sampler sequencer transport }
@ -26,13 +26,13 @@ handle!{
fn handle_focused (state: &mut App, e: &AppEvent) -> Usually<bool> { fn handle_focused (state: &mut App, e: &AppEvent) -> Usually<bool> {
match state.section { match state.section {
AppSection::Transport => AppFocus::Transport =>
handle_keymap(state, e, crate::control::transport::KEYMAP_TRANSPORT), handle_keymap(state, e, crate::control::transport::KEYMAP_TRANSPORT),
AppSection::Arranger => AppFocus::Arranger =>
handle_keymap(state, e, crate::control::arranger::KEYMAP_ARRANGER), handle_keymap(state, e, crate::control::arranger::KEYMAP_ARRANGER),
AppSection::Sequencer => AppFocus::Sequencer =>
handle_keymap(state, e, crate::control::sequencer::KEYMAP_SEQUENCER), handle_keymap(state, e, crate::control::sequencer::KEYMAP_SEQUENCER),
AppSection::Chain => Ok(if state.entered { AppFocus::Chain => Ok(if state.entered {
handle_device(state, e)? || handle_device(state, e)? ||
handle_keymap(state, e, crate::control::chain::KEYMAP_CHAIN)? handle_keymap(state, e, crate::control::chain::KEYMAP_CHAIN)?
} else { } else {

View file

@ -1,4 +1,4 @@
use crate::{core::*, model::{App, AppSection}}; use crate::{core::*, model::{App, AppFocus}};
pub const KEYMAP_FOCUS: &'static [KeyBinding<App>] = keymap!(App { pub const KEYMAP_FOCUS: &'static [KeyBinding<App>] = keymap!(App {
[Char(';'), NONE, "command", "open command palette", |app: &mut App| { [Char(';'), NONE, "command", "open command palette", |app: &mut App| {
@ -19,14 +19,14 @@ pub const KEYMAP_FOCUS: &'static [KeyBinding<App>] = keymap!(App {
pub fn focus_next (app: &mut App) -> Usually<bool> { pub fn focus_next (app: &mut App) -> Usually<bool> {
app.section.next(); app.section.next();
app.transport.focused = app.section == AppSection::Transport; app.transport.focused = app.section == AppFocus::Transport;
app.transport.entered = app.entered; app.transport.entered = app.entered;
Ok(true) Ok(true)
} }
pub fn focus_prev (app: &mut App) -> Usually<bool> { pub fn focus_prev (app: &mut App) -> Usually<bool> {
app.section.prev(); app.section.prev();
app.transport.focused = app.section == AppSection::Transport; app.transport.focused = app.section == AppFocus::Transport;
app.transport.entered = app.entered; app.transport.entered = app.entered;
Ok(true) Ok(true)
} }

View file

@ -36,7 +36,7 @@ pub struct App {
/// Optional modal dialog /// Optional modal dialog
pub modal: Option<Box<dyn Exit>>, pub modal: Option<Box<dyn Exit>>,
/// Currently focused section /// Currently focused section
pub section: AppSection, pub section: AppFocus,
/// Whether the current focus section has input priority /// Whether the current focus section has input priority
pub entered: bool, pub entered: bool,
/// Display position of cursor within note range /// Display position of cursor within note range
@ -82,7 +82,7 @@ impl App {
note_start: 2, note_start: 2,
scene_cursor: 1, scene_cursor: 1,
scenes: vec![], scenes: vec![],
section: AppSection::default(), section: AppFocus::default(),
seq_mode: false, seq_mode: false,
seq_buf: BufferedSequencerView::new(96, 16384), seq_buf: BufferedSequencerView::new(96, 16384),
time_cursor: 0, time_cursor: 0,
@ -155,9 +155,9 @@ impl App {
} }
#[derive(PartialEq, Clone, Copy)] #[derive(PartialEq, Clone, Copy)]
pub enum AppSection { Transport, Arranger, Sequencer, Chain, } pub enum AppFocus { Transport, Arranger, Sequencer, Chain, }
impl Default for AppSection { fn default () -> Self { Self::Arranger } } impl Default for AppFocus { fn default () -> Self { Self::Arranger } }
impl AppSection { impl AppFocus {
pub fn prev (&mut self) { pub fn prev (&mut self) {
*self = match self { *self = match self {
Self::Transport => Self::Chain, Self::Transport => Self::Chain,

View file

@ -14,7 +14,7 @@ pub struct ArrangerView<'a> {
impl<'a> ArrangerView<'a> { impl<'a> ArrangerView<'a> {
pub fn new (app: &'a App, vertical: bool) -> Self { pub fn new (app: &'a App, vertical: bool) -> Self {
Self { Self {
focused: app.section == AppSection::Arranger, focused: app.section == AppFocus::Arranger,
entered: app.entered, entered: app.entered,
scenes: &app.scenes, scenes: &app.scenes,
tracks: &app.tracks, tracks: &app.tracks,

View file

@ -18,7 +18,7 @@ impl<'a> ChainView<'a> {
Self { Self {
direction, direction,
entered: app.entered, entered: app.entered,
focused: app.section == AppSection::Chain, focused: app.section == AppFocus::Chain,
track: match app.track_cursor { track: match app.track_cursor {
0 => None, 0 => None,
_ => app.tracks.get(app.track_cursor - 1) _ => app.tracks.get(app.track_cursor - 1)

View file

@ -111,7 +111,7 @@ impl<'a> SequencerView<'a> {
}; };
Self { Self {
phrase: app.phrase(), phrase: app.phrase(),
focused: app.section == AppSection::Sequencer, focused: app.section == AppFocus::Sequencer,
entered: app.entered, entered: app.entered,
ppq: app.transport.ppq(), ppq: app.transport.ppq(),
now: app.transport.pulse(), now: app.transport.pulse(),