mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
display clamps; pass amount to axis inc/dec
This commit is contained in:
parent
694aed6d9b
commit
27b1c27891
3 changed files with 24 additions and 26 deletions
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue