diff --git a/src/arrange.rs b/src/arrange.rs index e336951f..96cb8241 100644 --- a/src/arrange.rs +++ b/src/arrange.rs @@ -20,9 +20,9 @@ impl HasJack<'static> for Arrangement { fn jack (&self) -> &Jack<'static> { &sel /// TODO rename to "render_cache" or smth pub arranger: Arc>, /// Display size - pub size: Measure, + pub size: [AtomicUsize; 2], /// Display size of clips area - pub size_inner: Measure, + pub size_inner: [AtomicUsize; 2], /// Source of time #[cfg(feature = "clock")] pub clock: Clock, /// Allows one MIDI clip to be edited @@ -84,7 +84,7 @@ impl HasJack<'static> for Arrangement { fn jack (&self) -> &Jack<'static> { &sel } impl_has!(Jack<'static>: |self: Arrangement| self.jack); -impl_has!(Measure: |self: Arrangement| self.size); +impl_has!([AtomicUsize; 2]: |self: Arrangement| self.size); impl_has!(Vec: |self: Arrangement| self.tracks); impl_has!(Vec: |self: Arrangement| self.scenes); impl_has!(Vec: |self: Arrangement| self.midi_ins); @@ -96,12 +96,12 @@ impl_as_mut_opt!(MidiEditor: |self: Arrangement| self.editor.as_mut()); impl_as_ref_opt!(Track: |self: Arrangement| self.selected_track()); impl_as_mut_opt!(Track: |self: Arrangement| self.selected_track_mut()); -impl >+AsMut>> HasScenes for T {} -impl >+AsMut>> HasTracks for T {} -impl +AsMutOpt+Send+Sync> HasScene for T {} -impl +AsMutOpt+Send+Sync> HasTrack for T {} -impl > TracksView for T {} -impl ClipsView for T {} +impl >+AsMut>> HasScenes for T {} +impl >+AsMut>> HasTracks for T {} +impl +AsMutOpt+Send+Sync> HasScene for T {} +impl +AsMutOpt+Send+Sync> HasTrack for T {} +impl TracksView for T {} +impl ClipsView for T {} pub trait ClipsView: TracksView + ScenesView { @@ -173,7 +173,7 @@ pub trait ClipsView: TracksView + ScenesView { } -pub trait TracksView: ScenesView + HasMidiIns + HasMidiOuts + HasTrackScroll + Measured { +pub trait TracksView: ScenesView + HasMidiIns + HasMidiOuts + HasTrackScroll { fn tracks_width_available (&self) -> u16 { (self.measure_width() as u16).saturating_sub(40) @@ -787,7 +787,7 @@ impl ScenesView for Arrangement { } } impl HasClipsSize for Arrangement { - fn clips_size (&self) -> &Measure { &self.size_inner } + fn clips_size (&self) -> &[AtomicUsize; 2] { &self.size_inner } } pub type SceneWith<'a, T> = diff --git a/src/browse.rs b/src/browse.rs index d0289fe5..34ad8982 100644 --- a/src/browse.rs +++ b/src/browse.rs @@ -21,7 +21,7 @@ def_command!(FileBrowserCommand: |sampler: Sampler|{ pub filter: String, pub index: usize, pub scroll: usize, - pub size: Measure, + pub size: [AtomicUsize; 2], } pub(crate) struct EntriesIterator<'a> { diff --git a/src/sample.rs b/src/sample.rs index 6196b93f..01dfbbe0 100644 --- a/src/sample.rs +++ b/src/sample.rs @@ -78,7 +78,7 @@ def_command!(SamplerCommand: |sampler: Sampler| { /// Currently active modal, if any. pub mode: Option, /// Size of rendered sampler. - pub size: Measure, + pub size: [AtomicUsize;2], /// Lowest note displayed. pub note_lo: AtomicUsize, /// Currently selected note. diff --git a/src/sequence.rs b/src/sequence.rs index 7c3fadae..1b210dd3 100644 --- a/src/sequence.rs +++ b/src/sequence.rs @@ -45,7 +45,7 @@ def_command!(MidiEditCommand: |editor: MidiEditor| { /// ``` pub struct MidiEditor { /// Size of editor on screen - pub size: Measure, + pub size: [AtomicUsize; 2], /// View mode and state of editor pub mode: PianoHorizontal, } @@ -60,13 +60,13 @@ pub struct MidiEditor { /// Buffer where the whole clip is rerendered on change pub buffer: Arc>, /// Size of actual notes area - pub size: Measure, + pub size: [AtomicUsize; 2], /// The display window - pub range: MidiSelection, + pub range: MidiSelection, /// The note cursor - pub point: MidiCursor, + pub point: MidiCursor, /// The highlight color palette - pub color: ItemTheme, + pub color: ItemTheme, /// Width of the keyboard pub keys_width: u16, } @@ -646,8 +646,8 @@ impl_has!(Sequencer: |self: Track| self.sequencer); impl_has!(Clock: |self: Sequencer| self.clock); impl_has!(Vec: |self: Sequencer| self.midi_ins); impl_has!(Vec: |self: Sequencer| self.midi_outs); -impl_has!(Measure: |self: MidiEditor| self.size); -impl_has!(Measure: |self: PianoHorizontal| self.size); +impl_has!([AtomicUsize; 2]: |self: MidiEditor| self.size); +impl_has!([AtomicUsize; 2]: |self: PianoHorizontal| self.size); impl_default!(Sequencer: Self { clock: Clock::default(), play_clip: None, @@ -890,7 +890,7 @@ impl_from!(MidiEditor: |clip: Option>>| { model }); impl_default!(MidiEditor: Self { - size: Measure::new(0, 0), mode: PianoHorizontal::new(None) + size: [0, 0].into(), mode: PianoHorizontal::new(None) }); impl_default!(OctaveVertical: Self { on: [false; 12], colors: [Rgb(255,255,255), Rgb(0,0,0), Rgb(255,0,0)] @@ -1040,7 +1040,7 @@ impl MidiEditor { impl PianoHorizontal { pub fn new (clip: Option<&Arc>>) -> Self { - let size = Measure::new(0, 0); + let size = [0, 0].into(); let mut range = MidiSelection::from((12, true)); range.time_axis = size.x.clone(); range.note_axis = size.y.clone(); diff --git a/src/tek.rs b/src/tek.rs index 31e5166e..67655ac9 100644 --- a/src/tek.rs +++ b/src/tek.rs @@ -59,7 +59,7 @@ use clap::{self, Parser, Subcommand}; use builder_pattern::Builder; use self::{ arrange::*, clock::*, dialog::*, browse::*, select::*, sequence::*, device::*, - config::*, mode::*, view::*, bind::* + config::*, mode::*, view::*, bind::*, sample::*, menu::* }; extern crate xdg; @@ -588,7 +588,7 @@ pub(crate) const HEADER: &'static str = r#" /// Must not be dropped for the duration of the process pub jack: Jack<'static>, /// Display size - pub size: Measure, + pub size: [AtomicUsize;2], /// Performance counter pub perf: PerfModel, /// Available view modes and input bindings @@ -611,7 +611,7 @@ impl_has!(Vec: |self: App|self.project.midi_ins); impl_has!(Vec: |self: App|self.project.midi_outs); impl_has!(Dialog: |self: App|self.dialog); impl_has!(Jack<'static>: |self: App|self.jack); -impl_has!(Measure: |self: App|self.size); +impl_has!([AtomicUsize;2]: |self: App|self.size); impl_has!(Pool: |self: App|self.pool); impl_has!(Selection: |self: App|self.project.selection); impl_as_ref!(Vec: |self: App|self.project.as_ref()); @@ -688,7 +688,7 @@ namespace!(App: Option>> { }; }); -pub trait HasClipsSize { fn clips_size (&self) -> &Measure; } +pub trait HasClipsSize { fn clips_size (&self) -> &[AtomicUsize;2]; } pub trait HasDevices: AsRef> + AsMut> { fn devices (&self) -> &Vec { self.as_ref() } @@ -965,7 +965,7 @@ impl Draw for App { } } } -impl HasClipsSize for App { fn clips_size (&self) -> &Measure { &self.project.size_inner } } +impl HasClipsSize for App { fn clips_size (&self) -> &[AtomicUsize;2] { &self.project.size_inner } } impl HasJack<'static> for App { fn jack (&self) -> &Jack<'static> { &self.jack } } impl_default!(AppCommand: Self::Nop); primitive!(u8: try_to_u8);