From<FrameInput> not ref
@@ -62,7 +62,7 @@ impl GUI {
frame_input: &mut crate::window::FrameInput,
callback: impl FnOnce(&egui::Context),
) -> bool {
- let change = self.update_internal(frame_input.into(), callback);
+ let change = self.update_internal(frame_input.clone().into(), callback);
for event in frame_input.events.iter_mut() {
if self.egui_context.wants_pointer_input() {
match event {
@@ -147,24 +147,11 @@ impl GUI {
}
#[cfg(feature = "window")]
-impl From<&mut crate::window::FrameInput> for egui::RawInput {
- fn from(input: &mut crate::window::FrameInput) -> Self {
- construct_input_state(input)
- }
-}
-
-#[cfg(feature = "window")]
-impl From<&crate::window::FrameInput> for egui::RawInput {
- fn from(input: &crate::window::FrameInput) -> Self {
- construct_input_state(input)
- }
-}
-
-#[cfg(feature = "window")]
-fn construct_input_state(frame_input: &crate::window::FrameInput) -> egui::RawInput {
+impl From<crate::window::FrameInput> for egui::RawInput {
+ fn from(frame_input: crate::window::FrameInput) -> Self {
let mut egui_modifiers = egui::Modifiers::default();
let mut egui_events = Vec::new();
- for event in frame_input.events.iter() {
+ for event in frame_input.events {
match event {
Event::KeyPress {
kind,
@@ -264,7 +251,6 @@ fn construct_input_state(frame_input: &crate::window::FrameInput) -> egui::RawIn
_ => (),
}
}
-
egui::RawInput {
screen_rect: Some(egui::Rect::from_min_size(
Default::default(),
@@ -280,8 +266,9 @@ fn construct_input_state(frame_input: &crate::window::FrameInput) -> egui::RawIn
..Default::default()
}
}
+}
-fn translate_to_egui_key_code(key: &crate::Key) -> egui::Key {
+fn translate_to_egui_key_code(key: crate::Key) -> egui::Key {
use crate::Key::*;
use egui::Key;
@@ -344,7 +331,7 @@ fn translate_to_egui_key_code(key: &crate::Key) -> egui::Key {
}
}
-fn map_modifiers(modifiers: &Modifiers) -> egui::Modifiers {
+fn map_modifiers(modifiers: Modifiers) -> egui::Modifiers {
egui::Modifiers {
alt: modifiers.alt,
ctrl: modifiers.ctrl,
