mirror of
https://codeberg.org/unspeaker/tek.git
synced 2026-04-03 21:00:44 +02:00
gotta replace that Measure thing with RwLock<[u16;2]>
This commit is contained in:
parent
60dbd89fc9
commit
9ef63324af
6 changed files with 26 additions and 21 deletions
|
|
@ -3,6 +3,7 @@ use ::std::sync::{Arc, RwLock, atomic::{AtomicUsize, Ordering::*}};
|
||||||
use ::atomic_float::AtomicF64;
|
use ::atomic_float::AtomicF64;
|
||||||
use ::tengri::{draw::*, term::*};
|
use ::tengri::{draw::*, term::*};
|
||||||
|
|
||||||
|
impl <T: AsRef<Clock>+AsMut<Clock>> HasClock for T {}
|
||||||
pub trait HasClock: AsRef<Clock> + AsMut<Clock> {
|
pub trait HasClock: AsRef<Clock> + AsMut<Clock> {
|
||||||
fn clock (&self) -> &Clock { self.as_ref() }
|
fn clock (&self) -> &Clock { self.as_ref() }
|
||||||
fn clock_mut (&mut self) -> &mut Clock { self.as_mut() }
|
fn clock_mut (&mut self) -> &mut Clock { self.as_mut() }
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::*;
|
use crate::{*, bind::*, mode::*, view::*};
|
||||||
|
|
||||||
/// Configuration: mode, view, and bind definitions.
|
/// Configuration: mode, view, and bind definitions.
|
||||||
///
|
///
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::{*, menu::*};
|
use crate::{*, browse::*, device::*, menu::*};
|
||||||
|
|
||||||
/// Various possible dialog modes.
|
/// Various possible dialog modes.
|
||||||
///
|
///
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
use crate::*;
|
use crate::{*, config::*};
|
||||||
|
|
||||||
impl Config {
|
impl Config {
|
||||||
pub fn get_mode (&self, mode: impl AsRef<str>) -> Option<Arc<Mode<Arc<str>>>> {
|
pub fn get_mode (&self, mode: impl AsRef<str>) -> Option<Arc<Mode<Arc<str>>>> {
|
||||||
self.modes.clone().read().unwrap().get(mode.as_ref()).cloned()
|
self.modes.clone().read().unwrap().get(mode.as_ref()).cloned()
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,9 @@
|
||||||
use crate::{*, device::*};
|
use crate::{*, clock::*, device::*};
|
||||||
|
|
||||||
|
impl <T: AsRef<Sequencer>+AsMut<Sequencer>> HasSequencer for T {}
|
||||||
|
impl <T: AsRefOpt<MidiEditor>+AsMutOpt<MidiEditor>> HasEditor for T {}
|
||||||
|
impl <T: NotePoint+TimePoint> MidiPoint for T {}
|
||||||
|
impl <T: TimeRange+NoteRange> MidiRange for T {}
|
||||||
def_command!(MidiEditCommand: |editor: MidiEditor| {
|
def_command!(MidiEditCommand: |editor: MidiEditor| {
|
||||||
Show { clip: Option<Arc<RwLock<MidiClip>>> } => {
|
Show { clip: Option<Arc<RwLock<MidiClip>>> } => {
|
||||||
editor.set_clip(clip.as_ref()); editor.redraw(); Ok(None) },
|
editor.set_clip(clip.as_ref()); editor.redraw(); Ok(None) },
|
||||||
|
|
@ -461,32 +465,32 @@ pub trait MidiPoint: NotePoint + TimePoint {
|
||||||
pub trait TimeRange {
|
pub trait TimeRange {
|
||||||
fn time_len (&self) -> &AtomicUsize;
|
fn time_len (&self) -> &AtomicUsize;
|
||||||
fn get_time_len (&self) -> usize {
|
fn get_time_len (&self) -> usize {
|
||||||
self.time_len().load(Ordering::Relaxed)
|
self.time_len().load(Relaxed)
|
||||||
}
|
}
|
||||||
fn time_zoom (&self) -> &AtomicUsize;
|
fn time_zoom (&self) -> &AtomicUsize;
|
||||||
fn get_time_zoom (&self) -> usize {
|
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 {
|
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 time_lock (&self) -> &AtomicBool;
|
||||||
fn get_time_lock (&self) -> bool {
|
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 {
|
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 time_start (&self) -> &AtomicUsize;
|
||||||
fn get_time_start (&self) -> usize {
|
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 {
|
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 time_axis (&self) -> &AtomicUsize;
|
||||||
fn get_time_axis (&self) -> usize {
|
fn get_time_axis (&self) -> usize {
|
||||||
self.time_axis().load(Ordering::Relaxed)
|
self.time_axis().load(Relaxed)
|
||||||
}
|
}
|
||||||
fn get_time_end (&self) -> usize {
|
fn get_time_end (&self) -> usize {
|
||||||
self.time_start().get() + self.time_axis().get() * self.time_zoom().get()
|
self.time_start().get() + self.time_axis().get() * self.time_zoom().get()
|
||||||
|
|
@ -496,14 +500,14 @@ pub trait TimeRange {
|
||||||
pub trait NoteRange {
|
pub trait NoteRange {
|
||||||
fn note_lo (&self) -> &AtomicUsize;
|
fn note_lo (&self) -> &AtomicUsize;
|
||||||
fn get_note_lo (&self) -> usize {
|
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 {
|
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 note_axis (&self) -> &AtomicUsize;
|
||||||
fn get_note_axis (&self) -> usize {
|
fn get_note_axis (&self) -> usize {
|
||||||
self.note_axis().load(Ordering::Relaxed)
|
self.note_axis().load(Relaxed)
|
||||||
}
|
}
|
||||||
fn get_note_hi (&self) -> usize {
|
fn get_note_hi (&self) -> usize {
|
||||||
(self.note_lo().get() + self.note_axis().get().saturating_sub(1)).min(127)
|
(self.note_lo().get() + self.note_axis().get().saturating_sub(1)).min(127)
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,10 @@ pub mod view;
|
||||||
|
|
||||||
use clap::{self, Parser, Subcommand};
|
use clap::{self, Parser, Subcommand};
|
||||||
use builder_pattern::Builder;
|
use builder_pattern::Builder;
|
||||||
|
use self::{
|
||||||
|
arrange::*, clock::*, dialog::*, browse::*, select::*, sequence::*, device::*,
|
||||||
|
config::*, mode::*, view::*, bind::*
|
||||||
|
};
|
||||||
|
|
||||||
extern crate xdg;
|
extern crate xdg;
|
||||||
pub(crate) use ::xdg::BaseDirectories;
|
pub(crate) use ::xdg::BaseDirectories;
|
||||||
|
|
@ -961,11 +965,6 @@ impl Draw<Tui> for App {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl <T: AsRef<Clock>+AsMut<Clock>> HasClock for T {}
|
|
||||||
impl <T: AsRef<Sequencer>+AsMut<Sequencer>> HasSequencer for T {}
|
|
||||||
impl <T: AsRefOpt<MidiEditor>+AsMutOpt<MidiEditor>> HasEditor for T {}
|
|
||||||
impl <T: NotePoint+TimePoint> MidiPoint for T {}
|
|
||||||
impl <T: TimeRange+NoteRange> MidiRange for T {}
|
|
||||||
impl HasClipsSize for App { fn clips_size (&self) -> &Measure<Tui> { &self.project.size_inner } }
|
impl HasClipsSize for App { fn clips_size (&self) -> &Measure<Tui> { &self.project.size_inner } }
|
||||||
impl HasJack<'static> for App { fn jack (&self) -> &Jack<'static> { &self.jack } }
|
impl HasJack<'static> for App { fn jack (&self) -> &Jack<'static> { &self.jack } }
|
||||||
impl_default!(AppCommand: Self::Nop);
|
impl_default!(AppCommand: Self::Nop);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue