diff --git a/README.md b/README.md
index 31c080e..1d1ffde 100644
--- a/README.md
+++ b/README.md
@@ -90,7 +90,7 @@
hui-winit = <master>
- winit = "0.29"
+ winit = "0.30" or winit = "0.29"
|
(support planned) |
diff --git a/hui-examples/Cargo.toml b/hui-examples/Cargo.toml
index fe069b4..fc7dcd0 100644
--- a/hui-examples/Cargo.toml
+++ b/hui-examples/Cargo.toml
@@ -8,7 +8,7 @@ publish = false
[dev-dependencies]
hui = { path = "../hui" }
hui-glium = { path = "../hui-glium" }
-hui-winit = { path = "../hui-winit" }
+hui-winit = { path = "../hui-winit", features = ["winit_29"] }
kubi-logging = { git = "https://github.com/griffi-gh/kubi", rev = "c162893fd" }
glium = "0.34"
winit = "0.29"
diff --git a/hui-winit/Cargo.toml b/hui-winit/Cargo.toml
index 8d45dee..00c622d 100644
--- a/hui-winit/Cargo.toml
+++ b/hui-winit/Cargo.toml
@@ -15,6 +15,12 @@ include = [
[dependencies]
hui = { version = "=0.1.0-alpha.5", path = "../hui", default-features = false }
-winit = { version = "0.29", default-features = false }
+winit_30 = { package = "winit", version = "0.30", default-features = false, optional = true }
+winit_29 = { package = "winit", version = "0.29", default-features = false, optional = true }
glam = "0.27"
log = "0.4"
+
+[features]
+default = []
+winit_30 = ["dep:winit_30"]
+winit_29 = ["dep:winit_29"]
diff --git a/hui-winit/src/lib.rs b/hui-winit/src/lib.rs
index 8037781..5dec0f9 100644
--- a/hui-winit/src/lib.rs
+++ b/hui-winit/src/lib.rs
@@ -1,6 +1,13 @@
+#[cfg(all(feature = "winit_30", feature = "winit_29"))]
+compile_error!("Only one of the winit_30 and winit_29 features can be enabled at a time");
+#[cfg(not(any(feature = "winit_30", feature = "winit_29")))]
+compile_error!("One of the winit_30 and winit_29 features must be enabled");
+#[cfg(feature = "winit_30")] extern crate winit_30 as winit;
+#[cfg(feature = "winit_29")] extern crate winit_29 as winit;
+
use glam::vec2;
use hui::{event::UiEvent, UiInstance};
-use winit::event::{Event, WindowEvent};
+use winit::event::{Event, WindowEvent, MouseButton, ElementState};
//TODO: check window id
pub fn handle_winit_event(ui: &mut UiInstance, event: &Event) {
@@ -12,15 +19,15 @@ pub fn handle_winit_event(ui: &mut UiInstance, event: &Event) {
WindowEvent::MouseInput { state, button, .. } => {
ui.push_event(UiEvent::MouseButton {
button: match button {
- winit::event::MouseButton::Left => hui::input::MouseButton::Primary,
- winit::event::MouseButton::Right => hui::input::MouseButton::Secondary,
- winit::event::MouseButton::Middle => hui::input::MouseButton::Middle,
- winit::event::MouseButton::Other(id) => hui::input::MouseButton::Other(*id as u8),
+ MouseButton::Left => hui::input::MouseButton::Primary,
+ MouseButton::Right => hui::input::MouseButton::Secondary,
+ MouseButton::Middle => hui::input::MouseButton::Middle,
+ MouseButton::Other(id) => hui::input::MouseButton::Other(*id as u8),
_ => return,
},
state: match state {
- winit::event::ElementState::Pressed => hui::input::ButtonState::Pressed,
- winit::event::ElementState::Released => hui::input::ButtonState::Released,
+ ElementState::Pressed => hui::input::ButtonState::Pressed,
+ ElementState::Released => hui::input::ButtonState::Released,
},
})
},