pub trait Plot: IntoElement {
// Required method
fn paint(
&mut self,
bounds: Bounds<Pixels>,
window: &mut Window,
cx: &mut App,
);
// Provided methods
fn prepaint(
&mut self,
_bounds: Bounds<Pixels>,
_window: &mut Window,
_cx: &mut App,
) -> Vec<AnyElement> { ... }
fn id(&self) -> Option<ElementId> { ... }
fn tooltip_state(
&self,
_position: Point<Pixels>,
_bounds: Bounds<Pixels>,
_cx: &App,
) -> Option<TooltipState> { ... }
fn tooltip(
&self,
_state: &TooltipState,
_cursor: Point<Pixels>,
_bounds: Bounds<Pixels>,
_window: &mut Window,
_cx: &mut App,
) -> Option<AnyElement> { ... }
}Required Methods§
Provided Methods§
Sourcefn prepaint(
&mut self,
_bounds: Bounds<Pixels>,
_window: &mut Window,
_cx: &mut App,
) -> Vec<AnyElement>
fn prepaint( &mut self, _bounds: Bounds<Pixels>, _window: &mut Window, _cx: &mut App, ) -> Vec<AnyElement>
Lay out and place the child elements this plot hosts (e.g. element labels).
Called during the element’s prepaint phase, so implementations may use
AnyElement::layout_as_root / AnyElement::prepaint_at to measure and
position children — neither is legal from Plot::paint. The returned
elements are painted right after paint, below the tooltip overlay.
Runs before Plot::tooltip_state and Plot::tooltip, so anything
resolved here can be reused by them.
The default returns no children.
Sourcefn id(&self) -> Option<ElementId>
fn id(&self) -> Option<ElementId>
A stable element id that enables interactive tooltip support for this plot.
Return Some(id) to opt in to tooltips; the id must be unique among sibling
elements. Returning None (the default) disables all tooltip behavior, leaving
the plot a pure, non-interactive element identical to the pre-tooltip behavior.
Sourcefn tooltip_state(
&self,
_position: Point<Pixels>,
_bounds: Bounds<Pixels>,
_cx: &App,
) -> Option<TooltipState>
fn tooltip_state( &self, _position: Point<Pixels>, _bounds: Bounds<Pixels>, _cx: &App, ) -> Option<TooltipState>
Map the cursor to the tooltip state to display.
position is the cursor position relative to the plot’s top-left origin (already
origin-subtracted), and bounds is the painted area. Return the TooltipState
to display (highlighted index, crosshair point, dots, side), or None to show
nothing. Only called while the cursor is inside bounds.
The default returns None.
Sourcefn tooltip(
&self,
_state: &TooltipState,
_cursor: Point<Pixels>,
_bounds: Bounds<Pixels>,
_window: &mut Window,
_cx: &mut App,
) -> Option<AnyElement>
fn tooltip( &self, _state: &TooltipState, _cursor: Point<Pixels>, _bounds: Bounds<Pixels>, _window: &mut Window, _cx: &mut App, ) -> Option<AnyElement>
Render the tooltip overlay for the active TooltipState.
cursor is the live cursor position (relative to the plot origin) and bounds is the
plot’s painted area, so the tooltip box can follow the cursor (pass cursor and
bounds.size to tooltip::Tooltip::new). Return the overlay element; it is painted
absolutely positioned above the plot graphics but below sibling content drawn after
the plot (tooltip::Tooltip defers its box to paint above everything). The default
returns None.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".