use modified version of conrod

Former-commit-id: 6a4697d02e18732dbf9ad679bac761c5a73457fa
This commit is contained in:
Imbris 2019-04-13 10:33:42 -04:00
parent 5404cc548a
commit 5e576f048e
2 changed files with 20 additions and 3 deletions

View File

@ -18,8 +18,9 @@ gfx = "0.17"
gfx_device_gl = { version = "0.15", optional = true }
gfx_window_glutin = "0.28"
glutin = "0.19"
conrod_core = "0.63"
conrod_winit = "0.63"
winit = "0.18"
conrod_core = { git = "https://gitlab.com/veloren/conrod.git" }
conrod_winit = { git = "https://gitlab.com/veloren/conrod.git" }
# ECS
specs = "0.14"

View File

@ -43,7 +43,23 @@ pub enum UiError {
pub struct Event(Input);
impl Event {
pub fn try_from(event: glutin::Event, window: &glutin::GlWindow) -> Option<Self> {
conrod_winit::convert_event(event, window.window()).map(|input| {
use conrod_winit::*;
use winit;
// A wrapper around the winit window that allows us to implement the trait necessary for enabling
// the winit <-> conrod conversion functions.
struct WindowRef<'a>(&'a winit::Window);
// Implement the `WinitWindow` trait for `WindowRef` to allow for generating compatible conversion
// functions.
impl<'a> conrod_winit::WinitWindow for WindowRef<'a> {
fn get_inner_size(&self) -> Option<(u32, u32)> {
winit::Window::get_inner_size(&self.0).map(Into::into)
}
fn hidpi_factor(&self) -> f32 {
winit::Window::get_hidpi_factor(&self.0) as _
}
}
convert_event!(event, &WindowRef(window.window())).map(|input| {
Self(input)
})
}