Skip to main content

FocusBox

Enum FocusBox 

Source
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.

Trait Implementations§

Source§

impl Clone for FocusBox

Source§

fn clone(&self) -> FocusBox

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for FocusBox

Source§

impl Debug for FocusBox

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for FocusBox

Source§

fn default() -> FocusBox

Returns the “default value” for a type. Read more
Source§

impl PartialEq for FocusBox

Source§

fn eq(&self, other: &FocusBox) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for FocusBox

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.