pub(super) struct OcrState {
boxes: Vec<OcrBox>,
image: (f64, f64),
selected: BTreeSet<usize>,
anchor: Option<usize>,
hovered: Option<usize>,
}Expand description
Boxes in reading order, plus what is selected and hovered; indices refer to that order.
Fields§
§boxes: Vec<OcrBox>§image: (f64, f64)§selected: BTreeSet<usize>§anchor: Option<usize>Box a Shift-click or drag extends from.
hovered: Option<usize>Implementations§
Source§impl OcrState
impl OcrState
Sourcepub(super) fn new(boxes: Vec<OcrBox>, image: (f64, f64)) -> Self
pub(super) fn new(boxes: Vec<OcrBox>, image: (f64, f64)) -> Self
image is the displayed texture’s size, used to place the normalized boxes.
pub(super) fn boxes(&self) -> &[OcrBox]
pub(super) fn image(&self) -> (f64, f64)
pub(super) fn is_selected(&self, idx: usize) -> bool
pub(super) fn hovered(&self) -> Option<usize>
Sourcepub(super) fn set_hovered(&mut self, idx: Option<usize>) -> bool
pub(super) fn set_hovered(&mut self, idx: Option<usize>) -> bool
Returns whether the hovered box changed, so callers redraw only when needed.
Sourcepub(super) fn box_at(&self, area: (f64, f64), p: (f64, f64)) -> Option<usize>
pub(super) fn box_at(&self, area: (f64, f64), p: (f64, f64)) -> Option<usize>
Topmost box under p, in the coordinates of a widget of size area.
Sourcepub(super) fn press(&mut self, idx: usize, shift: bool, ctrl: bool) -> bool
pub(super) fn press(&mut self, idx: usize, shift: bool, ctrl: bool) -> bool
Mouse press on a box; returns whether dragging should extend the selection.
Sourcepub(super) fn click(&mut self, idx: usize, extend: bool)
pub(super) fn click(&mut self, idx: usize, extend: bool)
Selects only idx, or toggles it when extend is set.
pub(super) fn select_all(&mut self)
pub(super) fn clear_selection(&mut self)
pub(super) fn has_selection(&self) -> bool
Sourcepub(super) fn selected_text(&self) -> Option<String>
pub(super) fn selected_text(&self) -> Option<String>
Selected boxes’ text, one per line in reading order.
Sourcepub(super) fn all_text(&self) -> Option<String>
pub(super) fn all_text(&self) -> Option<String>
Every box’s text, one per line in reading order.
fn join_text(&self, indices: impl Iterator<Item = usize>) -> Option<String>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for OcrState
impl RefUnwindSafe for OcrState
impl Send for OcrState
impl Sync for OcrState
impl Unpin for OcrState
impl UnsafeUnpin for OcrState
impl UnwindSafe for OcrState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T, Ctx> BundleDefault<Ctx> for Twhere
T: Default,
impl<T, Ctx> BundleDefault<Ctx> for Twhere
T: Default,
§fn default_with_context(_: Ctx) -> T
fn default_with_context(_: Ctx) -> T
Creates a default value with the given context.
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> NoneValue for Twhere
T: Default,
impl<T> NoneValue for Twhere
T: Default,
type NoneType = T
§fn null_value() -> T
fn null_value() -> T
The none-equivalent value.