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 set_direction(&mut self, dir: Direction)
pub fn set_direction(&mut self, dir: Direction)
Set the layout direction (no-op if unchanged; safe to call every
render). DndProvider’s dir prop calls this for you.
Sourcepub fn register(&mut self, record: ZoneRecord<T>) -> ZoneRegistration
pub fn register(&mut self, record: ZoneRecord<T>) -> ZoneRegistration
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 set_mounted(
&mut self,
registration: ZoneRegistration,
mounted: Rc<MountedData>,
)
pub fn set_mounted( &mut self, registration: ZoneRegistration, mounted: Rc<MountedData>, )
Attach the mounted element to this exact registration. A stale registration token is ignored.
Sourcepub fn set_rect_if_present(
&mut self,
registration: ZoneRegistration,
rect: Rect,
)
pub fn set_rect_if_present( &mut self, registration: ZoneRegistration, rect: Rect, )
Store a rect only while the registration that requested it is still current. This never inserts a missing zone and therefore cannot resurrect one that unmounted during an async measurement.
Sourcepub fn set_rect(&mut self, id: ZoneId, rect: Rect)
pub fn set_rect(&mut self, id: ZoneId, rect: Rect)
Set geometry for the current registration of id. This is the
synchronous/manual counterpart to Self::set_rect_if_present, used
by custom layout adapters and the headless test driver.
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 cached_rect(&self, id: ZoneId) -> Option<Rect>
pub fn cached_rect(&self, id: ZoneId) -> Option<Rect>
The zone’s cached client rect, read without subscribing. Returns
None when unmeasured, unknown, or the provider is already gone.
Sourcepub fn mounted_handle(&self, id: ZoneId) -> Option<Rc<MountedData>>
pub fn mounted_handle(&self, id: ZoneId) -> Option<Rc<MountedData>>
The zone’s mounted element, read without subscribing. Returns None
before mount, for an unknown zone, or after provider teardown.
Sourcepub fn records(&self) -> Vec<ZoneRecord<T>>
pub fn records(&self) -> Vec<ZoneRecord<T>>
Every registered zone, in registration order. Unlike the peeking lookups around it this is a subscribing read - a component rendering from it re-renders when zones mount or unmount - because its consumers (the debug overlay, your own devtools) are renderers.
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 rect is nearest - within max_distance CSS px of its closest
edge, not its center, so a large zone snaps a release right beside it
even though its center sits far away. 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).
Trait Implementations§
Source§impl<T: Clone + 'static> Clone for ZoneRegistry<T>
impl<T: Clone + 'static> Clone for ZoneRegistry<T>
impl<T: Clone + 'static> Copy for ZoneRegistry<T>
Auto Trait Implementations§
impl<T> !RefUnwindSafe for ZoneRegistry<T>
impl<T> !Send for ZoneRegistry<T>
impl<T> !Sync for ZoneRegistry<T>
impl<T> !UnwindSafe for ZoneRegistry<T>
impl<T> Freeze for ZoneRegistry<T>
impl<T> Unpin for ZoneRegistry<T>
impl<T> UnsafeUnpin for ZoneRegistry<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DependencyElement for T
Source§impl<T> InitializeFromFunction<T> for T
impl<T> InitializeFromFunction<T> for T
Source§fn initialize_from_function(f: fn() -> T) -> T
fn initialize_from_function(f: fn() -> T) -> T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more