#[allow(unused)] use super::EventCx;
use super::components::KineticStart;
#[allow(unused)] use crate::Events;
use crate::geom::{Offset, Rect, Vec2};
pub use IsUsed::{Unused, Used};
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)]
pub enum IsUsed {
Unused,
Used,
}
impl From<bool> for IsUsed {
fn from(is_used: bool) -> Self {
match is_used {
false => Self::Unused,
true => Self::Used,
}
}
}
impl From<IsUsed> for bool {
fn from(is_used: IsUsed) -> bool {
is_used == Used
}
}
impl std::ops::BitOr for IsUsed {
type Output = Self;
#[inline]
fn bitor(self, rhs: Self) -> Self {
match (self, rhs) {
(Unused, Unused) => Unused,
_ => Used,
}
}
}
impl std::ops::BitOrAssign for IsUsed {
#[inline]
fn bitor_assign(&mut self, rhs: Self) {
*self = *self | rhs;
}
}
impl std::ops::Not for IsUsed {
type Output = bool;
#[inline]
fn not(self) -> bool {
self != Used
}
}
#[derive(Clone, Debug, Default, PartialEq)]
#[must_use]
pub enum Scroll {
#[default]
None,
Scrolled,
Offset(Vec2),
Kinetic(KineticStart),
Rect(Rect),
}
impl std::ops::Sub<Offset> for Scroll {
type Output = Self;
#[inline]
fn sub(self, rhs: Offset) -> Self {
match self {
Scroll::Rect(rect) => Scroll::Rect(rect - rhs),
other => other,
}
}
}