Produce new window file events in iced_winit

This commit is contained in:
Héctor Ramón Jiménez 2020-01-16 07:18:17 +01:00
parent f73bacb454
commit b3106738eb
2 changed files with 24 additions and 13 deletions

View file

@ -26,7 +26,7 @@ pub enum Event {
/// A file was hovered, but has exited the window. /// A file was hovered, but has exited the window.
/// ///
/// There will be a single `FilesLeft` event triggered even if multiple /// There will be a single `FilesHoveredLeft` event triggered even if
/// files were hovered. /// multiple files were hovered.
FilesLeft, FilesHoveredLeft,
} }

View file

@ -302,6 +302,18 @@ pub trait Application: Sized {
event: window_event, event: window_event,
.. ..
} => match window_event { } => match window_event {
WindowEvent::Resized(new_size) => {
events.push(Event::Window(window::Event::Resized {
width: new_size.width.round() as u32,
height: new_size.height.round() as u32,
}));
size = new_size;
resized = true;
}
WindowEvent::CloseRequested => {
*control_flow = ControlFlow::Exit;
}
WindowEvent::CursorMoved { position, .. } => { WindowEvent::CursorMoved { position, .. } => {
events.push(Event::Mouse(mouse::Event::CursorMoved { events.push(Event::Mouse(mouse::Event::CursorMoved {
x: position.x as f32, x: position.x as f32,
@ -370,17 +382,16 @@ pub trait Application: Sized {
modifiers: conversion::modifiers_state(modifiers), modifiers: conversion::modifiers_state(modifiers),
})); }));
} }
WindowEvent::CloseRequested => { WindowEvent::HoveredFile(path) => {
*control_flow = ControlFlow::Exit; events
.push(Event::Window(window::Event::FileHovered(path)));
} }
WindowEvent::Resized(new_size) => { WindowEvent::DroppedFile(path) => {
events.push(Event::Window(window::Event::Resized { events
width: new_size.width.round() as u32, .push(Event::Window(window::Event::FileDropped(path)));
height: new_size.height.round() as u32, }
})); WindowEvent::HoveredFileCancelled => {
events.push(Event::Window(window::Event::FilesHoveredLeft));
size = new_size;
resized = true;
} }
_ => {} _ => {}
}, },