summaryrefslogtreecommitdiffstats
path: root/examples/multi_window
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2023-11-30 23:40:33 +0100
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2023-11-30 23:40:33 +0100
commit67408311f45d341509538f8cc185978da66b6ace (patch)
tree27b020da7eda4c77f07000e49335f5e0d482feba /examples/multi_window
parent9f29aec128ccf51c620a8b69a9fbd64186ab8c65 (diff)
downloadiced-67408311f45d341509538f8cc185978da66b6ace.tar.gz
iced-67408311f45d341509538f8cc185978da66b6ace.tar.bz2
iced-67408311f45d341509538f8cc185978da66b6ace.zip
Use actual floats for logical coordinates
Diffstat (limited to 'examples/multi_window')
-rw-r--r--examples/multi_window/src/main.rs15
1 files changed, 9 insertions, 6 deletions
diff --git a/examples/multi_window/src/main.rs b/examples/multi_window/src/main.rs
index 7d1f1e91..16beb46e 100644
--- a/examples/multi_window/src/main.rs
+++ b/examples/multi_window/src/main.rs
@@ -4,8 +4,10 @@ use iced::multi_window::{self, Application};
use iced::widget::{button, column, container, scrollable, text, text_input};
use iced::window;
use iced::{
- Alignment, Command, Element, Length, Settings, Subscription, Theme,
+ Alignment, Command, Element, Length, Point, Settings, Subscription, Theme,
+ Vector,
};
+
use std::collections::HashMap;
fn main() -> iced::Result {
@@ -33,8 +35,8 @@ enum Message {
ScaleChanged(window::Id, String),
TitleChanged(window::Id, String),
CloseWindow(window::Id),
+ WindowCreated(window::Id, Option<Point>),
WindowDestroyed(window::Id),
- WindowCreated(window::Id, (i32, i32)),
NewWindow,
}
@@ -90,10 +92,11 @@ impl multi_window::Application for Example {
self.windows.remove(&id);
}
Message::WindowCreated(id, position) => {
- self.next_window_pos = window::Position::Specific(
- position.0 + 20,
- position.1 + 20,
- );
+ if let Some(position) = position {
+ self.next_window_pos = window::Position::Specific(
+ position + Vector::new(20.0, 20.0),
+ );
+ }
if let Some(window) = self.windows.get(&id) {
return text_input::focus(window.input_id.clone());