feat(render): logical style metrics with a UI scale, so chrome has a consistent physical size

This commit is contained in:
Martino Ferrari committed 2026-09-28 12:17:53 +02:00
1 parent 1f03631e98
commit 7500fc90d2
21 files changed
+708 -82

No files matched your search

+8 -5
View File
@@ -110,11 +110,14 @@ using FrameFn = std::function<void(Plot&, f64 dt)>;
/// a delta is then a logical difference scaled by the factor in force now, never
/// the difference of two device positions (see `DragAnchor`).
///
/// Note that this also means the renderer's *style metrics* stay in device
/// pixels: at scale 2 the label font is 24 device px = 12 logical px, so labels
/// are smaller relative to the widget than at 1x. That is the same convention
/// the GLFW and Qt adapters use, and a host that wants a constant logical text
/// size scales `Renderer::style()` metrics by the factor itself.
/// The same factor states the display to the *renderer*: it is written to
/// `Renderer::style().ui_scale` every frame, which is what makes the chrome the
/// same physical size at any scale. The style's metrics are logical (see the unit
/// rule on `render::Style` -- spec §10 reverses the older convention that had them
/// in device pixels and accepted smaller labels on a high-DPI host), so at scale 2
/// the label font is 12 logical px drawn at 24 device px: the same size on screen as
/// at 1x, not a smaller one. This is the same convention the GLFW, Qt and ImGui
/// adapters use, and none of them has to scale a style metric by hand.
///
/// ## Input
///