Expand description
Scale, per window. Three scales multiply into egui’s
pixels_per_point (ppp) for the window being drawn:
- the native scale, the system’s for the window’s screen (winit’s scale factor), which differs between windows on screens of different densities;
- the interface zoom, the user’s “make everything bigger”, one
value for every window (egui’s
zoom_factor), moved in fixedZOOM_STEPSso that each step’s glyphs are rasterised once; - text size, which egui-pop’s theme applies to fonts only.
Layout is in points and does not move when the scale changes; only
rasterisation does. Read the scale where you paint
(ui.ctx().pixels_per_point() is the current window’s), never from a
value kept by an application-wide object. Caches sized in physical
pixels (thumbnails, textures) listen to changed, once per change.
Lines: a 1 point stroke is 1.25 pixels at 1.25, feathered over two
pixel columns into a grey line. stroke snaps a width as CSS snaps
border widths: to whole pixels, at least one.
use egui_pop_core::scale;
assert_eq!(scale::snap(1.0, 1.25), 0.8); // one pixel
assert_eq!(scale::snap(1.0, 2.0), 1.0); // two pixels
assert_eq!(scale::snap(0.25, 1.0), 1.0); // never under one pixel
assert_eq!(scale::zoom_step(1.0, 1), 1.1);
assert_eq!(scale::zoom_step(2.0, 1), 2.0);Structs§
- Scale
- The scales of the window being drawn.
Constants§
- ZOOM_
STEPS - The interface zoom’s steps.
Functions§
- changed
- The current window’s scale change this pass:
(old, new)pixels per point, orNone. Asked any number of times in one pass, it answers the same; the first pass of a window reports no change. - disable_
keyboard_ zoom - Turns off egui’s own zoom keys (Ctrl and
+,-,0), which would fire together with an application’s content zoom; egui-pop’s interface zoom commands replace them. - hairline
- One physical pixel, in points, in the current window.
- snap
- A width of
wpoints snapped atppp: a whole number of physical pixels, at least one, back in points. A width of zero (or less) stays zero: a stroke set to nothing is not drawn as a hairline. - snap_
size - A side of
spoints rounded to whole physical pixels (an icon’s box). - stroke
- A stroke width of
wpoints that stays crisp in the current window. - zoom_
step - The zoom step
bysteps fromcurrent(the nearest step first), clamped to the ends.