#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum MouseButton {
Left,
Right,
Middle,
}
#[derive(Debug, Clone, Copy, PartialEq)]
#[non_exhaustive]
pub enum MouseEventKind {
Press(MouseButton),
Release(MouseButton),
Move,
Scroll(f64),
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct MouseEvent {
pub position: (f64, f64),
pub kind: MouseEventKind,
pub modifiers: Modifiers,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum Key {
R,
X,
Y,
Z,
Up,
Down,
Left,
Right,
Plus,
Minus,
Escape,
Char(char),
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum KeyEvent {
Pressed {
key: Key,
},
Released {
key: Key,
},
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub struct Modifiers {
pub shift: bool,
pub ctrl: bool,
pub alt: bool,
}
#[derive(Debug, Clone, Copy)]
pub struct InteractionContext {
pub viewport_width: f64,
pub viewport_height: f64,
pub volume_bounds: Option<crate::math::Aabb>,
}
impl InteractionContext {
#[must_use]
pub fn aspect(&self) -> f64 {
if self.viewport_height > 0.0 {
self.viewport_width / self.viewport_height
} else {
1.0
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub struct InteractionResult {
pub camera_changed: bool,
pub window_level_changed: bool,
pub slice_changed: bool,
pub needs_redraw: bool,
}
impl InteractionResult {
#[must_use]
pub fn camera_only() -> Self {
Self {
camera_changed: true,
needs_redraw: true,
..Self::default()
}
}
#[must_use]
pub fn nothing() -> Self {
Self::default()
}
#[must_use]
pub fn window_level_only() -> Self {
Self {
window_level_changed: true,
needs_redraw: true,
..Self::default()
}
}
#[must_use]
pub fn slice_only() -> Self {
Self {
slice_changed: true,
needs_redraw: true,
..Self::default()
}
}
}