Skip to main content

Module reader_hud

Module reader_hud 

Expand description

Shared reading-surface chrome for the document readers (ebook, pdf_viewer), so both present the same selection affordances with the same spacing, hover, and selected-state treatment:

  • SelectionHud — the floating toolbar shown while a passage is selected: a floating Panel (crate::widget::floating_surface) with the highlight colours as ColorSwatchFaces and Copy / Note / Delete as plain buttons. Presentation + hit-testing only: each app owns the selection model and maps the emitted HudAction to its own command.
  • MarkerDrag — the grab/track/threshold state a reader embeds to let an annotation marker be dragged, agnostic of the coordinate space (page points vs. screen-y).

Nothing here reaches into a document. The HUD is chrome, so it reads the window’s theme end to end; the reading palette stays on the page.

Structs§

HudControls
Which controls a SelectionHud offers besides the always-present Copy: the highlight swatch row, and the Note and Delete controls when enabled.
HudPlacement
Where a SelectionHud floats: anchor is the horizontal centre and top-y of the selection’s first band, bounds the area the bar must stay inside, both in the drawing transform’s space.
HudSwatch
One highlight colour offered in the HUD’s swatch row.
MarkerDrag
A reader begins a drag when a press lands on a marker it owns, tracks the pointer while held, and reads back the marker origin on release to persist the new anchor. Agnostic of the coordinate space (page points vs. screen-y) — the caller decides how to interpret the returned origin.
SelectionHud
A drawn SelectionHud: its bounding rect plus the hit rects of its controls. Built fresh each frame by SelectionHud::draw; the caller either hit-tests it directly via SelectionHud::hit or folds its buttons into its own hit list via SelectionHud::buttons.

Enums§

HudAction
The swatch index in HudAction::Highlight indexes into the swatches slice passed to SelectionHud::draw; the caller maps it back to its own colour model.
HudSide
Which side of the selection a SelectionHud prefers.