flatland-client-ui 0.2.15

Engine-agnostic play client UI state (world grid, input, presentation)
Documentation
//! Engine-neutral keyboard and pointer events.

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum UiKeyEventKind {
    Press,
    Release,
    Repeat,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub struct UiKeyModifiers {
    pub shift: bool,
    pub control: bool,
    pub alt: bool,
}

impl UiKeyModifiers {
    pub fn contains_shift(self) -> bool {
        self.shift
    }

    pub fn contains_control(self) -> bool {
        self.control
    }

    pub fn contains_alt(self) -> bool {
        self.alt
    }
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum UiKeyCode {
    Char(char),
    Up,
    Down,
    Left,
    Right,
    Esc,
    Enter,
    Tab,
    BackTab,
    Delete,
    Backspace,
    Space,
    ShiftLeft,
    ShiftRight,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct UiKeyEvent {
    pub kind: UiKeyEventKind,
    pub code: UiKeyCode,
    pub modifiers: UiKeyModifiers,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum UiMouseButton {
    Left,
    Right,
    Middle,
}

#[derive(Debug, Clone, Copy, PartialEq)]
pub enum UiPointerEvent {
    Move {
        x: f32,
        y: f32,
    },
    Click {
        x: f32,
        y: f32,
        button: UiMouseButton,
        /// True when Shift was held at click time (T2 combat targeting).
        shift: bool,
    },
    Scroll {
        x: f32,
        y: f32,
        delta: f32,
    },
}