pub struct EditorScale { /* private fields */ }Expand description
Shared, mutable editor scale factor.
Single source of truth for the live content-scale of an open plugin
window. Each GUI backend (egui / iced / slint) constructs one in
Editor::open, stores it on the editor for set_scale_factor to
write through, and hands a clone to its baseview WindowHandler so
the render thread can pick up changes between frames.
Two writers, one reader-per-frame:
Editor::set_scale_factor(host → editor, e.g. CLAPset_scale, VST3 WindowsIPlugViewContentScaleSupport).WindowEvent::Resized(baseview → handler, fired when the OS reports a new content scale, e.g. dragging the window across monitors with different DPIs).
Most-recent-write wins. The handler tracks a last_applied_scale
alongside its EditorScale clone and, when it observes a divergence
at frame start, recomputes physical sizes and reconfigures its
surface / renderer.
Implementations§
Source§impl EditorScale
impl EditorScale
Sourcepub fn new(initial: f64) -> Self
pub fn new(initial: f64) -> Self
Construct with an initial scale. Non-finite or non-positive
values clamp to 1.0 so callers never have to defend against
0.0 * size collapsing the surface.
Sourcepub fn get_f32(&self) -> f32
pub fn get_f32(&self) -> f32
Read the current scale, narrowed to f32 for renderer / DSP
use. Display scales never exceed 4.0 in practice, so the f64
→ f32 narrowing is invisible.
Sourcepub fn set(&self, scale: f64)
pub fn set(&self, scale: f64)
Update the current scale. Non-finite or non-positive values are
silently dropped - callers are forwarding numbers from hosts /
info.scale() where a bad value is a host bug, not something
to propagate into the surface config.
Sourcepub fn take_change(&self, last: &mut f32) -> Option<f32>
pub fn take_change(&self, last: &mut f32) -> Option<f32>
Pick up a host-driven scale change since the last frame.
Reads the current scale (narrowed to f32) and compares it
bit-identically against last. When the value moved, updates
last and returns Some(cur); otherwise returns None.
Used by every editor backend’s per-frame loop to gate surface /
renderer reconfiguration on actual host scale events. Bit-equality
is the correct semantics - the cell is written verbatim from
host callbacks, never through accumulating arithmetic, so an
epsilon-based check would either thrash on noise (there is
none) or miss a legitimate 1.0 → 1.0001 host signal.
Trait Implementations§
Source§impl Clone for EditorScale
impl Clone for EditorScale
Source§fn clone(&self) -> EditorScale
fn clone(&self) -> EditorScale
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more