Skip to main content

ElementCursorState

Trait ElementCursorState 

Source
pub trait ElementCursorState {
    // Required method
    fn is_hovered_with_margins(
        &self,
        id: ElementId,
        margin_left: f32,
        margin_top: f32,
        margin_right: f32,
        margin_bottom: f32,
    ) -> bool;

    // Provided methods
    fn is_hovered_with_margin(&self, id: ElementId, margin: f32) -> bool { ... }
    fn is_hovered_with_axis_margin(
        &self,
        id: ElementId,
        horizontal: f32,
        vertical: f32,
    ) -> bool { ... }
    fn is_hovered(&self, id: ElementId) -> bool { ... }
}
Expand description

Query whether the cursor is over a layout element.

Implementors resolve the element’s bounding box and compare it against the current cursor position. Returns false when the element is unknown.

§Blanket implementation

CotisApp implements this trait when:

  • Renderer: RenderCompatibleWith<Manager> + MouseProvider
  • Manager: LayoutManagerCompatible<Renderer> + ElementBoundingBox

Required Methods§

Source

fn is_hovered_with_margins( &self, id: ElementId, margin_left: f32, margin_top: f32, margin_right: f32, margin_bottom: f32, ) -> bool

Per-edge margins: left, top, right, bottom.

Uses cursor_in_rect_with_margins against the element’s layout bounding box.

Provided Methods§

Source

fn is_hovered_with_margin(&self, id: ElementId, margin: f32) -> bool

Same margin on every side (positive expands the hover region outward).

Source

fn is_hovered_with_axis_margin( &self, id: ElementId, horizontal: f32, vertical: f32, ) -> bool

Horizontal margin applied to left and right; vertical margin to top and bottom.

Source

fn is_hovered(&self, id: ElementId) -> bool

Returns whether the cursor is inside the element’s bounding box with zero margins.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<Renderer: RenderCompatibleWith<Manager> + MouseProvider, Manager: LayoutManagerCompatible<Renderer> + ElementBoundingBox, Pipe> ElementCursorState for CotisApp<Renderer, Manager, Pipe>

Source§

fn is_hovered_with_margins( &self, id: ElementId, margin_left: f32, margin_top: f32, margin_right: f32, margin_bottom: f32, ) -> bool

Implementors§