Module content_zoom
Expand description
Content zoom: one mechanism for every app window.
Ctrl+Plus, Ctrl+Minus and Ctrl+0 (⌘ on macOS), Ctrl+scroll and a
touchpad pinch zoom the content of the window they reach. The window’s
host resolves the gesture to a ZoomStep and offers it to the widgets
first: a widget whose content has a zoom of its own (a web page’s
per-site zoom, a PDF page) provides ContentZoom and answers it.
Otherwise the step changes the window’s content scale (WindowZoom):
the theme is rebuilt with the factor multiplied into its UI scale, so
text, spacing, icons and every layout reflow at the new size, rasterised
at the display’s resolution, never a bitmap stretch. The person’s text
size setting stays on top of it (text_scale is untouched), and a
terminal’s grid, set in the theme’s code type, grows its font with it.
A window’s factor is remembered per app on this device, and every change is said in the window’s bar for a while (“110%”).
An app whose content has a scale of its own — a photograph fitted to its
frame, a PDF page, a board — does not invent its levels, its bounds or its
percentage: it holds a ZoomModel over its own levels and draws the
toolkit’s own controls for it (controls). Ctrl+0 then means the same
thing in every window: the content at its own size (a page at 100 %, a
picture fitted to the frame), never one app’s private idea of “fit”.
Structs§
- Window
Zoom - A window’s content zoom: its factor, where it is remembered, the level the window’s bar says after a change, and the scroll and pinch it accumulates into steps.
- Zoom
Model - The scale of one app’s content: the levels it steps through, where
Ctrl+0returns to, and the factor it shows now.
Enums§
- Zoom
Gesture - A zoom gesture as it arrives: a key, a Ctrl+scroll or a touchpad
pinch. Scroll and pinch add up to steps (
WindowZoom::step_of). - Zoom
Step - What a zoom gesture asks for, and what the window’s Zoom in, Zoom out and Actual size actions carry.
Constants§
- LEVELS
- The zoom levels every step moves between, as factors of the default.
- MAX
- The largest content zoom.
- MIN
- The smallest content zoom.
Traits§
- Content
Zoom - A widget whose content zooms by itself: a web page (per site), a
document page. The host offers it every zoom gesture before it zooms the
window; it answers with the factor it now shows (for the indicator), or
Noneto leave the gesture to the window.
Functions§
- controls
- The toolkit’s zoom controls, in the toolkit’s own buttons: out, the level
(which returns the content to its own size), and in.
prefixnames the three of them for tests and assistive technology (.zoom-out,.zoom-level,.zoom-in);default_labelis what the middle one says while the content shows at its own size (“Fit to window”, “Actual size”). - is_
zoom_ modifier - Whether
modifiersmake a scroll a zoom: the platform’s command modifier, without Alt. - is_
zoom_ scroll - Whether
eventis a Ctrl+scroll, which zooms rather than scrolls: a scrolling container leaves it to the window (or to a widget whose content zooms by itself). - offer
- Offer
stepto the widgets underwidget, depth first: the factor the first one that took it now shows. - provided