pub trait Selectable<C: DragConfig = Config> {
// Required method
fn bounds(&self, cfg: &C, measure: &dyn MeasureText) -> Option<RectF>;
// Provided methods
fn selection_box(
&self,
cfg: &C,
measure: &dyn MeasureText,
) -> Option<SelectionBox> { ... }
fn contains(
&self,
cfg: &C,
measure: &dyn MeasureText,
x: f32,
y: f32,
) -> bool { ... }
fn register_into(self, map: &mut HitMap<C>) -> HitId
where Self: Sized + Send + Sync + 'static { ... }
fn as_draggable(&self) -> Option<&dyn Draggable<C>> { ... }
fn as_resizable(&self) -> Option<&dyn Resizable<C>> { ... }
fn element_id(&self) -> String { ... }
}Expand description
An object the user can select on the chart.
Implementations provide Self::bounds only. Selection behavior lives in
the default methods so it is identical across elements; override them only
to change the policy itself.
Required Methods§
Sourcefn bounds(&self, cfg: &C, measure: &dyn MeasureText) -> Option<RectF>
fn bounds(&self, cfg: &C, measure: &dyn MeasureText) -> Option<RectF>
Interaction bounds of this element under cfg, or None when the
element is hidden, empty, or the layout is infeasible. Text-bearing
elements use measure; tick-label elements remain representative
strips rather than exact rendered-label unions.
Provided Methods§
Sourcefn selection_box(
&self,
cfg: &C,
measure: &dyn MeasureText,
) -> Option<SelectionBox>
fn selection_box( &self, cfg: &C, measure: &dyn MeasureText, ) -> Option<SelectionBox>
Default selection policy: a blue box SELECTION_PADDING px outside
the bounds, stroked SELECTION_STROKE_WIDTH px in
SELECTION_COLOR. Resizable elements additionally carry the eight
resize handle squares.
Sourcefn contains(&self, cfg: &C, measure: &dyn MeasureText, x: f32, y: f32) -> bool
fn contains(&self, cfg: &C, measure: &dyn MeasureText, x: f32, y: f32) -> bool
Default hit test: point-in-bounds.
Sourcefn register_into(self, map: &mut HitMap<C>) -> HitId
fn register_into(self, map: &mut HitMap<C>) -> HitId
Default registration: every Selectable can enter a HitMap the
same way. Returns the id the map will report from hit_test.
(Send + Sync because hosts store hit maps in cross-thread render
state, e.g. egui’s CallbackResources.)
Sourcefn as_draggable(&self) -> Option<&dyn Draggable<C>>
fn as_draggable(&self) -> Option<&dyn Draggable<C>>
Sourcefn as_resizable(&self) -> Option<&dyn Resizable<C>>
fn as_resizable(&self) -> Option<&dyn Resizable<C>>
This element’s resize capability, if any. Elements that also implement
Resizable override this with Some(self) — their selection box
then grows the eight resize handles automatically.
Sourcefn element_id(&self) -> String
fn element_id(&self) -> String
Stable element name for hosts that key on identity rather than
HitId (e.g. a wasm host exposing hit-testing as strings):
"data_area", "axis_bottom", "tick_labels_left",
"axis_title_left", "legend", "chart_title",
"colorbar_axis", "colorbar_tick_labels", "colorbar_title".
Custom host elements keep the default.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".