From ae31e416c21523e9c66fa36b912d6731d7340749 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Wed, 27 Apr 2022 18:33:08 +0200 Subject: [PATCH] Don't use baseview system scaling on Windows/Linux Until the UI frameworks make it possible to get the size or scale for the window, this would cause the window contents to be scaled incorrectly if the host does not set a scale factor. --- nih_plug_egui/src/lib.rs | 6 ++++++ nih_plug_iced/src/lib.rs | 6 ++++++ nih_plug_vizia/src/lib.rs | 9 +++++++++ 3 files changed, 21 insertions(+) diff --git a/nih_plug_egui/src/lib.rs b/nih_plug_egui/src/lib.rs index 5ab69e24..01df87fc 100644 --- a/nih_plug_egui/src/lib.rs +++ b/nih_plug_egui/src/lib.rs @@ -44,7 +44,13 @@ where user_state: Arc::new(RwLock::new(user_state)), update: Arc::new(update), + // TODO: We can't get the size of the window when baseview does its own scaling, so if the + // host does not set a scale factor on Windows or Linux we should just use a factor of + // 1. That may make the GUI tiny but it also prevents it from getting cut off. + #[cfg(target_os = "macos")] scaling_factor: AtomicCell::new(None), + #[cfg(not(target_os = "macos"))] + scaling_factor: AtomicCell::new(Some(1.0)), })) } diff --git a/nih_plug_iced/src/lib.rs b/nih_plug_iced/src/lib.rs index d8f8e53d..6fb0366d 100644 --- a/nih_plug_iced/src/lib.rs +++ b/nih_plug_iced/src/lib.rs @@ -132,7 +132,13 @@ pub fn create_iced_editor( iced_state, initialization_flags, + // TODO: We can't get the size of the window when baseview does its own scaling, so if the + // host does not set a scale factor on Windows or Linux we should just use a factor of + // 1. That may make the GUI tiny but it also prevents it from getting cut off. + #[cfg(target_os = "macos")] scaling_factor: AtomicCell::new(None), + #[cfg(not(target_os = "macos"))] + scaling_factor: AtomicCell::new(Some(1.0)), parameter_updates_sender, parameter_updates_receiver: Arc::new(parameter_updates_receiver), diff --git a/nih_plug_vizia/src/lib.rs b/nih_plug_vizia/src/lib.rs index 39b6bf4d..a6a2de98 100644 --- a/nih_plug_vizia/src/lib.rs +++ b/nih_plug_vizia/src/lib.rs @@ -34,7 +34,13 @@ where app: Arc::new(app), apply_theming: true, + // TODO: We can't get the size of the window when baseview does its own scaling, so if the + // host does not set a scale factor on Windows or Linux we should just use a factor of + // 1. That may make the GUI tiny but it also prevents it from getting cut off. + #[cfg(target_os = "macos")] scaling_factor: AtomicCell::new(None), + #[cfg(not(target_os = "macos"))] + scaling_factor: AtomicCell::new(Some(1.0)), })) } @@ -54,7 +60,10 @@ where app: Arc::new(app), apply_theming: false, + #[cfg(target_os = "macos")] scaling_factor: AtomicCell::new(None), + #[cfg(not(target_os = "macos"))] + scaling_factor: AtomicCell::new(Some(1.0)), })) }