display clamps; pass amount to axis inc/dec

This commit is contained in:
🪞👃🪞 2024-10-23 01:14:09 +03:00
parent 694aed6d9b
commit 27b1c27891
3 changed files with 24 additions and 26 deletions

View file

@ -2,20 +2,20 @@ use crate::*;
macro_rules! impl_axis_common { ($A:ident $T:ty) => {
impl $A<$T> {
#[inline] pub fn start_inc (&mut self) -> $T {
self.start += 1;
#[inline] pub fn start_inc (&mut self, n: $T) -> $T {
self.start = (self.start + n).min(self.clamp.unwrap_or(<$T>::MAX));
self.start
}
#[inline] pub fn start_dec (&mut self) -> $T {
self.start = self.start.saturating_sub(1);
#[inline] pub fn start_dec (&mut self, n: $T) -> $T {
self.start = self.start.saturating_sub(n);
self.start
}
#[inline] pub fn point_inc (&mut self) -> Option<$T> {
self.point = self.point.map(|p|p + 1);
#[inline] pub fn point_inc (&mut self, n: $T) -> Option<$T> {
self.point = self.point.map(|p|(p + n).min(self.clamp.unwrap_or(<$T>::MAX)));
self.point
}
#[inline] pub fn point_dec (&mut self) -> Option<$T> {
self.point = self.point.map(|p|p.saturating_sub(1));
#[inline] pub fn point_dec (&mut self, n: $T) -> Option<$T> {
self.point = self.point.map(|p|p.saturating_sub(n));
self.point
}
}