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
* [ ] MIDI map
* [ ] Scriptable
* Save project
* [ ] Preserve layout
* Save project:
* [ ] Preserve EDN layout
* Samples:
* [ ] Sample browser
* [ ] Sample editor
* [ ] Envelope
* [ ] Stretch sample to BPM
* [ ] 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 }
@ -26,13 +26,13 @@ handle!{
fn handle_focused (state: &mut App, e: &AppEvent) -> Usually<bool> {
match state.section {
AppSection::Transport =>
AppFocus::Transport =>
handle_keymap(state, e, crate::control::transport::KEYMAP_TRANSPORT),
AppSection::Arranger =>
AppFocus::Arranger =>
handle_keymap(state, e, crate::control::arranger::KEYMAP_ARRANGER),
AppSection::Sequencer =>
AppFocus::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_keymap(state, e, crate::control::chain::KEYMAP_CHAIN)?
} 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 {
[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> {
app.section.next();
app.transport.focused = app.section == AppSection::Transport;
app.transport.focused = app.section == AppFocus::Transport;
app.transport.entered = app.entered;
Ok(true)
}
pub fn focus_prev (app: &mut App) -> Usually<bool> {
app.section.prev();
app.transport.focused = app.section == AppSection::Transport;
app.transport.focused = app.section == AppFocus::Transport;
app.transport.entered = app.entered;
Ok(true)
}

View file

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

View file

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

View file

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

View file

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