Skip to main content

Hooks

Struct Hooks 

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

Source§

impl Hooks

Source

pub fn names(&self) -> Vec<&'static str>

The hooks that are set, by name.

Trait Implementations§

Source§

impl Debug for Hooks

Source§

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

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

impl Default for Hooks

Source§

fn default() -> Hooks

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

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> 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
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> Finish for T

§

fn finish(self)

Does nothing but move self, equivalent to drop.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

§

impl<U, T> ToOwnedObj<U> for T
where U: FromObjRef<T>,

§

fn to_owned_obj(&self, data: FontData<'_>) -> U

Convert this type into T, using the provided data to resolve any offsets.
§

impl<U, T> ToOwnedTable<U> for T
where U: FromTableRef<T>,

§

fn to_owned_table(&self) -> U

Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,