The VST3 and CLAP APIs require sizes to be in either physical or logical coordinates, depending on the current platform.
The current baseview APIs (backed by the dpi crate) use different types to separate the two coordinates types, which forces users to jump through some platform-specific hoops to get this to work properly, for instance:
|
fn size_to_gui_size(size: Size, scale_factor: f64) -> GuiSize { |
|
#[cfg(target_os = "macos")] |
|
{ |
|
let size = size.to_logical(scale_factor); |
|
GuiSize { width: size.width, height: size.height } |
|
} |
|
|
|
#[cfg(not(target_os = "macos"))] |
|
{ |
|
let size = size.to_physical(scale_factor); |
|
GuiSize { width: size.width, height: size.height } |
|
} |
|
} |
Having a NativeSize type which can have the same Pixel type for both logical and physical sizes would alleviate this issue, and remove this potential footgun from native code.
The VST3 and CLAP APIs require sizes to be in either physical or logical coordinates, depending on the current platform.
The current baseview APIs (backed by the
dpicrate) use different types to separate the two coordinates types, which forces users to jump through some platform-specific hoops to get this to work properly, for instance:baseview/examples/plugin_clack/src/gui.rs
Lines 165 to 177 in 4a4827a
Having a
NativeSizetype which can have the samePixeltype for both logical and physical sizes would alleviate this issue, and remove this potential footgun from native code.