pub struct ZoneRegistry<T: Clone + 'static> { /* private fields */ }Expand description
Registry of the currently mounted drop zones, in mount order.
Implementations§
Source§impl<T: Clone + 'static> ZoneRegistry<T>
impl<T: Clone + 'static> ZoneRegistry<T>
Sourcepub fn from_signal(zones: Signal<Vec<ZoneRecord<T>>>) -> Self
pub fn from_signal(zones: Signal<Vec<ZoneRecord<T>>>) -> Self
Wrap an existing signal. Prefer crate::core::hooks::use_dnd_provider.
Sourcepub fn register(&mut self, record: ZoneRecord<T>)
pub fn register(&mut self, record: ZoneRecord<T>)
Add (or replace, by id) a zone.
Sourcepub fn sync_label(&mut self, id: ZoneId, label: Option<String>)
pub fn sync_label(&mut self, id: ZoneId, label: Option<String>)
Update a zone’s label in place (no-op if unchanged or unknown).
Sourcepub fn unregister(&mut self, id: ZoneId)
pub fn unregister(&mut self, id: ZoneId)
Remove a zone (call when its component unmounts).
Sourcepub fn get(&self, id: ZoneId) -> Option<ZoneRecord<T>>
pub fn get(&self, id: ZoneId) -> Option<ZoneRecord<T>>
Look up a zone by id.
Sourcepub fn contains(&self, id: ZoneId) -> bool
pub fn contains(&self, id: ZoneId) -> bool
Is a zone with this id registered here? The parent-zone context is
shared across payload types, so a record’s parent can name a zone
living in another type’s registry - check before navigating to one.
Sourcepub fn ascend(&self, current: ZoneId) -> Option<ZoneId>
pub fn ascend(&self, current: ZoneId) -> Option<ZoneId>
The zone keyboard navigation should enter when ascending from
current: its parent, but only when that parent is registered in
this registry. A DropZone<A> nested inside a DropZone<B> records
B’s id as its parent, and entering an id this registry can’t resolve
would leave the drag hovering a zone that can never receive it.
Sourcepub fn acceptable(&self, payload: &T) -> Vec<ZoneRecord<T>>
pub fn acceptable(&self, payload: &T) -> Vec<ZoneRecord<T>>
All zones accepting payload, in registration order.
Sourcepub fn step_zone(
&self,
current: Option<ZoneId>,
payload: &T,
step: isize,
) -> Option<ZoneId>
pub fn step_zone( &self, current: Option<ZoneId>, payload: &T, step: isize, ) -> Option<ZoneId>
The next/previous zone (cyclic) relative to current among zones that
accept payload. step is +1 or -1.
Order is spatial (top-to-bottom, then left-to-right) for zones
with measured rects - call Self::refresh_rects first, as the
built-in keyboard interaction does on pickup. Unmeasured zones keep
registration order, after the measured ones.
Sourcepub fn children_of(
&self,
parent: Option<ZoneId>,
payload: &T,
) -> Vec<ZoneRecord<T>>
pub fn children_of( &self, parent: Option<ZoneId>, payload: &T, ) -> Vec<ZoneRecord<T>>
Zones directly inside parent (None = root level) that accept
payload, in spatial order (top-to-bottom, left-to-right; unmeasured
zones keep registration order at the end).
Sourcepub fn step_sibling(
&self,
current: Option<ZoneId>,
payload: &T,
step: isize,
) -> Option<ZoneId>
pub fn step_sibling( &self, current: Option<ZoneId>, payload: &T, step: isize, ) -> Option<ZoneId>
Next/previous zone (cyclic) among the siblings of current -
zones sharing its parent. With no current, cycles the root level.
Sourcepub fn first_child(&self, id: ZoneId, payload: &T) -> Option<ZoneId>
pub fn first_child(&self, id: ZoneId, payload: &T) -> Option<ZoneId>
The first (spatially) acceptable zone nested inside id.
Sourcepub fn hit_test(&self, point: Point) -> Option<ZoneId>
pub fn hit_test(&self, point: Point) -> Option<ZoneId>
Topmost zone containing point (client coordinates), using cached
rects - call Self::refresh_rects when a drag starts. Later-mounted
zones win, approximating DOM paint order.
Sourcepub fn hit_test_closest(
&self,
point: Point,
payload: &T,
max_distance: f64,
) -> Option<ZoneId>
pub fn hit_test_closest( &self, point: Point, payload: &T, max_distance: f64, ) -> Option<ZoneId>
Like Self::hit_test, but acceptance-aware: it returns the topmost
zone that both contains the point and accepts payload, and when no
such zone contains the point, falls back to the acceptable zone whose
center is nearest - within max_distance CSS px. Skipping zones that
reject the payload lets a drop land on an accepting zone sitting under
a rejecting (or decorative) one, and is friendlier for imprecise (touch)
drops that land in the gutter between zones.
Sourcepub async fn measure_all(&self)
pub async fn measure_all(&self)
Re-measure every mounted zone’s client rect and wait for the
measurements to land - unlike Self::refresh_rects, which fires
and forgets. Use before a hit-test that must see fresh geometry
(e.g. retrying a missed touch drop after a layout change).
Sourcepub fn refresh_rects(&self)
pub fn refresh_rects(&self)
Re-measure every mounted zone’s client rect (async, spawned).