mirror of
https://github.com/hannobraun/Fornjot
synced 2025-05-06 10:58:28 +00:00
Simplify
This commit is contained in:
parent
04bd789006
commit
8065543d8e
@ -7,29 +7,20 @@ use crate::{
|
|||||||
|
|
||||||
use super::InputEvent;
|
use super::InputEvent;
|
||||||
|
|
||||||
/// Input handling abstraction
|
pub fn handle_event(
|
||||||
///
|
event: InputEvent,
|
||||||
/// Takes user input and applies them to application state.
|
focus_point: FocusPoint,
|
||||||
#[derive(Default)]
|
camera: &mut Camera,
|
||||||
pub struct InputHandler;
|
) {
|
||||||
|
match event {
|
||||||
impl InputHandler {
|
InputEvent::Translation { previous, current } => {
|
||||||
/// Handle an input event
|
apply_translation(previous, current, focus_point, camera);
|
||||||
pub fn handle_event(
|
}
|
||||||
event: InputEvent,
|
InputEvent::Rotation { angle_x, angle_y } => {
|
||||||
focus_point: FocusPoint,
|
apply_rotation(angle_x, angle_y, focus_point, camera);
|
||||||
camera: &mut Camera,
|
}
|
||||||
) {
|
InputEvent::Zoom(zoom_delta) => {
|
||||||
match event {
|
apply_zoom(zoom_delta, focus_point, camera);
|
||||||
InputEvent::Translation { previous, current } => {
|
|
||||||
apply_translation(previous, current, focus_point, camera);
|
|
||||||
}
|
|
||||||
InputEvent::Rotation { angle_x, angle_y } => {
|
|
||||||
apply_rotation(angle_x, angle_y, focus_point, camera);
|
|
||||||
}
|
|
||||||
InputEvent::Zoom(zoom_delta) => {
|
|
||||||
apply_zoom(zoom_delta, focus_point, camera);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,4 +3,4 @@
|
|||||||
mod event;
|
mod event;
|
||||||
mod handler;
|
mod handler;
|
||||||
|
|
||||||
pub use self::{event::InputEvent, handler::InputHandler};
|
pub use self::{event::InputEvent, handler::handle_event};
|
||||||
|
@ -4,7 +4,7 @@ use tracing::warn;
|
|||||||
use crate::{
|
use crate::{
|
||||||
camera::{Camera, FocusPoint},
|
camera::{Camera, FocusPoint},
|
||||||
graphics::{DrawConfig, Renderer},
|
graphics::{DrawConfig, Renderer},
|
||||||
input::InputHandler,
|
input::handle_event,
|
||||||
InputEvent, NormalizedScreenPosition, RendererInitError, Screen,
|
InputEvent, NormalizedScreenPosition, RendererInitError, Screen,
|
||||||
ScreenSize,
|
ScreenSize,
|
||||||
};
|
};
|
||||||
@ -62,7 +62,7 @@ impl Viewer {
|
|||||||
/// Handle an input event
|
/// Handle an input event
|
||||||
pub fn handle_input_event(&mut self, event: InputEvent) {
|
pub fn handle_input_event(&mut self, event: InputEvent) {
|
||||||
if let Some(focus_point) = self.focus_point {
|
if let Some(focus_point) = self.focus_point {
|
||||||
InputHandler::handle_event(event, focus_point, &mut self.camera);
|
handle_event(event, focus_point, &mut self.camera);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user