summaryrefslogtreecommitdiffstats
path: root/winit/src
diff options
context:
space:
mode:
authorLibravatar Richard <richardsoncusto@gmail.com>2022-10-19 23:33:20 -0300
committerLibravatar bungoboingo <shankern@protonmail.com>2023-01-09 11:27:04 -0800
commitf93fa0254329ebddca21ea1a79bd8ee6d8b4bdaf (patch)
tree3b3ae59caf9f67c0c5d58fb1aeb997bc91aecf99 /winit/src
parent1bc0c480f9747826b244c30e92d8c4a29b576e4a (diff)
downloadiced-f93fa0254329ebddca21ea1a79bd8ee6d8b4bdaf.tar.gz
iced-f93fa0254329ebddca21ea1a79bd8ee6d8b4bdaf.tar.bz2
iced-f93fa0254329ebddca21ea1a79bd8ee6d8b4bdaf.zip
introduce `window::spawn` and `window::close`
Diffstat (limited to 'winit/src')
-rw-r--r--winit/src/application.rs5
-rw-r--r--winit/src/multi_window.rs79
-rw-r--r--winit/src/window.rs16
3 files changed, 66 insertions, 34 deletions
diff --git a/winit/src/application.rs b/winit/src/application.rs
index 4486f5d9..910f3d94 100644
--- a/winit/src/application.rs
+++ b/winit/src/application.rs
@@ -675,6 +675,11 @@ pub fn run_command<A, E>(
window::Action::Drag => {
let _res = window.drag_window();
}
+ window::Action::Spawn { .. } | window::Action::Close => {
+ log::info!(
+ "This is only available on `multi_window::Application`"
+ )
+ }
window::Action::Resize { width, height } => {
window.set_inner_size(winit::dpi::LogicalSize {
width,
diff --git a/winit/src/multi_window.rs b/winit/src/multi_window.rs
index 9f46b88d..1d71d801 100644
--- a/winit/src/multi_window.rs
+++ b/winit/src/multi_window.rs
@@ -855,41 +855,52 @@ pub fn run_command<A, E>(
clipboard.write(contents);
}
},
- command::Action::Window(id, action) => {
- let window = windows.get(&id).expect("No window found");
-
- match action {
- window::Action::Resize { width, height } => {
- window.set_inner_size(winit::dpi::LogicalSize {
- width,
- height,
- });
- }
- window::Action::Move { x, y } => {
- window.set_outer_position(
- winit::dpi::LogicalPosition { x, y },
- );
- }
- window::Action::SetMode(mode) => {
- window.set_visible(conversion::visible(mode));
- window.set_fullscreen(conversion::fullscreen(
- window.primary_monitor(),
- mode,
- ));
- }
- window::Action::FetchMode(tag) => {
- let mode = if window.is_visible().unwrap_or(true) {
- conversion::mode(window.fullscreen())
- } else {
- window::Mode::Hidden
- };
-
- proxy
- .send_event(Event::Application(tag(mode)))
- .expect("Send message to event loop");
- }
+ command::Action::Window(id, action) => match action {
+ window::Action::Spawn { settings } => {
+ proxy
+ .send_event(Event::NewWindow(id, settings.into()))
+ .expect("Send message to event loop");
}
- }
+ window::Action::Close => {
+ proxy
+ .send_event(Event::CloseWindow(id))
+ .expect("Send message to event loop");
+ }
+ window::Action::Resize { width, height } => {
+ let window = windows.get(&id).expect("No window found");
+ window.set_inner_size(winit::dpi::LogicalSize {
+ width,
+ height,
+ });
+ }
+ window::Action::Move { x, y } => {
+ let window = windows.get(&id).expect("No window found");
+ window.set_outer_position(winit::dpi::LogicalPosition {
+ x,
+ y,
+ });
+ }
+ window::Action::SetMode(mode) => {
+ let window = windows.get(&id).expect("No window found");
+ window.set_visible(conversion::visible(mode));
+ window.set_fullscreen(conversion::fullscreen(
+ window.primary_monitor(),
+ mode,
+ ));
+ }
+ window::Action::FetchMode(tag) => {
+ let window = windows.get(&id).expect("No window found");
+ let mode = if window.is_visible().unwrap_or(true) {
+ conversion::mode(window.fullscreen())
+ } else {
+ window::Mode::Hidden
+ };
+
+ proxy
+ .send_event(Event::Application(tag(mode)))
+ .expect("Send message to event loop");
+ }
+ },
command::Action::System(action) => match action {
system::Action::QueryInformation(_tag) => {
#[cfg(feature = "system")]
diff --git a/winit/src/window.rs b/winit/src/window.rs
index d9bc0d83..fba863ef 100644
--- a/winit/src/window.rs
+++ b/winit/src/window.rs
@@ -14,6 +14,22 @@ pub fn drag<Message>() -> Command<Message> {
Command::single(command::Action::Window(window::Action::Drag))
}
+/// TODO(derezzedex)
+pub fn spawn<Message>(
+ id: window::Id,
+ settings: window::Settings,
+) -> Command<Message> {
+ Command::single(command::Action::Window(
+ id,
+ window::Action::Spawn { settings },
+ ))
+}
+
+/// TODO(derezzedex)
+pub fn close<Message>(id: window::Id) -> Command<Message> {
+ Command::single(command::Action::Window(id, window::Action::Close))
+}
+
/// Resizes the window to the given logical dimensions.
pub fn resize<Message>(
id: window::Id,