Skip to main content

Module zoom

Module zoom 

Source
Expand description

How large the Renderer is drawing, and the application’s way to change it.

Two things make a screen larger. The reader’s operating system has a text size (os), and the application has a zoom level (level), stepped with Command or Control and plus, minus or zero, the way an editor zooms. The level is a whole number from MIN_ZOOM_LEVEL to MAX_ZOOM_LEVEL, and each step is a factor of 1.2. What the screen is drawn at is their product, k = os × 1.2^level.

The Renderer owns both: it reads the system’s setting, answers the keys and remembers the level between runs. It tells the Host the result once at start and again whenever it changes, the way a size class is reported, and this module is where that report is kept for the components that read it. An application that lays out text of its own (an HTML island, a measured paragraph) uses k; one that only uses native widgets needs nothing here, because those are already drawn at the right size.

The application can also set the level, from a menu’s “Zoom In” for example. That rides out on the window record, in the batch the call produces.

Structs§

Zoom
What the Renderer is drawing at, as it last reported.
ZoomHandle
A handle on the zoom. Copy, so it can move into any number of handlers.
ZoomSubscription
A registration for changes to the report. Dropping it ends the registration.

Constants§

MAX_ZOOM_LEVEL
The largest application zoom level. Eight steps of 1.2 up is about four times the size.
MIN_ZOOM_LEVEL
The smallest application zoom level. Eight steps of 1.2 down is about a quarter size.
ZOOM_STEP
The factor one application zoom step multiplies by.

Functions§

app_scale
1.2^level, the application’s share of the factor at a level.
clamp_level
A level kept inside the range the Renderer accepts.
set_zoom_level
Asks the Renderer to draw at level. It goes out on the window record in the batch the current call produces, and the Renderer answers with a new report.
subscribe
Registers notify to be called each time the Renderer reports a different zoom.
zoom
What the Renderer last reported. Available outside a component too.