FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    EffectHostContext

    struct · ferroui-base · v0.5.0

    struct EffectHostContext<'a>
    

    The element an interactive effect is the effect of, as the effect's input handler sees it (Effector's SkiaEffectHostContext): its bounds, the pointer position in its coordinates, normalized to its bounds and in the coordinates of the effect's program, the capture of the pointer, and the invalidation of the effect.

    Three coordinate spaces meet here:

    • the host's own coordinates (get_position), device independent pixels from the top left corner of the host, through every render transform up to the root;
    • the normalized coordinates (get_normalized_position), 0 to 1 across the input bounds, which is what the interactive effects of the library pass as uniforms: independent of the scale, they need no conversion on the render thread;
    • the coordinates of the program (get_effect_position): device pixels from the top left corner of the area of the effect, at layer_scale (section 3.4 of the plan, the coord a program is given).

    The area of the effect is the rectangle the renderer draws the effect over (#580): the bounds of the content of the host's subtree, with the padding of the effect, as the compositor last drew them (render_bounds), so that a normalized position of 0.5 is the middle of what the program draws, also when the content does not fill the host or reaches beyond it. Before the host was drawn (or without a compositor), the area is the host's own bounds with the padding.

    View source

    Members

    effect

    fn effect(self: &Self) -> &'a Effect
    

    The effect.

    Source

    host

    fn host(self: &Self) -> &'a InputElement
    

    The host: the input element the effect is the effect of.

    Source

    visual

    fn visual(self: &Self) -> &'a Visual
    

    The host as a visual.

    Source

    bounds

    fn bounds(self: &Self) -> Rect
    

    The bounds of the host, in the coordinates of its parent.

    Source

    size

    fn size(self: &Self) -> Size
    

    The size of the host.

    Source

    input_bounds

    fn input_bounds(self: &Self) -> Rect
    

    The bounds the pointer is normalized to, in the host's coordinates: the area the renderer drew the effect over without the padding of the effect, so that the input and the program agree (#580; Effector normalizes to the content of the host within its bounds and draws over the same rectangle); the host's own size, from its top left corner, before the host was drawn.

    Source

    input_size

    fn input_size(self: &Self) -> Size
    

    The input size: the size of the input bounds.

    Source

    render_bounds

    fn render_bounds(self: &Self) -> Option<Rect>
    

    The rectangle the renderer drew the effect over in the last frame, in the host's coordinates (#580): the bounds of the subtree of the host, the padding of the effect included, as the compositor read them back. None before the host was drawn, for a host that is not shown, and without a compositor.

    Source

    padding

    fn padding(self: &Self) -> Thickness
    

    The padding of the effect: how far its area reaches beyond the host's bounds.

    Source

    effect_bounds

    fn effect_bounds(self: &Self) -> Rect
    

    The area of the effect in the host's coordinates: the input bounds inflated by the padding of the effect (the rectangle the renderer drew the effect over, once the host was drawn).

    Source

    layer_scale

    fn layer_scale(self: &Self) -> f64
    

    Device pixels per device independent pixel of the host, as the render thread computes the layer_scale of the effect: the render scaling of the host's presentation source times the mean of the lengths of the axes of the transform from the host to the root. 1 for a host that is not in a visual tree.

    Source

    get_position

    fn get_position(self: &Self, e: &PointerEventArgs) -> Point
    

    The position of the pointer of e in the host's coordinates.

    Source

    get_normalized_position

    fn get_normalized_position(self: &Self, e: &PointerEventArgs, clamp: bool) -> Point
    

    The position of the pointer of e normalized to the input bounds: 0 to 1 from the left to the right and from the top to the bottom of the area the effect is drawn over, clamped to 0..1 when clamp is set (Effector's GetNormalizedPosition).

    Source

    normalize

    fn normalize(self: &Self, position: Point, clamp: bool) -> Point
    

    position, in the host's coordinates, normalized to the input bounds; an empty side counts as one pixel.

    Source

    get_effect_position

    fn get_effect_position(self: &Self, e: &PointerEventArgs) -> Point
    

    The position of the pointer of e in the coordinates of the effect's program: device pixels from the top left corner of the area of the effect.

    Source

    to_effect_space

    fn to_effect_space(self: &Self, position: Point) -> Point
    

    position, in the host's coordinates, in the coordinates of the effect's program.

    Source

    capture_pointer

    fn capture_pointer(self: &Self, e: &PointerEventArgs)
    

    Captures the pointer of e to the host, so that the host and the effect receive its input wherever it is until it is released.

    Source

    release_pointer_capture

    fn release_pointer_capture(self: &Self, e: &PointerEventArgs)
    

    Releases the capture of the pointer of e when the host has it.

    Source

    has_pointer_capture

    fn has_pointer_capture(self: &Self, e: &PointerEventArgs) -> bool
    

    Whether the host captures the pointer of e.

    Source

    invalidate

    fn invalidate(self: &Self)
    

    Asks for a new snapshot of the effect: raises its invalidated notification (Effector's Invalidate).

    Source

    request_animation_frame

    fn request_animation_frame(self: &Self, action: impl FnOnce(&EffectHostContext<'_>, SignedDuration) -> () + 'static)
    

    Runs action on the next frame of the animation clock with the frame time, while the effect is still the effect of the host: an effect that animates its uniforms (a ripple that spreads) asks for one frame at a time. Nothing runs when the effect was detached before the frame, or the host or the effect is gone.

    Source

    Trait implementations

    • Send
    • Sync
    • Freeze
    • UnsafeUnpin
    • Unpin
    • UnwindSafe
    • RefUnwindSafe
    • ClassDefaults
    • Borrow<T>
    • BorrowMut<T>
    • Into<U>
    • From<T>
    • TryInto<U>
    • TryFrom<U>
    • Any
    • ErasedDestructor
    • IntoEither

    Availability

    Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.