Skip to main content

Module content_zoom

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§

WindowZoom
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.
ZoomModel
The scale of one app’s content: the levels it steps through, where Ctrl+0 returns to, and the factor it shows now.

Enums§

ZoomGesture
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).
ZoomStep
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§

ContentZoom
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 None to 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. prefix names the three of them for tests and assistive technology (.zoom-out, .zoom-level, .zoom-in); default_label is what the middle one says while the content shows at its own size (“Fit to window”, “Actual size”).
is_zoom_modifier
Whether modifiers make a scroll a zoom: the platform’s command modifier, without Alt.
is_zoom_scroll
Whether event is 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 step to the widgets under widget, depth first: the factor the first one that took it now shows.
provided