Skip to main content

HitMap

Struct HitMap 

Source
pub struct HitMap<C: DragConfig = Config> { /* private fields */ }
Expand description

Registry of selectable elements for one chart panel + point hit-testing.

Hosts feed pointer events here: hit_test returns the topmost registered element under the point (later registrations win — register background elements like the data area first, small foreground elements like titles last). The model owns this because hit-testing is pure bounds geometry; the renderer only supplies the MeasureText implementation.

Implementations§

Source§

impl<C: DragConfig> HitMap<C>

Source

pub fn for_state() -> Self

Create a map for an explicit state type; Cartesian callers keep new().

Source

pub fn register( &mut self, el: impl Selectable<C> + Send + Sync + 'static, ) -> HitId

Source

pub fn hit_test( &self, cfg: &C, measure: &dyn MeasureText, x: f32, y: f32, ) -> Option<HitId>

Topmost element containing (x, y) — entries are tested in reverse registration order.

Source

pub fn get(&self, id: HitId) -> Option<&(dyn Selectable<C> + Send + Sync)>

Source

pub fn selection_box( &self, id: HitId, cfg: &C, measure: &dyn MeasureText, ) -> Option<SelectionBox>

Selection highlight for a registered element — the registered element’s Selectable::selection_box policy.

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source§

impl HitMap<Config>

Source

pub fn new() -> Self

Source

pub fn standard_chart() -> Self

The standard registration set for a single chart panel, back-to-front: data area → axes → tick-label bands → axis titles → legend → chart title → colourbar strip → colourbar axis → colourbar labels → colourbar title.

Colourbar chrome is last, so it wins over anything it overlaps. Its smaller parts follow the strip, allowing the ticks, labels, and title to be selected independently while the strip remains the resize target.

Trait Implementations§

Source§

impl Default for HitMap<Config>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<C = Config> !RefUnwindSafe for HitMap<C>

§

impl<C = Config> !UnwindSafe for HitMap<C>

§

impl<C> Freeze for HitMap<C>
where Vec<Box<dyn Selectable<C> + Send + Sync>>: Freeze,

§

impl<C> Send for HitMap<C>
where Vec<Box<dyn Selectable<C> + Send + Sync>>: Send,

§

impl<C> Sync for HitMap<C>
where Vec<Box<dyn Selectable<C> + Send + Sync>>: Sync,

§

impl<C> Unpin for HitMap<C>
where Vec<Box<dyn Selectable<C> + Send + Sync>>: Unpin,

§

impl<C> UnsafeUnpin for HitMap<C>
where Vec<Box<dyn Selectable<C> + Send + Sync>>: UnsafeUnpin,

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.