Skip to main content

Module areas

Module areas 

Source
Expand description

The area registry: what each interactive area writes, declared to the framework, which draws the affordance so a person tells at a glance what only shows from what edits.

Experimental: may change in any release (docs/stability.md).

An interactive area registers each pass it is drawn (register, after its widget) with its kind (AreaKind):

  • display: shows something, writes nothing (a scope’s picture);
  • navigate: moves what is shown without touching what is edited (pan and zoom, the selection, a scope’s mode);
  • edit: writes what the application edits (a parameter, the histogram’s drag), with the control it writes (“Exposure”), its value now (“+0.30 EV”) and, if the application has one, its path.

For an edit area the framework draws, never the widget:

  • its grips at rest (Grip), small handles where a drag takes it (as the handles of a Levels tool): a graph with grips edits, a graph without is a picture;
  • the edit cursor of its drag (AreaSpec::cursor);
  • a hover card naming the control and its value, which is also the area’s accessible description.

An edit area is inert while what it shows is not current: the application side draws a panel whose state is stale, updating or failed inside scope with inert, and a widget asks inert before it senses its drag (dragging the histogram of the previous photo would edit with a wrong picture). An inert area shows no grip, no card and no edit cursor, and is listed as inert.

list gives the areas of each window’s last pass, for agents and tests (the application API carries them on its bus as pop.ui.areas).

use egui_pop_core::areas::{self, AreaSpec, Grip};

fn exposure(ui: &mut egui::Ui, ev: &mut f32) {
    let inert = areas::inert(ui);
    let sense = if inert { egui::Sense::hover() } else { egui::Sense::drag() };
    let (rect, r) = ui.allocate_exact_size(egui::vec2(160.0, 40.0), sense);
    *ev += r.drag_delta().x / rect.width() * 4.0;
    areas::register(
        ui,
        &r,
        AreaSpec::edit("demo.exposure", "Exposure")
            .value(format!("{ev:+.2} EV"))
            .grip(Grip::horizontal(rect.right_center())),
    );
}

Structs§

AreaRecord
An area as the registry lists it, from a window’s last pass.
AreaSpec
An area declared to the registry (register).
Grip
A grip drawn at rest on an edit area: a small handle centred where a drag takes it.

Enums§

AreaKind
What an interactive area writes.
GripAxis
Which way a grip’s drag goes.

Functions§

card_id
The hover card’s id of the area drawn by response’s widget id, for crate::hover_card::open.
find
The area under id in the last pass, if registered.
inert
Whether an edit area drawn in ui now is inert: it senses no edit, shows no grip. Ask it before sensing the drag.
list
The areas of each window’s last pass (the pass drawing, once it ended; the one before while it draws), the main window’s first.
paint_grip
Paints a grip, in the theme’s colours: the raised surface, the strong border (the accent while its area is hovered, dragged or focused) and ridges in the muted text colour.
register
Registers an area drawn this pass, after its widget (response), and draws what the framework draws for it: an edit area’s grips, its cursor and its hover card, unless it is inert. Returns whether it is inert.
scope
Draws add as the content of panel: the areas it registers name the panel, and its edit areas are inert when inert (the panel’s state is not current).