From 9ef63324af597e72de1fd59675e72af14b423e0d Mon Sep 17 00:00:00 2001 From: okay stopped screaming Date: Sun, 22 Mar 2026 00:00:21 +0200 Subject: [PATCH] wip: 1 more pass, 82e, near there gotta replace that Measure thing with RwLock<[u16;2]> --- src/clock.rs | 1 + src/config.rs | 2 +- src/dialog.rs | 2 +- src/mode.rs | 3 ++- src/sequence.rs | 28 ++++++++++++++++------------ src/tek.rs | 11 +++++------ 6 files changed, 26 insertions(+), 21 deletions(-) diff --git a/src/clock.rs b/src/clock.rs index 16c8de23..2e76cbc6 100644 --- a/src/clock.rs +++ b/src/clock.rs @@ -3,6 +3,7 @@ use ::std::sync::{Arc, RwLock, atomic::{AtomicUsize, Ordering::*}}; use ::atomic_float::AtomicF64; use ::tengri::{draw::*, term::*}; +impl +AsMut> HasClock for T {} pub trait HasClock: AsRef + AsMut { fn clock (&self) -> &Clock { self.as_ref() } fn clock_mut (&mut self) -> &mut Clock { self.as_mut() } diff --git a/src/config.rs b/src/config.rs index d550e789..415f99b8 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,4 +1,4 @@ -use crate::*; +use crate::{*, bind::*, mode::*, view::*}; /// Configuration: mode, view, and bind definitions. /// diff --git a/src/dialog.rs b/src/dialog.rs index 492ebed8..56ae8043 100644 --- a/src/dialog.rs +++ b/src/dialog.rs @@ -1,4 +1,4 @@ -use crate::{*, menu::*}; +use crate::{*, browse::*, device::*, menu::*}; /// Various possible dialog modes. /// diff --git a/src/mode.rs b/src/mode.rs index 46692c39..8577d80b 100644 --- a/src/mode.rs +++ b/src/mode.rs @@ -1,4 +1,5 @@ -use crate::*; +use crate::{*, config::*}; + impl Config { pub fn get_mode (&self, mode: impl AsRef) -> Option>>> { self.modes.clone().read().unwrap().get(mode.as_ref()).cloned() diff --git a/src/sequence.rs b/src/sequence.rs index 630318d5..7c3fadae 100644 --- a/src/sequence.rs +++ b/src/sequence.rs @@ -1,5 +1,9 @@ -use crate::{*, device::*}; +use crate::{*, clock::*, device::*}; +impl +AsMut> HasSequencer for T {} +impl +AsMutOpt> HasEditor for T {} +impl MidiPoint for T {} +impl MidiRange for T {} def_command!(MidiEditCommand: |editor: MidiEditor| { Show { clip: Option>> } => { editor.set_clip(clip.as_ref()); editor.redraw(); Ok(None) }, @@ -461,32 +465,32 @@ pub trait MidiPoint: NotePoint + TimePoint { pub trait TimeRange { fn time_len (&self) -> &AtomicUsize; fn get_time_len (&self) -> usize { - self.time_len().load(Ordering::Relaxed) + self.time_len().load(Relaxed) } fn time_zoom (&self) -> &AtomicUsize; fn get_time_zoom (&self) -> usize { - self.time_zoom().load(Ordering::Relaxed) + self.time_zoom().load(Relaxed) } fn set_time_zoom (&self, value: usize) -> usize { - self.time_zoom().swap(value, Ordering::Relaxed) + self.time_zoom().swap(value, Relaxed) } fn time_lock (&self) -> &AtomicBool; fn get_time_lock (&self) -> bool { - self.time_lock().load(Ordering::Relaxed) + self.time_lock().load(Relaxed) } fn set_time_lock (&self, value: bool) -> bool { - self.time_lock().swap(value, Ordering::Relaxed) + self.time_lock().swap(value, Relaxed) } fn time_start (&self) -> &AtomicUsize; fn get_time_start (&self) -> usize { - self.time_start().load(Ordering::Relaxed) + self.time_start().load(Relaxed) } fn set_time_start (&self, value: usize) -> usize { - self.time_start().swap(value, Ordering::Relaxed) + self.time_start().swap(value, Relaxed) } fn time_axis (&self) -> &AtomicUsize; fn get_time_axis (&self) -> usize { - self.time_axis().load(Ordering::Relaxed) + self.time_axis().load(Relaxed) } fn get_time_end (&self) -> usize { self.time_start().get() + self.time_axis().get() * self.time_zoom().get() @@ -496,14 +500,14 @@ pub trait TimeRange { pub trait NoteRange { fn note_lo (&self) -> &AtomicUsize; fn get_note_lo (&self) -> usize { - self.note_lo().load(Ordering::Relaxed) + self.note_lo().load(Relaxed) } fn set_note_lo (&self, x: usize) -> usize { - self.note_lo().swap(x, Ordering::Relaxed) + self.note_lo().swap(x, Relaxed) } fn note_axis (&self) -> &AtomicUsize; fn get_note_axis (&self) -> usize { - self.note_axis().load(Ordering::Relaxed) + self.note_axis().load(Relaxed) } fn get_note_hi (&self) -> usize { (self.note_lo().get() + self.note_axis().get().saturating_sub(1)).min(127) diff --git a/src/tek.rs b/src/tek.rs index 3210d078..31e5166e 100644 --- a/src/tek.rs +++ b/src/tek.rs @@ -57,6 +57,10 @@ pub mod view; use clap::{self, Parser, Subcommand}; use builder_pattern::Builder; +use self::{ + arrange::*, clock::*, dialog::*, browse::*, select::*, sequence::*, device::*, + config::*, mode::*, view::*, bind::* +}; extern crate xdg; pub(crate) use ::xdg::BaseDirectories; @@ -961,14 +965,9 @@ impl Draw for App { } } } -impl +AsMut> HasClock for T {} -impl +AsMut> HasSequencer for T {} -impl +AsMutOpt> HasEditor for T {} -impl MidiPoint for T {} -impl MidiRange for T {} impl HasClipsSize for App { fn clips_size (&self) -> &Measure { &self.project.size_inner } } impl HasJack<'static> for App { fn jack (&self) -> &Jack<'static> { &self.jack } } -impl_default!(AppCommand: Self::Nop); +impl_default!(AppCommand: Self::Nop); primitive!(u8: try_to_u8); primitive!(u16: try_to_u16); primitive!(usize: try_to_usize);