mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
fix some more lints
This commit is contained in:
parent
a64925ba8c
commit
fa9f7f8aaf
15 changed files with 224 additions and 236 deletions
|
|
@ -125,10 +125,10 @@ from_edn!("plugin/lv2" => |jack: &Arc<RwLock<JackClient>>, args| -> Plugin {
|
|||
Plugin::new_lv2(jack, &name, &path)
|
||||
});
|
||||
|
||||
const SYM_NAME: &'static str = ":name";
|
||||
const SYM_GAIN: &'static str = ":gain";
|
||||
const SYM_SAMPLER: &'static str = "sampler";
|
||||
const SYM_LV2: &'static str = "lv2";
|
||||
const SYM_NAME: &str = ":name";
|
||||
const SYM_GAIN: &str = ":gain";
|
||||
const SYM_SAMPLER: &str = "sampler";
|
||||
const SYM_LV2: &str = "lv2";
|
||||
|
||||
from_edn!("mixer/track" => |jack: &Arc<RwLock<JackClient>>, args| -> MixerTrack {
|
||||
let mut _gain = 0.0f64;
|
||||
|
|
@ -147,7 +147,7 @@ from_edn!("mixer/track" => |jack: &Arc<RwLock<JackClient>>, args| -> MixerTrack
|
|||
_gain = f64::from(*g);
|
||||
}
|
||||
},
|
||||
Edn::List(args) => match args.get(0) {
|
||||
Edn::List(args) => match args.first() {
|
||||
// Add a sampler device to the track
|
||||
Some(Edn::Symbol(SYM_SAMPLER)) => {
|
||||
track.devices.push(
|
||||
|
|
@ -156,7 +156,7 @@ from_edn!("mixer/track" => |jack: &Arc<RwLock<JackClient>>, args| -> MixerTrack
|
|||
panic!(
|
||||
"unsupported in track {}: {:?}; tek_mixer not compiled with feature \"sampler\"",
|
||||
&track.name,
|
||||
args.get(0).unwrap()
|
||||
args.first().unwrap()
|
||||
)
|
||||
},
|
||||
// Add a LV2 plugin to the track.
|
||||
|
|
@ -167,13 +167,13 @@ from_edn!("mixer/track" => |jack: &Arc<RwLock<JackClient>>, args| -> MixerTrack
|
|||
panic!(
|
||||
"unsupported in track {}: {:?}; tek_mixer not compiled with feature \"plugin\"",
|
||||
&track.name,
|
||||
args.get(0).unwrap()
|
||||
args.first().unwrap()
|
||||
)
|
||||
},
|
||||
None =>
|
||||
panic!("empty list track {}", &track.name),
|
||||
_ =>
|
||||
panic!("unexpected in track {}: {:?}", &track.name, args.get(0).unwrap())
|
||||
panic!("unexpected in track {}: {:?}", &track.name, args.first().unwrap())
|
||||
},
|
||||
_ => {}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ pub fn delegate <B, C: Command<S>, S> (
|
|||
wrap: impl Fn(C)->B,
|
||||
state: &mut S,
|
||||
) -> Perhaps<B> {
|
||||
Ok(cmd.execute(state)?.map(|x|wrap(x)))
|
||||
Ok(cmd.execute(state)?.map(wrap))
|
||||
}
|
||||
|
||||
pub trait InputToCommand<E: Engine, S>: Command<S> + Sized {
|
||||
|
|
|
|||
|
|
@ -19,18 +19,10 @@ impl<T: Copy + Debug + PartialEq> FocusState<T> {
|
|||
Self::Entered(_) => Self::Entered(inner),
|
||||
}
|
||||
}
|
||||
pub fn is_focused (&self) -> bool {
|
||||
if let Self::Focused(_) = self { true } else { false }
|
||||
}
|
||||
pub fn is_entered (&self) -> bool {
|
||||
if let Self::Entered(_) = self { true } else { false }
|
||||
}
|
||||
pub fn to_focused (&mut self) {
|
||||
*self = Self::Focused(self.inner())
|
||||
}
|
||||
pub fn to_entered (&mut self) {
|
||||
*self = Self::Entered(self.inner())
|
||||
}
|
||||
pub fn is_focused (&self) -> bool { matches!(self, Self::Focused(_)) }
|
||||
pub fn is_entered (&self) -> bool { matches!(self, Self::Entered(_)) }
|
||||
pub fn focus (&mut self) { *self = Self::Focused(self.inner()) }
|
||||
pub fn enter (&mut self) { *self = Self::Entered(self.inner()) }
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Debug)]
|
||||
|
|
@ -252,8 +244,7 @@ impl<T: FocusGrid + HasEnter> FocusOrder for T {
|
|||
}
|
||||
|
||||
pub trait FocusWrap<T> {
|
||||
fn wrap <'a, W: Render<Tui>> (self, focus: T, content: &'a W)
|
||||
-> impl Render<Tui> + 'a;
|
||||
fn wrap <W: Render<Tui>> (self, focus: T, content: &'_ W) -> impl Render<Tui> + '_;
|
||||
}
|
||||
|
||||
pub fn to_focus_command <T: Send + Sync> (input: &TuiInput) -> Option<FocusCommand<T>> {
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ impl<E: Engine, H: Handle<E>> Handle<E> for Option<H> {
|
|||
|
||||
impl<H, E: Engine> Handle<E> for Mutex<H> where H: Handle<E> {
|
||||
fn handle (&mut self, context: &E::Input) -> Perhaps<E::Handled> {
|
||||
self.lock().unwrap().handle(context)
|
||||
self.get_mut().unwrap().handle(context)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ impl<E: Engine> Render<E> for &dyn Render<E> {
|
|||
//}
|
||||
//}
|
||||
|
||||
impl<'a, E: Engine> Render<E> for Box<dyn Render<E> + 'a> {
|
||||
impl<E: Engine> Render<E> for Box<dyn Render<E> + '_> {
|
||||
fn min_size (&self, to: E::Size) -> Perhaps<E::Size> {
|
||||
(**self).min_size(to)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,24 +57,6 @@ impl Plugin {
|
|||
audio_outs: vec![],
|
||||
})
|
||||
}
|
||||
|
||||
//fn jack_from_lv2 (name: &str, plugin: &::livi::Plugin) -> Usually<Jack> {
|
||||
//let counts = plugin.port_counts();
|
||||
//let mut jack = Jack::new(name)?;
|
||||
//for i in 0..counts.atom_sequence_inputs {
|
||||
//jack = jack.midi_in(&format!("midi-in-{i}"))
|
||||
//}
|
||||
//for i in 0..counts.atom_sequence_outputs {
|
||||
//jack = jack.midi_out(&format!("midi-out-{i}"));
|
||||
//}
|
||||
//for i in 0..counts.audio_inputs {
|
||||
//jack = jack.audio_in(&format!("audio-in-{i}"));
|
||||
//}
|
||||
//for i in 0..counts.audio_outputs {
|
||||
//jack = jack.audio_out(&format!("audio-out-{i}"));
|
||||
//}
|
||||
//Ok(jack)
|
||||
//}
|
||||
}
|
||||
|
||||
pub struct PluginAudio(Arc<RwLock<Plugin>>);
|
||||
|
|
@ -110,7 +92,7 @@ audio!(|self: PluginAudio, client, scope|{
|
|||
let mut outputs = vec![];
|
||||
for _ in state.midi_outs.iter() {
|
||||
outputs.push(::livi::event::LV2AtomSequence::new(
|
||||
&features,
|
||||
features,
|
||||
scope.n_frames() as usize
|
||||
));
|
||||
}
|
||||
|
|
@ -123,7 +105,25 @@ audio!(|self: PluginAudio, client, scope|{
|
|||
instance.run(scope.n_frames() as usize, ports).unwrap()
|
||||
};
|
||||
},
|
||||
_ => {}
|
||||
_ => todo!("only lv2 is supported")
|
||||
}
|
||||
Control::Continue
|
||||
});
|
||||
|
||||
//fn jack_from_lv2 (name: &str, plugin: &::livi::Plugin) -> Usually<Jack> {
|
||||
//let counts = plugin.port_counts();
|
||||
//let mut jack = Jack::new(name)?;
|
||||
//for i in 0..counts.atom_sequence_inputs {
|
||||
//jack = jack.midi_in(&format!("midi-in-{i}"))
|
||||
//}
|
||||
//for i in 0..counts.atom_sequence_outputs {
|
||||
//jack = jack.midi_out(&format!("midi-out-{i}"));
|
||||
//}
|
||||
//for i in 0..counts.audio_inputs {
|
||||
//jack = jack.audio_in(&format!("audio-in-{i}"));
|
||||
//}
|
||||
//for i in 0..counts.audio_outputs {
|
||||
//jack = jack.audio_out(&format!("audio-out-{i}"));
|
||||
//}
|
||||
//Ok(jack)
|
||||
//}
|
||||
|
|
|
|||
|
|
@ -21,10 +21,8 @@ impl LV2Plugin {
|
|||
min_block_length: 1,
|
||||
max_block_length: 65536,
|
||||
});
|
||||
let plugin = world
|
||||
.iter_plugins()
|
||||
.nth(0)
|
||||
.expect(&format!("plugin not found: {uri}"));
|
||||
let plugin = world.iter_plugins().nth(0)
|
||||
.unwrap_or_else(||panic!("plugin not found: {uri}"));
|
||||
Ok(Self {
|
||||
instance: unsafe {
|
||||
plugin
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
pub(crate) mod coord; pub(crate) use coord::*;
|
||||
pub(crate) mod size; pub(crate) use size::*;
|
||||
pub(crate) mod area; pub(crate) use area::*;
|
||||
pub(crate) mod direction; pub(crate) use direction::*;
|
||||
use crate::*;
|
||||
use std::ops::{Add, Sub, Mul, Div};
|
||||
use std::fmt::{Display, Debug};
|
||||
|
||||
// TODO: return impl Point and impl Size instead of [N;x]
|
||||
// to disambiguate between usage of 2-"tuple"s
|
||||
|
|
@ -28,3 +27,165 @@ pub use self::{
|
|||
bsp::*,
|
||||
fill::*,
|
||||
};
|
||||
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
pub enum Direction { North, South, West, East, }
|
||||
|
||||
impl Direction {
|
||||
pub fn is_north (&self) -> bool { matches!(self, Self::North) }
|
||||
pub fn is_south (&self) -> bool { matches!(self, Self::South) }
|
||||
pub fn is_east (&self) -> bool { matches!(self, Self::West) }
|
||||
pub fn is_west (&self) -> bool { matches!(self, Self::East) }
|
||||
/// Return next direction clockwise
|
||||
pub fn cw (&self) -> Self {
|
||||
match self {
|
||||
Self::North => Self::East,
|
||||
Self::South => Self::West,
|
||||
Self::West => Self::North,
|
||||
Self::East => Self::South,
|
||||
}
|
||||
}
|
||||
/// Return next direction counterclockwise
|
||||
pub fn ccw (&self) -> Self {
|
||||
match self {
|
||||
Self::North => Self::West,
|
||||
Self::South => Self::East,
|
||||
Self::West => Self::South,
|
||||
Self::East => Self::North,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Standard numeric type.
|
||||
pub trait Coordinate: Send + Sync + Copy
|
||||
+ Add<Self, Output=Self>
|
||||
+ Sub<Self, Output=Self>
|
||||
+ Mul<Self, Output=Self>
|
||||
+ Div<Self, Output=Self>
|
||||
+ Ord + PartialEq + Eq
|
||||
+ Debug + Display + Default
|
||||
+ From<u16> + Into<u16>
|
||||
+ Into<usize>
|
||||
+ Into<f64>
|
||||
{
|
||||
fn minus (self, other: Self) -> Self {
|
||||
if self >= other {
|
||||
self - other
|
||||
} else {
|
||||
0.into()
|
||||
}
|
||||
}
|
||||
fn zero () -> Self {
|
||||
0.into()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Coordinate for T where T: Send + Sync + Copy
|
||||
+ Add<Self, Output=Self>
|
||||
+ Sub<Self, Output=Self>
|
||||
+ Mul<Self, Output=Self>
|
||||
+ Div<Self, Output=Self>
|
||||
+ Ord + PartialEq + Eq
|
||||
+ Debug + Display + Default
|
||||
+ From<u16> + Into<u16>
|
||||
+ Into<usize>
|
||||
+ Into<f64>
|
||||
{}
|
||||
|
||||
pub trait Size<N: Coordinate> {
|
||||
fn x (&self) -> N;
|
||||
fn y (&self) -> N;
|
||||
#[inline] fn w (&self) -> N { self.x() }
|
||||
#[inline] fn h (&self) -> N { self.y() }
|
||||
#[inline] fn wh (&self) -> [N;2] { [self.x(), self.y()] }
|
||||
#[inline] fn clip_w (&self, w: N) -> [N;2] { [self.w().min(w), self.h()] }
|
||||
#[inline] fn clip_h (&self, h: N) -> [N;2] { [self.w(), self.h().min(h)] }
|
||||
#[inline] fn expect_min (&self, w: N, h: N) -> Usually<&Self> {
|
||||
if self.w() < w || self.h() < h {
|
||||
Err(format!("min {w}x{h}").into())
|
||||
} else {
|
||||
Ok(self)
|
||||
}
|
||||
}
|
||||
}
|
||||
impl<N: Coordinate> Size<N> for (N, N) {
|
||||
fn x (&self) -> N { self.0 }
|
||||
fn y (&self) -> N { self.1 }
|
||||
}
|
||||
|
||||
impl<N: Coordinate> Size<N> for [N;2] {
|
||||
fn x (&self) -> N { self[0] }
|
||||
fn y (&self) -> N { self[1] }
|
||||
}
|
||||
|
||||
pub trait Area<N: Coordinate>: Copy {
|
||||
fn x (&self) -> N;
|
||||
fn y (&self) -> N;
|
||||
fn w (&self) -> N;
|
||||
fn h (&self) -> N;
|
||||
fn x2 (&self) -> N { self.x() + self.w() }
|
||||
fn y2 (&self) -> N { self.y() + self.h() }
|
||||
#[inline] fn wh (&self) -> [N;2] { [self.w(), self.h()] }
|
||||
#[inline] fn xywh (&self) -> [N;4] { [self.x(), self.y(), self.w(), self.h()] }
|
||||
#[inline] fn lrtb (&self) -> [N;4] { [self.x(), self.x2(), self.y(), self.y2()] }
|
||||
#[inline] fn push_x (&self, x: N) -> [N;4] { [self.x() + x, self.y(), self.w(), self.h()] }
|
||||
#[inline] fn push_y (&self, y: N) -> [N;4] { [self.x(), self.y() + y, self.w(), self.h()] }
|
||||
#[inline] fn shrink_x (&self, x: N) -> [N;4] {
|
||||
[self.x(), self.y(), self.w().minus(x), self.h()]
|
||||
}
|
||||
#[inline] fn shrink_y (&self, y: N) -> [N;4] {
|
||||
[self.x(), self.y(), self.w(), self.h().minus(y)]
|
||||
}
|
||||
#[inline] fn set_w (&self, w: N) -> [N;4] { [self.x(), self.y(), w, self.h()] }
|
||||
#[inline] fn set_h (&self, h: N) -> [N;4] { [self.x(), self.y(), self.w(), h] }
|
||||
#[inline] fn clip_h (&self, h: N) -> [N;4] {
|
||||
[self.x(), self.y(), self.w(), self.h().min(h)]
|
||||
}
|
||||
#[inline] fn clip_w (&self, w: N) -> [N;4] {
|
||||
[self.x(), self.y(), self.w().min(w), self.h()]
|
||||
}
|
||||
#[inline] fn clip (&self, wh: impl Size<N>) -> [N;4] {
|
||||
[self.x(), self.y(), wh.w(), wh.h()]
|
||||
}
|
||||
#[inline] fn expect_min (&self, w: N, h: N) -> Usually<&Self> {
|
||||
if self.w() < w || self.h() < h {
|
||||
Err(format!("min {w}x{h}").into())
|
||||
} else {
|
||||
Ok(self)
|
||||
}
|
||||
}
|
||||
#[inline] fn split_fixed (&self, direction: Direction, a: N) -> ([N;4],[N;4]) {
|
||||
match direction {
|
||||
Direction::North => (
|
||||
[self.x(), (self.y()+self.h()).minus(a), self.w(), a],
|
||||
[self.x(), self.y(), self.w(), self.h().minus(a)],
|
||||
),
|
||||
Direction::South => (
|
||||
[self.x(), self.y(), self.w(), a],
|
||||
[self.x(), self.y() + a, self.w(), self.h().minus(a)],
|
||||
),
|
||||
Direction::East => (
|
||||
[self.x(), self.y(), a, self.h()],
|
||||
[self.x() + a, self.y(), self.w().minus(a), self.h()],
|
||||
),
|
||||
Direction::West => (
|
||||
[self.x() + self.w() - a, self.y(), a, self.h()],
|
||||
[self.x(), self.y(), self.w() - a, self.h()],
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<N: Coordinate> Area<N> for (N, N, N, N) {
|
||||
#[inline] fn x (&self) -> N { self.0 }
|
||||
#[inline] fn y (&self) -> N { self.1 }
|
||||
#[inline] fn w (&self) -> N { self.2 }
|
||||
#[inline] fn h (&self) -> N { self.3 }
|
||||
}
|
||||
|
||||
impl<N: Coordinate> Area<N> for [N;4] {
|
||||
#[inline] fn x (&self) -> N { self[0] }
|
||||
#[inline] fn y (&self) -> N { self[1] }
|
||||
#[inline] fn w (&self) -> N { self[2] }
|
||||
#[inline] fn h (&self) -> N { self[3] }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,73 +0,0 @@
|
|||
use crate::*;
|
||||
|
||||
pub trait Area<N: Coordinate>: Copy {
|
||||
fn x (&self) -> N;
|
||||
fn y (&self) -> N;
|
||||
fn w (&self) -> N;
|
||||
fn h (&self) -> N;
|
||||
fn x2 (&self) -> N { self.x() + self.w() }
|
||||
fn y2 (&self) -> N { self.y() + self.h() }
|
||||
#[inline] fn wh (&self) -> [N;2] { [self.w(), self.h()] }
|
||||
#[inline] fn xywh (&self) -> [N;4] { [self.x(), self.y(), self.w(), self.h()] }
|
||||
#[inline] fn lrtb (&self) -> [N;4] { [self.x(), self.x2(), self.y(), self.y2()] }
|
||||
#[inline] fn push_x (&self, x: N) -> [N;4] { [self.x() + x, self.y(), self.w(), self.h()] }
|
||||
#[inline] fn push_y (&self, y: N) -> [N;4] { [self.x(), self.y() + y, self.w(), self.h()] }
|
||||
#[inline] fn shrink_x (&self, x: N) -> [N;4] {
|
||||
[self.x(), self.y(), self.w().minus(x), self.h()]
|
||||
}
|
||||
#[inline] fn shrink_y (&self, y: N) -> [N;4] {
|
||||
[self.x(), self.y(), self.w(), self.h().minus(y)]
|
||||
}
|
||||
#[inline] fn set_w (&self, w: N) -> [N;4] { [self.x(), self.y(), w, self.h()] }
|
||||
#[inline] fn set_h (&self, h: N) -> [N;4] { [self.x(), self.y(), self.w(), h] }
|
||||
#[inline] fn clip_h (&self, h: N) -> [N;4] {
|
||||
[self.x(), self.y(), self.w(), self.h().min(h.into())]
|
||||
}
|
||||
#[inline] fn clip_w (&self, w: N) -> [N;4] {
|
||||
[self.x(), self.y(), self.w().min(w.into()), self.h()]
|
||||
}
|
||||
#[inline] fn clip (&self, wh: impl Size<N>) -> [N;4] {
|
||||
[self.x(), self.y(), wh.w(), wh.h()]
|
||||
}
|
||||
#[inline] fn expect_min (&self, w: N, h: N) -> Usually<&Self> {
|
||||
if self.w() < w || self.h() < h {
|
||||
Err(format!("min {w}x{h}").into())
|
||||
} else {
|
||||
Ok(self)
|
||||
}
|
||||
}
|
||||
#[inline] fn split_fixed (&self, direction: Direction, a: N) -> ([N;4],[N;4]) {
|
||||
match direction {
|
||||
Direction::Up => (
|
||||
[self.x(), (self.y()+self.h()).minus(a), self.w(), a],
|
||||
[self.x(), self.y(), self.w(), self.h().minus(a)],
|
||||
),
|
||||
Direction::Down => (
|
||||
[self.x(), self.y(), self.w(), a],
|
||||
[self.x(), self.y() + a, self.w(), self.h().minus(a)],
|
||||
),
|
||||
Direction::Right => (
|
||||
[self.x(), self.y(), a, self.h()],
|
||||
[self.x() + a, self.y(), self.w().minus(a), self.h()],
|
||||
),
|
||||
Direction::Left => (
|
||||
[self.x() + self.w() - a, self.y(), a, self.h()],
|
||||
[self.x(), self.y(), self.w() - a, self.h()],
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<N: Coordinate> Area<N> for (N, N, N, N) {
|
||||
#[inline] fn x (&self) -> N { self.0 }
|
||||
#[inline] fn y (&self) -> N { self.1 }
|
||||
#[inline] fn w (&self) -> N { self.2 }
|
||||
#[inline] fn h (&self) -> N { self.3 }
|
||||
}
|
||||
|
||||
impl<N: Coordinate> Area<N> for [N;4] {
|
||||
#[inline] fn x (&self) -> N { self[0] }
|
||||
#[inline] fn y (&self) -> N { self[1] }
|
||||
#[inline] fn w (&self) -> N { self[2] }
|
||||
#[inline] fn h (&self) -> N { self[3] }
|
||||
}
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
use crate::*;
|
||||
|
||||
/// Standard numeric type.
|
||||
pub trait Coordinate: Send + Sync + Copy
|
||||
+ Add<Self, Output=Self>
|
||||
+ Sub<Self, Output=Self>
|
||||
+ Mul<Self, Output=Self>
|
||||
+ Div<Self, Output=Self>
|
||||
+ Ord + PartialEq + Eq
|
||||
+ Debug + Display + Default
|
||||
+ From<u16> + Into<u16>
|
||||
+ Into<usize>
|
||||
+ Into<f64>
|
||||
{
|
||||
fn minus (self, other: Self) -> Self {
|
||||
if self >= other {
|
||||
self - other
|
||||
} else {
|
||||
0.into()
|
||||
}
|
||||
}
|
||||
fn zero () -> Self {
|
||||
0.into()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Coordinate for T where T: Send + Sync + Copy
|
||||
+ Add<Self, Output=Self>
|
||||
+ Sub<Self, Output=Self>
|
||||
+ Mul<Self, Output=Self>
|
||||
+ Div<Self, Output=Self>
|
||||
+ Ord + PartialEq + Eq
|
||||
+ Debug + Display + Default
|
||||
+ From<u16> + Into<u16>
|
||||
+ Into<usize>
|
||||
+ Into<f64>
|
||||
{}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
use crate::*;
|
||||
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
pub enum Direction { Up, Down, Left, Right, }
|
||||
impl Direction {
|
||||
pub fn is_up (&self) -> bool { match self { Self::Up => true, _ => false } }
|
||||
pub fn is_down (&self) -> bool { match self { Self::Down => true, _ => false } }
|
||||
pub fn is_left (&self) -> bool { match self { Self::Left => true, _ => false } }
|
||||
pub fn is_right (&self) -> bool { match self { Self::Right => true, _ => false } }
|
||||
/// Return next direction clockwise
|
||||
pub fn cw (&self) -> Self {
|
||||
match self {
|
||||
Self::Up => Self::Right,
|
||||
Self::Down => Self::Left,
|
||||
Self::Left => Self::Up,
|
||||
Self::Right => Self::Down,
|
||||
}
|
||||
}
|
||||
/// Return next direction counterclockwise
|
||||
pub fn ccw (&self) -> Self {
|
||||
match self {
|
||||
Self::Up => Self::Left,
|
||||
Self::Down => Self::Right,
|
||||
Self::Left => Self::Down,
|
||||
Self::Right => Self::Up,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
use crate::*;
|
||||
|
||||
pub trait Size<N: Coordinate> {
|
||||
fn x (&self) -> N;
|
||||
fn y (&self) -> N;
|
||||
#[inline] fn w (&self) -> N { self.x() }
|
||||
#[inline] fn h (&self) -> N { self.y() }
|
||||
#[inline] fn wh (&self) -> [N;2] { [self.x(), self.y()] }
|
||||
#[inline] fn clip_w (&self, w: N) -> [N;2] { [self.w().min(w.into()), self.h()] }
|
||||
#[inline] fn clip_h (&self, h: N) -> [N;2] { [self.w(), self.h().min(h.into())] }
|
||||
#[inline] fn expect_min (&self, w: N, h: N) -> Usually<&Self> {
|
||||
if self.w() < w || self.h() < h {
|
||||
Err(format!("min {w}x{h}").into())
|
||||
} else {
|
||||
Ok(self)
|
||||
}
|
||||
}
|
||||
}
|
||||
impl<N: Coordinate> Size<N> for (N, N) {
|
||||
fn x (&self) -> N { self.0 }
|
||||
fn y (&self) -> N { self.1 }
|
||||
}
|
||||
impl<N: Coordinate> Size<N> for [N;2] {
|
||||
fn x (&self) -> N { self[0] }
|
||||
fn y (&self) -> N { self[1] }
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
use crate::*;
|
||||
use Direction::*;
|
||||
|
||||
impl<E: Engine> LayoutSplit<E> for E {}
|
||||
|
||||
|
|
@ -11,22 +12,22 @@ pub trait LayoutSplit<E: Engine> {
|
|||
fn split_n <A: Render<E>, B: Render<E>> (
|
||||
flip: bool, amount: E::Unit, a: A, b: B
|
||||
) -> Split<E, A, B> {
|
||||
Self::split(flip, Direction::Up, amount, a, b)
|
||||
Self::split(flip, North, amount, a, b)
|
||||
}
|
||||
fn split_s <A: Render<E>, B: Render<E>> (
|
||||
flip: bool, amount: E::Unit, a: A, b: B
|
||||
) -> Split<E, A, B> {
|
||||
Self::split(flip, Direction::Down, amount, a, b)
|
||||
Self::split(flip, South, amount, a, b)
|
||||
}
|
||||
fn split_w <A: Render<E>, B: Render<E>> (
|
||||
flip: bool, amount: E::Unit, a: A, b: B
|
||||
) -> Split<E, A, B> {
|
||||
Self::split(flip, Direction::Left, amount, a, b)
|
||||
Self::split(flip, West, amount, a, b)
|
||||
}
|
||||
fn split_e <A: Render<E>, B: Render<E>> (
|
||||
flip: bool, amount: E::Unit, a: A, b: B
|
||||
) -> Split<E, A, B> {
|
||||
Self::split(flip, Direction::Right, amount, a, b)
|
||||
Self::split(flip, East, amount, a, b)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -40,16 +41,16 @@ impl<E: Engine, A: Render<E>, B: Render<E>> Split<E, A, B> {
|
|||
Self(flip, direction, proportion, a, b, Default::default())
|
||||
}
|
||||
pub fn up (flip: bool, proportion: E::Unit, a: A, b: B) -> Self {
|
||||
Self(flip, Direction::Up, proportion, a, b, Default::default())
|
||||
Self(flip, North, proportion, a, b, Default::default())
|
||||
}
|
||||
pub fn down (flip: bool, proportion: E::Unit, a: A, b: B) -> Self {
|
||||
Self(flip, Direction::Down, proportion, a, b, Default::default())
|
||||
Self(flip, South, proportion, a, b, Default::default())
|
||||
}
|
||||
pub fn left (flip: bool, proportion: E::Unit, a: A, b: B) -> Self {
|
||||
Self(flip, Direction::Left, proportion, a, b, Default::default())
|
||||
Self(flip, West, proportion, a, b, Default::default())
|
||||
}
|
||||
pub fn right (flip: bool, proportion: E::Unit, a: A, b: B) -> Self {
|
||||
Self(flip, Direction::Right, proportion, a, b, Default::default())
|
||||
Self(flip, East, proportion, a, b, Default::default())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
use crate::*;
|
||||
use Direction::*;
|
||||
|
||||
#[macro_export] macro_rules! col {
|
||||
([$($expr:expr),* $(,)?]) => {
|
||||
|
|
@ -58,13 +59,13 @@ impl<
|
|||
Self(build, direction, Default::default())
|
||||
}
|
||||
#[inline] pub fn right (build: F) -> Self {
|
||||
Self::new(Direction::Right, build)
|
||||
Self::new(East, build)
|
||||
}
|
||||
#[inline] pub fn down (build: F) -> Self {
|
||||
Self::new(Direction::Down, build)
|
||||
Self::new(South, build)
|
||||
}
|
||||
#[inline] pub fn up (build: F) -> Self {
|
||||
Self::new(Direction::Up, build)
|
||||
Self::new(North, build)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -75,7 +76,7 @@ where
|
|||
fn min_size (&self, to: E::Size) -> Perhaps<E::Size> {
|
||||
match self.1 {
|
||||
|
||||
Direction::Down => {
|
||||
South => {
|
||||
let mut w: E::Unit = 0.into();
|
||||
let mut h: E::Unit = 0.into();
|
||||
(self.0)(&mut |component: &dyn Render<E>| {
|
||||
|
|
@ -93,7 +94,7 @@ where
|
|||
Ok(Some([w, h].into()))
|
||||
},
|
||||
|
||||
Direction::Right => {
|
||||
East => {
|
||||
let mut w: E::Unit = 0.into();
|
||||
let mut h: E::Unit = 0.into();
|
||||
(self.0)(&mut |component: &dyn Render<E>| {
|
||||
|
|
@ -111,7 +112,7 @@ where
|
|||
Ok(Some([w, h].into()))
|
||||
},
|
||||
|
||||
Direction::Up => {
|
||||
North => {
|
||||
let mut w: E::Unit = 0.into();
|
||||
let mut h: E::Unit = 0.into();
|
||||
(self.0)(&mut |component: &dyn Render<E>| {
|
||||
|
|
@ -129,7 +130,7 @@ where
|
|||
Ok(Some([w, h].into()))
|
||||
},
|
||||
|
||||
Direction::Left => {
|
||||
West => {
|
||||
let w: E::Unit = 0.into();
|
||||
let h: E::Unit = 0.into();
|
||||
(self.0)(&mut |component: &dyn Render<E>| {
|
||||
|
|
@ -148,7 +149,7 @@ where
|
|||
let mut w = 0.into();
|
||||
let mut h = 0.into();
|
||||
match self.1 {
|
||||
Direction::Down => {
|
||||
South => {
|
||||
(self.0)(&mut |item| {
|
||||
if h < area.h() {
|
||||
let item = E::max_y(area.h() - h, E::push_y(h, item));
|
||||
|
|
@ -162,7 +163,7 @@ where
|
|||
Ok(())
|
||||
})?;
|
||||
},
|
||||
Direction::Right => {
|
||||
East => {
|
||||
(self.0)(&mut |item| {
|
||||
if w < area.w() {
|
||||
let item = E::max_x(area.w() - w, E::push_x(w, item));
|
||||
|
|
@ -176,7 +177,7 @@ where
|
|||
Ok(())
|
||||
})?;
|
||||
},
|
||||
Direction::Up => {
|
||||
North => {
|
||||
(self.0)(&mut |item| {
|
||||
if h < area.h() {
|
||||
let show = item.min_size([area.w(), area.h().minus(h)].into())?.map(|s|s.wh());
|
||||
|
|
|
|||
|
|
@ -185,7 +185,7 @@ impl ClockModel {
|
|||
/// Hosts the JACK callback for updating the temporal pointer and playback status.
|
||||
pub struct ClockAudio<'a, T: HasClock>(pub &'a mut T);
|
||||
|
||||
impl<'a, T: HasClock> Audio for ClockAudio<'a, T> {
|
||||
impl<T: HasClock> Audio for ClockAudio<'_, T> {
|
||||
#[inline] fn process (&mut self, _: &Client, scope: &ProcessScope) -> Control {
|
||||
self.0.clock().update_from_scope(scope).unwrap();
|
||||
Control::Continue
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue