enable interior mutability for time/note axis

this will allow to adapt the cursor position
during render, always keeping it visible
This commit is contained in:
🪞👃🪞 2024-10-24 22:47:15 +03:00
parent 03e2e20258
commit dd21f73e9d
4 changed files with 83 additions and 60 deletions

View file

@ -1,5 +1,16 @@
use crate::*;
pub struct FixedAxis<T> {
pub start: T,
pub point: Option<T>,
pub clamp: Option<T>,
}
pub struct ScaledAxis<T> {
pub start: T,
pub scale: T,
pub point: Option<T>,
pub clamp: Option<T>,
}
macro_rules! impl_axis_common { ($A:ident $T:ty) => {
impl $A<$T> {
#[inline] pub fn start_inc (&mut self, n: $T) -> $T {
@ -20,23 +31,8 @@ macro_rules! impl_axis_common { ($A:ident $T:ty) => {
}
}
} }
pub struct FixedAxis<T> {
pub start: T,
pub point: Option<T>,
pub clamp: Option<T>,
}
impl_axis_common!(FixedAxis u16);
impl_axis_common!(FixedAxis usize);
pub struct ScaledAxis<T> {
pub start: T,
pub scale: T,
pub point: Option<T>,
pub clamp: Option<T>,
}
impl_axis_common!(ScaledAxis u16);
impl_axis_common!(ScaledAxis usize);