diff options
author | 2020-01-10 05:13:04 +0100 | |
---|---|---|
committer | 2020-01-10 05:13:04 +0100 | |
commit | 992ca76afc40bd3f57fbd2bc6e673e1fb334b0af (patch) | |
tree | 4e2598f2cf71b80f2e454391e65d2409b671778a | |
parent | 0a8302450557877cb667b51fc84383aaf0a11b02 (diff) | |
parent | d15d1156bd0c7fa111d1c59bea11fd58b9cc63b1 (diff) | |
download | iced-992ca76afc40bd3f57fbd2bc6e673e1fb334b0af.tar.gz iced-992ca76afc40bd3f57fbd2bc6e673e1fb334b0af.tar.bz2 iced-992ca76afc40bd3f57fbd2bc6e673e1fb334b0af.zip |
Merge pull request #149 from hecrj/feature/window-resized-event
Window resized event
-rw-r--r-- | native/src/event.rs | 8 | ||||
-rw-r--r-- | native/src/lib.rs | 1 | ||||
-rw-r--r-- | native/src/window.rs | 4 | ||||
-rw-r--r-- | native/src/window/event.rs | 12 | ||||
-rw-r--r-- | winit/src/application.rs | 11 |
5 files changed, 31 insertions, 5 deletions
diff --git a/native/src/event.rs b/native/src/event.rs index 71f06006..1d28aa7b 100644 --- a/native/src/event.rs +++ b/native/src/event.rs @@ -1,4 +1,7 @@ -use crate::input::{keyboard, mouse}; +use crate::{ + input::{keyboard, mouse}, + window, +}; /// A user interface event. /// @@ -13,4 +16,7 @@ pub enum Event { /// A mouse event Mouse(mouse::Event), + + /// A window event + Window(window::Event), } diff --git a/native/src/lib.rs b/native/src/lib.rs index 8dcacb2b..e65c6596 100644 --- a/native/src/lib.rs +++ b/native/src/lib.rs @@ -44,6 +44,7 @@ pub mod layout; pub mod renderer; pub mod subscription; pub mod widget; +pub mod window; mod clipboard; mod element; diff --git a/native/src/window.rs b/native/src/window.rs new file mode 100644 index 00000000..220bb3be --- /dev/null +++ b/native/src/window.rs @@ -0,0 +1,4 @@ +//! Build window-based GUI applications. +mod event; + +pub use event::Event; diff --git a/native/src/window/event.rs b/native/src/window/event.rs new file mode 100644 index 00000000..89ec0a0c --- /dev/null +++ b/native/src/window/event.rs @@ -0,0 +1,12 @@ +/// A window-related event. +#[derive(PartialEq, Clone, Copy, Debug)] +pub enum Event { + /// A window was resized + Resized { + /// The new width of the window (in units) + width: u32, + + /// The new height of the window (in units) + height: u32, + }, +} diff --git a/winit/src/application.rs b/winit/src/application.rs index da943660..8529c99c 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -2,8 +2,8 @@ use crate::{ container, conversion, input::{keyboard, mouse}, renderer::{Target, Windowed}, - subscription, Cache, Clipboard, Command, Container, Debug, Element, Event, - Length, MouseCursor, Settings, Subscription, UserInterface, + subscription, window, Cache, Clipboard, Command, Container, Debug, Element, + Event, Length, MouseCursor, Settings, Subscription, UserInterface, }; /// An interactive, native cross-platform application. @@ -373,10 +373,13 @@ pub trait Application: Sized { *control_flow = ControlFlow::Exit; } 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; - - log::debug!("Resized: {:?}", new_size); } _ => {} }, |