pub enum FocusBox {
None,
Inflated,
Rect(Rect),
}Expand description
The shape a focused widget’s focus rectangle takes.
A widget being edited has a live control behind it, and what that control answers when asked for a focus rectangle depends on which control it is — three answers, not one, and two of the three are no rectangle at all:
- A text field and a combo box — editable or not — answer an empty rectangle outright, so nothing is stroked over them. This is the common case and it is why the focused text-field goldens carry a caret and glyphs but no outline. Editability does not enter into it: a caller that inflates a read-only combo strokes a box that must not be drawn.
- A check box, a radio button and a single-select list box
answer their window rectangle inflated by one unit on every side, which
is
FocusBox::Inflated. A list box falls through to that answer when it is not multi-select. - A multi-select list box answers the rectangle of the item its caret
sits on, clipped to the client area — a rectangle only the list control’s
own scroll and caret state can name, so a caller that has it supplies it
as
FocusBox::Rect.
annot_render’s own table says the same thing; the two are kept in step
deliberately, because this is the one a pdfrum-form caller reads.
FocusBox::None is the empty answer and the default: a focused entry
that names it is still focused — it draws no tint — and simply strokes
nothing.
use pdfrum_doc::{FocusBox, geom};
// A text field and an editable combo box stroke nothing.
assert_eq!(FocusBox::default(), FocusBox::None);
// A multi-select list box names the rectangle only it can compute.
let explicit = FocusBox::Rect(geom::rect(0.0, 0.0, 100.0, 20.0));
assert_ne!(explicit, FocusBox::Inflated);Variants§
None
No rectangle: nothing is stroked. A text field and an editable combo box always answer this.
Inflated
The annotation’s own rectangle, inflated by one unit on every side.
Rect(Rect)
An explicit rectangle in page space, already in its final position.