pub struct Hooks {
pub before_view: Option<Box<dyn FnMut(&ViewChange, &Mapping) -> Verdict<View>>>,
pub on_double_click: Option<Box<dyn FnMut(Pos2, &Mapping, &mut dyn FnMut() -> Option<View>) -> Option<View>>>,
pub before_handle: Option<Box<dyn FnMut(&HandleMove, &Mapping) -> Verdict<[f64; 2]>>>,
pub before_compare: Option<Box<dyn FnMut(&Compare, &Compare) -> Verdict<Compare>>>,
pub on_readout: Option<Box<dyn FnMut(&Readout) -> String>>,
pub under_overlays: Option<Box<dyn FnMut(&Painter, &Mapping)>>,
pub after_paint: Option<Box<dyn FnMut(&Painter, &Mapping)>>,
pub before_display: Option<Box<dyn FnMut(&Resolution) -> Verdict<DisplayTarget>>>,
}Expand description
The hooks of one viewport (all optional). Set them on the
ViewportState with
hooks_mut.
Fields§
§before_view: Option<Box<dyn FnMut(&ViewChange, &Mapping) -> Verdict<View>>>Before the view changes: allow, veto or redirect (clamp the zoom, keep the image in view). Not asked when a gesture is cancelled: that puts back a view already allowed.
on_double_click: Option<Box<dyn FnMut(Pos2, &Mapping, &mut dyn FnMut() -> Option<View>) -> Option<View>>>Replaces the double click on the canvas (not one a handle took).
Gets the pointer, the mapping and the profile’s default action;
returns the view to show, or None for no change. A hook that
handles the click itself does not call the default; one that
passes it on calls it and returns its view. Calling it runs the
whole default: when the profile’s action is to leave the view it
returns None and the viewport sends Signal::Leave, exactly as
without a hook.
before_handle: Option<Box<dyn FnMut(&HandleMove, &Mapping) -> Verdict<[f64; 2]>>>Before a handle moves: allow, veto (it stays) or redirect (snap it to a grid, keep it inside the image).
before_compare: Option<Box<dyn FnMut(&Compare, &Compare) -> Verdict<Compare>>>Before the comparison changes (the current one, the proposed
one): allow, veto or redirect. Over the before key it is asked
once when the key goes down and once when it comes up, the
latter only after a press it let through.
on_readout: Option<Box<dyn FnMut(&Readout) -> String>>Replaces the readout’s text.
under_overlays: Option<Box<dyn FnMut(&Painter, &Mapping)>>After the image, before the overlays: draw between them (a mask’s tint, a selection’s veil), in image coordinates through the mapping; the overlays and their handles stay on top.
after_paint: Option<Box<dyn FnMut(&Painter, &Mapping)>>After the image, the overlays and their handles are drawn: draw more on top, in image coordinates through the mapping.
before_display: Option<Box<dyn FnMut(&Resolution) -> Verdict<DisplayTarget>>>Before the viewport draws for the target it resolved (what is wanted against what the surface carries): allow, veto (draw sRGB) or redirect (draw for another target the surface carries, a soft proof for example). Asked when the resolution changes.
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Hooks
impl !RefUnwindSafe for Hooks
impl !Send for Hooks
impl !Sync for Hooks
impl Unpin for Hooks
impl UnsafeUnpin for Hooks
impl !UnwindSafe for Hooks
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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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>
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>
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<F, T, S> SimdInto<T, S> for Fwhere
T: SimdFrom<F, S>,
S: Simd,
impl<F, T, S> SimdInto<T, S> for Fwhere
T: SimdFrom<F, S>,
S: Simd,
§impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
§fn to_owned_obj(&self, data: FontData<'_>) -> U
fn to_owned_obj(&self, data: FontData<'_>) -> U
T, using the provided data to resolve any offsets.