Merge pull request #149 from hecrj/feature/window-resized-event
Window resized event
This commit is contained in:
commit
992ca76afc
@ -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),
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ pub mod layout;
|
||||
pub mod renderer;
|
||||
pub mod subscription;
|
||||
pub mod widget;
|
||||
pub mod window;
|
||||
|
||||
mod clipboard;
|
||||
mod element;
|
||||
|
4
native/src/window.rs
Normal file
4
native/src/window.rs
Normal file
@ -0,0 +1,4 @@
|
||||
//! Build window-based GUI applications.
|
||||
mod event;
|
||||
|
||||
pub use event::Event;
|
12
native/src/window/event.rs
Normal file
12
native/src/window/event.rs
Normal file
@ -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,
|
||||
},
|
||||
}
|
@ -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);
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user