Rename MouseInput to CursorState

This commit is contained in:
Emil Ernerfeldt 2021-01-17 02:34:21 +01:00
parent d0fc77fe9b
commit 53d0114d3c
2 changed files with 8 additions and 8 deletions

View file

@ -16,7 +16,7 @@ pub struct InputState {
/// The raw input we got this frame /// The raw input we got this frame
pub raw: RawInput, pub raw: RawInput,
pub mouse: MouseInput, pub mouse: CursorState,
/// How many pixels the user scrolled /// How many pixels the user scrolled
pub scroll_delta: Vec2, pub scroll_delta: Vec2,
@ -68,7 +68,7 @@ impl Default for InputState {
/// Mouse (or touch) state. /// Mouse (or touch) state.
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct MouseInput { pub struct CursorState {
/// Is the button currently down? /// Is the button currently down?
/// true the frame when it is pressed, /// true the frame when it is pressed,
/// false the frame it is released. /// false the frame it is released.
@ -113,7 +113,7 @@ pub struct MouseInput {
pos_history: History<Pos2>, pos_history: History<Pos2>,
} }
impl Default for MouseInput { impl Default for CursorState {
fn default() -> Self { fn default() -> Self {
Self { Self {
down: false, down: false,
@ -236,9 +236,9 @@ impl InputState {
} }
} }
impl MouseInput { impl CursorState {
#[must_use] #[must_use]
pub fn begin_frame(mut self, time: f64, new: &RawInput) -> MouseInput { pub fn begin_frame(mut self, time: f64, new: &RawInput) -> CursorState {
let delta = new let delta = new
.mouse_pos .mouse_pos
.and_then(|new| self.pos.map(|last| new - last)) .and_then(|new| self.pos.map(|last| new - last))
@ -289,7 +289,7 @@ impl MouseInput {
Vec2::default() Vec2::default()
}; };
MouseInput { CursorState {
down: new.mouse_down && new.mouse_pos.is_some(), down: new.mouse_down && new.mouse_pos.is_some(),
pressed, pressed,
released, released,
@ -354,7 +354,7 @@ impl InputState {
} }
} }
impl MouseInput { impl CursorState {
pub fn ui(&self, ui: &mut crate::Ui) { pub fn ui(&self, ui: &mut crate::Ui) {
let Self { let Self {
down, down,

View file

@ -117,7 +117,7 @@ pub use {
data::{input::*, output::*}, data::{input::*, output::*},
grid::Grid, grid::Grid,
id::Id, id::Id,
input_state::*, input_state::InputState,
layers::{LayerId, Order}, layers::{LayerId, Order},
layout::*, layout::*,
memory::Memory, memory::Memory,