diff options
author | 2023-01-18 17:04:11 -0800 | |
---|---|---|
committer | 2023-01-18 17:04:11 -0800 | |
commit | 0a643287deece9234b64cc843a9f6ae3e6e4806e (patch) | |
tree | f0072a46432d8e2f1a8a4131ac05297283d2dea5 /examples/multi_window | |
parent | 7e9a12a4aa64deda193dfc0f18c34f93e3adc852 (diff) | |
download | iced-0a643287deece9234b64cc843a9f6ae3e6e4806e.tar.gz iced-0a643287deece9234b64cc843a9f6ae3e6e4806e.tar.bz2 iced-0a643287deece9234b64cc843a9f6ae3e6e4806e.zip |
Added window::Id to multi_window application's scale_factor
Diffstat (limited to 'examples/multi_window')
-rw-r--r-- | examples/multi_window/src/main.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/examples/multi_window/src/main.rs b/examples/multi_window/src/main.rs index 18536bdf..0d0a809b 100644 --- a/examples/multi_window/src/main.rs +++ b/examples/multi_window/src/main.rs @@ -12,6 +12,7 @@ use iced::{Color, Command, Element, Length, Settings, Size, Subscription}; use iced_lazy::responsive; use iced_native::{event, subscription, Event}; +use iced_native::window::Id; use std::collections::HashMap; pub fn main() -> iced::Result { @@ -29,6 +30,7 @@ struct Example { #[derive(Debug)] struct Window { title: String, + scale: f64, panes: pane_grid::State<Pane>, focus: Option<pane_grid::Pane>, } @@ -69,6 +71,7 @@ impl Application for Example { panes, focus: None, title: String::from("Default window"), + scale: 1.0, }; ( @@ -178,6 +181,7 @@ impl Application for Example { panes, focus: None, title: format!("New window ({})", self.windows.len()), + scale: 1.0 + (self.windows.len() as f64 / 10.0), }; let window_id = window::Id::new(self.windows.len()); @@ -342,6 +346,10 @@ impl Application for Example { fn close_requested(&self, window: window::Id) -> Self::Message { Message::Window(window, WindowMessage::CloseWindow) } + + fn scale_factor(&self, window: Id) -> f64 { + self.windows.get(&window).map(|w| w.scale).unwrap_or(1.0) + } } const PANE_ID_COLOR_UNFOCUSED: Color = Color::from_rgb( |