From fa9f7f8aafe70530a6baf7867e7094cca0af22a4 Mon Sep 17 00:00:00 2001 From: unspeaker Date: Fri, 27 Dec 2024 16:12:58 +0100 Subject: [PATCH] fix some more lints --- crates/edn/src/lib.rs | 16 +-- crates/tek/src/core/command.rs | 2 +- crates/tek/src/core/focus.rs | 19 +--- crates/tek/src/core/input.rs | 2 +- crates/tek/src/core/output.rs | 2 +- crates/tek/src/plugin.rs | 40 +++---- crates/tek/src/plugin/lv2.rs | 6 +- crates/tek/src/space.rs | 169 +++++++++++++++++++++++++++++- crates/tek/src/space/area.rs | 73 ------------- crates/tek/src/space/coord.rs | 37 ------- crates/tek/src/space/direction.rs | 28 ----- crates/tek/src/space/size.rs | 26 ----- crates/tek/src/space/split.rs | 17 +-- crates/tek/src/space/stack.rs | 21 ++-- crates/tek/src/time/clock.rs | 2 +- 15 files changed, 224 insertions(+), 236 deletions(-) delete mode 100644 crates/tek/src/space/area.rs delete mode 100644 crates/tek/src/space/coord.rs delete mode 100644 crates/tek/src/space/direction.rs delete mode 100644 crates/tek/src/space/size.rs diff --git a/crates/edn/src/lib.rs b/crates/edn/src/lib.rs index 356c362a..a6b51214 100644 --- a/crates/edn/src/lib.rs +++ b/crates/edn/src/lib.rs @@ -125,10 +125,10 @@ from_edn!("plugin/lv2" => |jack: &Arc>, 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>, args| -> MixerTrack { let mut _gain = 0.0f64; @@ -147,7 +147,7 @@ from_edn!("mixer/track" => |jack: &Arc>, 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>, 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>, 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()) }, _ => {} }); diff --git a/crates/tek/src/core/command.rs b/crates/tek/src/core/command.rs index 1f59e548..8740193b 100644 --- a/crates/tek/src/core/command.rs +++ b/crates/tek/src/core/command.rs @@ -38,7 +38,7 @@ pub fn delegate , S> ( wrap: impl Fn(C)->B, state: &mut S, ) -> Perhaps { - Ok(cmd.execute(state)?.map(|x|wrap(x))) + Ok(cmd.execute(state)?.map(wrap)) } pub trait InputToCommand: Command + Sized { diff --git a/crates/tek/src/core/focus.rs b/crates/tek/src/core/focus.rs index 0bae0cb6..00db730a 100644 --- a/crates/tek/src/core/focus.rs +++ b/crates/tek/src/core/focus.rs @@ -19,18 +19,10 @@ impl FocusState { 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 FocusOrder for T { } pub trait FocusWrap { - fn wrap <'a, W: Render> (self, focus: T, content: &'a W) - -> impl Render + 'a; + fn wrap > (self, focus: T, content: &'_ W) -> impl Render + '_; } pub fn to_focus_command (input: &TuiInput) -> Option> { diff --git a/crates/tek/src/core/input.rs b/crates/tek/src/core/input.rs index 19c42b3b..9686a533 100644 --- a/crates/tek/src/core/input.rs +++ b/crates/tek/src/core/input.rs @@ -45,7 +45,7 @@ impl> Handle for Option { impl Handle for Mutex where H: Handle { fn handle (&mut self, context: &E::Input) -> Perhaps { - self.lock().unwrap().handle(context) + self.get_mut().unwrap().handle(context) } } diff --git a/crates/tek/src/core/output.rs b/crates/tek/src/core/output.rs index 8798251f..5ee2a75d 100644 --- a/crates/tek/src/core/output.rs +++ b/crates/tek/src/core/output.rs @@ -75,7 +75,7 @@ impl Render for &dyn Render { //} //} -impl<'a, E: Engine> Render for Box + 'a> { +impl Render for Box + '_> { fn min_size (&self, to: E::Size) -> Perhaps { (**self).min_size(to) } diff --git a/crates/tek/src/plugin.rs b/crates/tek/src/plugin.rs index 9f347709..b728bfd1 100644 --- a/crates/tek/src/plugin.rs +++ b/crates/tek/src/plugin.rs @@ -57,24 +57,6 @@ impl Plugin { audio_outs: vec![], }) } - - //fn jack_from_lv2 (name: &str, plugin: &::livi::Plugin) -> Usually { - //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>); @@ -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 { + //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) + //} diff --git a/crates/tek/src/plugin/lv2.rs b/crates/tek/src/plugin/lv2.rs index 206a79c3..4beddcf0 100644 --- a/crates/tek/src/plugin/lv2.rs +++ b/crates/tek/src/plugin/lv2.rs @@ -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 diff --git a/crates/tek/src/space.rs b/crates/tek/src/space.rs index 1934f727..ec0cbd7e 100644 --- a/crates/tek/src/space.rs +++ b/crates/tek/src/space.rs @@ -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 + + Sub + + Mul + + Div + + Ord + PartialEq + Eq + + Debug + Display + Default + + From + Into + + Into + + Into +{ + fn minus (self, other: Self) -> Self { + if self >= other { + self - other + } else { + 0.into() + } + } + fn zero () -> Self { + 0.into() + } +} + +impl Coordinate for T where T: Send + Sync + Copy + + Add + + Sub + + Mul + + Div + + Ord + PartialEq + Eq + + Debug + Display + Default + + From + Into + + Into + + Into +{} + +pub trait Size { + 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 Size for (N, N) { + fn x (&self) -> N { self.0 } + fn y (&self) -> N { self.1 } +} + +impl Size for [N;2] { + fn x (&self) -> N { self[0] } + fn y (&self) -> N { self[1] } +} + +pub trait Area: 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;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 Area 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 Area 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] } +} diff --git a/crates/tek/src/space/area.rs b/crates/tek/src/space/area.rs deleted file mode 100644 index c1c8d350..00000000 --- a/crates/tek/src/space/area.rs +++ /dev/null @@ -1,73 +0,0 @@ -use crate::*; - -pub trait Area: 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;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 Area 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 Area 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] } -} diff --git a/crates/tek/src/space/coord.rs b/crates/tek/src/space/coord.rs deleted file mode 100644 index 67c8ddcf..00000000 --- a/crates/tek/src/space/coord.rs +++ /dev/null @@ -1,37 +0,0 @@ -use crate::*; - -/// Standard numeric type. -pub trait Coordinate: Send + Sync + Copy - + Add - + Sub - + Mul - + Div - + Ord + PartialEq + Eq - + Debug + Display + Default - + From + Into - + Into - + Into -{ - fn minus (self, other: Self) -> Self { - if self >= other { - self - other - } else { - 0.into() - } - } - fn zero () -> Self { - 0.into() - } -} - -impl Coordinate for T where T: Send + Sync + Copy - + Add - + Sub - + Mul - + Div - + Ord + PartialEq + Eq - + Debug + Display + Default - + From + Into - + Into - + Into -{} diff --git a/crates/tek/src/space/direction.rs b/crates/tek/src/space/direction.rs deleted file mode 100644 index 7ad3eb8d..00000000 --- a/crates/tek/src/space/direction.rs +++ /dev/null @@ -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, - } - } -} diff --git a/crates/tek/src/space/size.rs b/crates/tek/src/space/size.rs deleted file mode 100644 index 5fe0ed40..00000000 --- a/crates/tek/src/space/size.rs +++ /dev/null @@ -1,26 +0,0 @@ -use crate::*; - -pub trait Size { - 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 Size for (N, N) { - fn x (&self) -> N { self.0 } - fn y (&self) -> N { self.1 } -} -impl Size for [N;2] { - fn x (&self) -> N { self[0] } - fn y (&self) -> N { self[1] } -} diff --git a/crates/tek/src/space/split.rs b/crates/tek/src/space/split.rs index e4c98785..26faf2c1 100644 --- a/crates/tek/src/space/split.rs +++ b/crates/tek/src/space/split.rs @@ -1,4 +1,5 @@ use crate::*; +use Direction::*; impl LayoutSplit for E {} @@ -11,22 +12,22 @@ pub trait LayoutSplit { fn split_n , B: Render> ( flip: bool, amount: E::Unit, a: A, b: B ) -> Split { - Self::split(flip, Direction::Up, amount, a, b) + Self::split(flip, North, amount, a, b) } fn split_s , B: Render> ( flip: bool, amount: E::Unit, a: A, b: B ) -> Split { - Self::split(flip, Direction::Down, amount, a, b) + Self::split(flip, South, amount, a, b) } fn split_w , B: Render> ( flip: bool, amount: E::Unit, a: A, b: B ) -> Split { - Self::split(flip, Direction::Left, amount, a, b) + Self::split(flip, West, amount, a, b) } fn split_e , B: Render> ( flip: bool, amount: E::Unit, a: A, b: B ) -> Split { - Self::split(flip, Direction::Right, amount, a, b) + Self::split(flip, East, amount, a, b) } } @@ -40,16 +41,16 @@ impl, B: Render> Split { 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()) } } diff --git a/crates/tek/src/space/stack.rs b/crates/tek/src/space/stack.rs index 79fb643d..a48f5a5a 100644 --- a/crates/tek/src/space/stack.rs +++ b/crates/tek/src/space/stack.rs @@ -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 { 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| { @@ -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| { @@ -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| { @@ -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| { @@ -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()); diff --git a/crates/tek/src/time/clock.rs b/crates/tek/src/time/clock.rs index 8798029a..022bc26f 100644 --- a/crates/tek/src/time/clock.rs +++ b/crates/tek/src/time/clock.rs @@ -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 Audio for ClockAudio<'_, T> { #[inline] fn process (&mut self, _: &Client, scope: &ProcessScope) -> Control { self.0.clock().update_from_scope(scope).unwrap(); Control::Continue