inc/dec axis values
Some checks failed
/ build (push) Has been cancelled

This commit is contained in:
i do not exist 2026-10-05 18:37:47 +03:00
parent b6f7d2d361
commit e42f400514
4 changed files with 83 additions and 57 deletions

View file

@ -512,7 +512,7 @@ pub fn tek_vec_arc_str <'a> (_: &App, _: impl Language) -> Perhaps<Vec<Arc<str>>
#[command(Enter = "enter")] pub fn enter_mode (&mut self, mode: Arc<str>) -> Perhaps<AppCmd> { #[command(Enter = "enter")] pub fn enter_mode (&mut self, mode: Arc<str>) -> Perhaps<AppCmd> {
let mut modes = self.stack().write(); let mut modes = self.stack().write();
Ok(if modes.last().map(|mode|mode.name.as_ref()) != Some(mode.as_ref()) { Ok(if modes.last().map(|mode|mode.name.as_ref()) != Some(mode.as_ref()) {
let data = Default::default(); let data = self.modes().read().get(&mode).map(|mode|&mode.data).cloned();
modes.push(Frame::new(mode, data)); modes.push(Frame::new(mode, data));
Some(AppCmd::Leave) Some(AppCmd::Leave)
} else { } else {
@ -531,25 +531,27 @@ pub fn tek_vec_arc_str <'a> (_: &App, _: impl Language) -> Perhaps<Vec<Arc<str>>
} }
/// Increment the given data axis. /// Increment the given data axis.
#[command(Inc = "inc")] pub fn inc (&mut self, axis: Arc<str>) -> Perhaps<AppCmd> { #[command(Inc = "inc")] pub fn inc (&mut self, axis: Arc<str>) -> Perhaps<AppCmd> {
if let Some(mode) = self.stack().write().last_mut() { Ok(self.stack().write().last_mut().map(|frame|{
if mode.data.contains_key(&axis) { if let Some(mode) = self.modes().read().get(&frame.name)
*mode.data.get_mut(&axis).unwrap() += 1; && let Some(param) = mode.axis.get(&axis)
} else { && mode.data.contains_key(param)
return err!("invalid axis {axis} for mode {}", &mode.name) {
*frame.data.get_mut(param).unwrap() += 1;
} }
} None
Ok(None) }).flatten())
} }
/// Decrement the given data axis. /// Decrement the given data axis.
#[command(Dec = "dec")] pub fn dec (&mut self, axis: Arc<str>) -> Perhaps<AppCmd> { #[command(Dec = "dec")] pub fn dec (&mut self, axis: Arc<str>) -> Perhaps<AppCmd> {
if let Some(mode) = self.stack().write().last_mut() { Ok(self.stack().write().last_mut().map(|frame|{
if mode.data.contains_key(&axis) { if let Some(mode) = self.modes().read().get(&frame.name)
*mode.data.get_mut(&axis).unwrap() -= 1; && let Some(param) = mode.axis.get(&axis)
} else { && mode.data.contains_key(param)
return err!("invalid axis {axis} for mode {}", &mode.name) {
*frame.data.get_mut(param).unwrap() -= 1;
} }
} None
Ok(None) }).flatten())
} }
/// Cancel current selection. /// Cancel current selection.
#[command(Cancel = "cancel")] pub fn cmd_cancel (&mut self) -> Perhaps<AppCmd> { #[command(Cancel = "cancel")] pub fn cmd_cancel (&mut self) -> Perhaps<AppCmd> {

View file

@ -33,6 +33,12 @@ impl Frame {
impl<T: AsRef<str>> From<T> for Frame { impl<T: AsRef<str>> From<T> for Frame {
fn from (name: T) -> Self { fn from (name: T) -> Self {
Self::new(name, Default::default()) Self::new(name, None)
}
}
impl From<Mode> for Frame {
fn from (mode: Mode) -> Self {
Self::new(mode.name.get(0).cloned().unwrap_or_default(), Some(mode.data.clone()))
} }
} }

View file

@ -11,26 +11,35 @@
(axis IFine @lt @gt ) (axis IFine @lt @gt )
(axis WFine @openbrace @closebrace ) (axis WFine @openbrace @closebrace )
(mode Menu (name Main Menu) (info Welcome to Tek!) (mode Menu
(axis Y Index) (data Index 1) (name Main Menu)
(info Welcome to Tek!)
(axis Y Index)
(data Index 1)
(bind Confirm) (bind Confirm)
(view (bar/s 2 Transport (bar/n 2 StatusBar (align/c (bar/s 2 (align/x Logo) Menu)))))) (view (bar/s 2 Transport (bar/n 2 StatusBar (align/c (bar/s 2 (align/x Logo) Menu))))))
(mode Help (mode Help
(axis Y Index) (data Index 0) (axis Y Index)
(axis P Page) (data Page 0) (data Index 0)
(axis P Page)
(data Page 0)
(view (bg (g 32) (fg (g 64) (full/xy (align/c (bg (g 48) (fg (g 224) (view (bg (g 32) (fg (g 64) (full/xy (align/c (bg (g 48) (fg (g 224)
(bar/s 2 (text Help yourself! ) (align/c Config)))))))))) (bar/s 2 (text Help yourself! ) (align/c Config))))))))))
(mode Options (mode Options
(axis Y Index) (data Index 0) (axis Y Index)
(axis P Page) (data Page 0) (data Index 0)
(axis P Page)
(data Page 0)
(view (bg (g 32) (fg (g 64) (full/xy (view (bg (g 32) (fg (g 64) (full/xy
(bg (g 48) (fg (g 224) (align/c (expand/wh 2 2 (text Options )))))))))) (bg (g 48) (fg (g 224) (align/c (expand/wh 2 2 (text Options ))))))))))
(mode History (mode History
(axis Y Index) (data Index 0) (axis Y Index)
(axis P Page) (data Page 0) (data Index 0)
(axis P Page)
(data Page 0)
(view (bg (g 32) (fg (g 64) (full/xy (bg (g 48) (fg (g 224) (view (bg (g 32) (fg (g 64) (full/xy (bg (g 48) (fg (g 224)
(align/c (bar/s 1 (text Project history ) HistoryList))))))))) (align/c (bar/s 1 (text Project history ) HistoryList)))))))))
@ -41,20 +50,26 @@
(bsp/e (push/x 1 (text Yes)) (align/ne (pull/x 2 (text No)))))))))))))) (bsp/e (push/x 1 (text Yes)) (align/ne (pull/x 2 (text No))))))))))))))
(mode Save (mode Save
(axis X Input) (data Input 0) (axis X Input)
(axis Y Index) (data Index 0) (data Input 0)
(axis Y Index)
(data Index 0)
(view (bg (g 32) (fg (g 64) (full/xy (bg (g 48) (fg (g 224) (view (bg (g 32) (fg (g 64) (full/xy (bg (g 48) (fg (g 224)
(align/c (bar/s 1 (expand/wh 2 2 (text Save to: )) (text <file browser here>)))))))))) (align/c (bar/s 1 (expand/wh 2 2 (text Save to: )) (text <file browser here>))))))))))
(mode Load (mode Load
(axis X Input) (data Input 0) (axis X Input)
(axis Y Index) (data Index 0) (data Input 0)
(axis Y Index)
(data Index 0)
(view (bg (g 32) (fg (g 64) (full/xy (bg (g 48) (fg (g 224) (view (bg (g 32) (fg (g 64) (full/xy (bg (g 48) (fg (g 224)
(align/c (bar/s 1 (expand/wh 2 2 (text Load from: )) (text <file browser here>)))))))))) (align/c (bar/s 1 (expand/wh 2 2 (text Load from: )) (text <file browser here>))))))))))
(mode Rename (mode Rename
(axis X Input) (data Input 0) (axis X Input)
(axis Y Index) (data Index 0) (data Input 0)
(axis Y Index)
(data Index 0)
(view (bg (g 32) (fg (g 64) (full/xy (bg (g 48) (fg (g 224) (view (bg (g 32) (fg (g 64) (full/xy (bg (g 48) (fg (g 224)
(align/c (expand/wh 2 2 (text Rename item )))))))))) (align/c (expand/wh 2 2 (text Rename item ))))))))))
@ -63,8 +78,10 @@
(view Transport)) (view Transport))
(mode Arranger (name Arranger) (info Launch grid.) (mode Arranger (name Arranger) (info Launch grid.)
(axis X Track) (data Track 1) (axis X Track)
(axis Y Scene) (data Scene 1) (data Track 1)
(axis Y Scene)
(data Scene 1)
(bind Global Clock Tracks Scenes Clip Launch Color History) (bind Global Clock Tracks Scenes Clip Launch Color History)
(view (bar/n 2 StatusBar (bar/s 8 (bar/e 16 (align/nw Transport) (view (bar/n 2 StatusBar (bar/s 8 (bar/e 16 (align/nw Transport)
(bar/w 20 (bar/s 2 (bar/w 4 TracksOutputsAdd TracksOutputsCount) (bar/w 20 (bar/s 2 (bar/w 4 TracksOutputsAdd TracksOutputsCount)
@ -77,8 +94,10 @@
(bar/w 20 (text) (bar/e 16 ScenesNames ScenesClips)))))) (bar/w 20 (text) (bar/e 16 ScenesNames ScenesClips))))))
(mode Edit (info MIDI editor.) (mode Edit (info MIDI editor.)
(axis X Time) (data Time 0) (axis X Time)
(axis Y Pitch) (data Pitch 36)) (data Time 0)
(axis Y Pitch)
(data Pitch 36))
(mode Sequencer (info MIDI sequencer.) (mode Sequencer (info MIDI sequencer.)
(bind Global Clock I IFine Y Page EditorView EditorAdd EditorDel) (bind Global Clock I IFine Y Page EditorView EditorAdd EditorDel)

View file

@ -723,35 +723,34 @@ pub use self::proj::*; mod proj {
Config => watch.config_print(), Config => watch.config_print(),
Resume => todo!("resume session"), Resume => todo!("resume session"),
List => todo!("list sessions"), List => todo!("list sessions"),
New(sesh) => Exit::run(|exit|Tui::run_main( New(sesh) => Exit::run(|exit|Tui::run_main(exit.clone(), {
exit.clone(), #[allow(unused_mut)]
{ let mut app = App::new(Some(exit), sesh.init()?, watch, None);
#[allow(unused_mut)] app.dialog = Dialog::welcome();
let mut app = App::new(Some(exit), sesh.init()?, watch, Some(vec![ app.enter_mode("Menu".into())?;
"Menu".into() #[cfg(feature = "prof2")] app.trace(trace);
])); Arc::new(RwLock::new(app))
app.dialog = Dialog::welcome(); })).map(|_|())?,
#[cfg(feature = "prof2")] {
if trace {
app.guard = Some({
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
//let tracy = tracing_tracy::TracyLayer::default();
let (flame, _guard) = tracing_flame::FlameLayer::with_file("./tracing.folded").unwrap();
//let registry = tracing_subscriber::registry().with(flame).init();
//tracing::subscriber::set_global_default(registry)?;
tracing::subscriber::set_global_default(tracing_subscriber::registry().with(flame))?;
_guard
})
}
}
Arc::new(RwLock::new(app))
})).map(|_|())?,
_ => todo!() _ => todo!()
} }
Ok(()) Ok(())
} }
} }
impl App {
#[cfg(feature = "prof2")] fn trace (&mut self, trace: bool) {
self.guard = trace.then(||Some({
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
//let tracy = tracing_tracy::TracyLayer::default();
let (flame, _guard) = tracing_flame::FlameLayer::with_file("./tracing.folded").unwrap();
//let registry = tracing_subscriber::registry().with(flame).init();
//tracing::subscriber::set_global_default(registry)?;
tracing::subscriber::set_global_default(tracing_subscriber::registry().with(flame))?;
_guard
}));
}
}
pub fn print_status (project: &Project) { pub fn print_status (project: &Project) {
println!("Name: {:?}", &project.name); println!("Name: {:?}", &project.name);
println!("JACK: {:?}", &project.jack); println!("JACK: {:?}", &project.jack);